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

About this Entry

This page contains a single entry by Aaron Oliver published on February 26, 2010 6:25 AM.

The Database Is a Time Bomb was the previous entry in this blog.

The Law of Medium Software Projects is the next entry in this blog.

Find recent content on the main index or look in the archives to find all content.

Categories

Creative Commons License
This blog is licensed under a Creative Commons License.