Supported by :   My Law Forms Ltd. - Deed polls and Tenancy Agreements

XHTML Formatting – tag attributes

Quote everything

In order to become a ninja coder you will have to pass the quote test. The rule is simple: quote all attribute values, period.

Here’s a GOOD example:

<a href=“http://yoursite.com”>My Site</a>
And here’s a BAD example:

<a href=http://yoursite.com>My Site</a>

In HTML 4 you could get away with not quoting your attribute values but not anymore.
Breaking and spacing

Sometimes when you’re writing xHTML you’ll get a really long line. You’ll probably want to break the line, which is okay, just don’t do it in the middle of an attribute value. It’s likely that your attribute will get messed up if you do. You’ll also want to avoid multiple spaces in attributes as well, just one will do.

<a href= “http://yourdomain.com” title=“A link to
my website”>My Website</a>

That example just looks ugly. It would be much better if it looked like this:

<a href= “http://yourdomain.com”
title=“A link to my website”>My Website</a>

This entry was posted on Thursday, January 11th, 2007 at 12:22 pm and is filed under XHTML tips. You can follow any responses to this entry through the RSS 2.0 feed. Both comments and pings are currently closed.

Comments are closed.