Humane HTML Tag Wraps?

| Comments

Every now and then I find myself writing HTML by hand. Sometimes the tags have lots of attributes, or they have long values. This makes them way longer than the aesthetic 80-ish character max. What’s the best way to wrap them?

If I start with:

<a href="http://codesoftly.com" id="awesome-link-one" class="link main" rel="bookmark">mylink</a>

What’s the best way to wrap it?

Stacked: Everything on Its Own Line?

<a href="http://codesoftly.com" 
     id="awesome-link-one" 
     class="link main" 
     rel="bookmark">mylink</a>

I like this because it’s clear what all the attributes are. There’s little chance of missing one because it’s way off the right of the screen.

I don’t like that it hides what the link text is.

One Long Opening Tag With Linked Text Indented?

<a href="http://codesoftly.com" id="awesome-link-one" class="link main" rel="bookmark">
    mylink
</a>

I like this because it leaves the link text clear and on a line by itself. It’s crummy because that first line can get really long.

Something In Between?

<a href="http://codesoftly.com" id="awesome-link-one" 
     class="link main" rel="bookmark">mylink</a>

I’m not sure this is any better. It feels like the worst of both worlds.

Oh, and “How Dreamweaver does it” isn’t a legitimate answer.

blog comments powered by Disqus