My XHTML 1.0 Strict Resolution

XHTML 1.0 Strict is my new best friend. Designing pages using this doctype is the perfect new year’s resolution to ensure that my site is slim and trim.

So, we could get into the argument about whether HTML 4.01 Strict is better than XHTML 1.0 Transitional, but personally I think that argument is not worth having until you can tell me why you are not adopting the W3C standard of XHTML 1.0 Strict.

Here are the reasons I’m choosing XHTML 1.0 Strict:

  1. I want my web pages to be easily interpreted by any user agent whether it be a screenreader, a browser on a laptop or on a mobile phone. XHTML’s cleaner and more stringent syntax is a language based on all that we’ve learned over the past 10+ years of the web. It includes the power of XML to define date with the strength of HTML’s ability to display data. Any coder can quickly see the advantage of having all tags closed, properly nested and well formed.
  2. But XHTML 1.0 isn’t good enough for me without the Strict. What does Strict mean? Clean separation of content from presentation. This separation makes a web site modular and easier to maintain while drastically reducing page size.

I’m beginning to think of my XTHML 1.0 Strict New Year’s resolution as a diet for my web sites.

Only new trick I had to learn when moving from XHTML 1.0 Transitional to XHTML 1.0 Strict was how to get my forms to validate. I had made the “old-fashioned” mistake of wrapping a <div> around my <form>. I kept getting the following errors from the XHTML validator:

  • document type does not allow element “label” here; missing one of “p”, “h1”, “h2”, “h3”, “h4”, “h5”, “h6”, “div”, “pre”, “address”, “fieldset”, “ins”, “del” start-tag.
  • document type does not allow element “input” here; missing one of “p”, “h1”, “h2”, “h3”, “h4”, “h5”, “h6”, “div”, “pre”, “address”, “fieldset”, “ins”, “del” start-tag.

Scratching head. Huh? What do you mean I can’t have a “label” and an “input” here? Did you know that in XHTML 1.0 Strict the <form> tag can only contain block level tags? This means that the <input> and <label> tags need to be wrapped in a block level tag within the <form> tag or you too will suffer the two errors listed above.

If you used to do this:

<div>
<form …>
<label…> … </label>
<input… />

</form>
</div>

To be XHTML 1.0 Strict you’ll need to do this:

<form …>
<div>
<label …> … </label>
<input … />

</div>
</form>

So, what is your new year’s resolution for your web site? Will your code be ready for bikini season?

11 comments

  1. Actually, you could replace the div with a Fieldset, thus limiting the markup only to form elements.

    I think my code is ready for bikini season, being xhtml1.1 strict :)

  2. You have some killer marketing skills, my friend! I do not speak fluent geek; but I read this entire post anyway because of the hot model. Mad props to you! ;)

  3. You and I should talk. Sounds like our two professional worlds are overlapping somewhat. I’d like to learn a little more about this and the differences between XHTML strict and the XML I’ve been working with.

    Oh yeah…and about that model? Yes, it would be a faboo Valentine’s gift.

    -r-

  4. Thank you! You saved my hair. I had been pulling them trying to figure out WTF is up with the error :)
    In fact, what I did was instead of putting the tag outside the tag, I simply enclosed all that followed below the tag into a tag which solved all the problems.

  5. lol i realized my tags didn’t show. Forgot to use code them

    In fact, what I did was instead of putting the tag outside the tag, I simply enclosed all that followed below the tag into a tag which solved all the problems.

  6. lol, I give up! Thank you though, using “fieldset” tag instead of putting the “form” tag outside the “div” tag did the job. Just enclosed all the form elements within the “fieldset” tag.

Comments are closed.