Montana Jones

Montana n: A state of the northwest United States bordering on Canada. Admitted as the 41st state in 1889. The fourth largest state in the union, it includes vast prairies and numerous majestic mountain ranges.
Syn: Treasure State, Big Sky Country, Last Best Place.

Jones n: slang. An addiction or very deep craving.

Monday, October 03, 2005

Meaningful XHTML

I no longer work professionally as a web geek, but I dabble on the side and try to keep up. I have long been a fan of the style sheet and I thought tables for layout was a cludge from the first time I did it. As web code evolves, new and different ways of doing things appear. Sometimes these things are a step forward but sometimes they make life harder.

I am completely okay with the death of <font>. I like the idea of closing all single <tags />. But there are other things I am still coming to terms with. I am told from The Elements of Meaningful XHTML that there are certain HTML things I am doing wrong. Such as:

Avoid <b> <br/> <i> <sub> <sup>

I don't know about you, but <br /> is one of my most used tags. I started my web dev career in a design shop and the designers were always haranguing me about the layout of their text. It took a long time before these ink on paper people completely grasped the concept that the text could be different sizes and fonts on different screens. I was always fighting code, with designer right over my shoulder, trying to make text layout more attractive. It took me a long time to grasp the concept that attractive and well formatted text is a good thing and makes web pages better. To this day when I knock out web code there is always an imaginary designer lurking over my shoulder telling me the text is ugly. <br /> was my friend then and it is still a powerful tool today. It is simple, easy to code, produces exactly the result I want in every browser, it can be styled, backwards compatible, and now I am not supposed to use it in meaningful code. I am having a hard time finding any explanation of how I am supposed to modify my formatting to work without a <br /> tag.

That's not all that I am doing wrong. On this very blog I like to write conversations a lot. I usually use definition lists for the conversation like this:

<dl>
  <dt>Me</dt>
  <dd>What do you want to do today?</dd>

  <dt>They</dt>
  <dd>I dunno, what do you want to do?</dd>
</dl>

It is a pretty simple way to get the layout I want with a minimum of tags and code. Technically I am not supposed to do this. DT is supposed to be a term and DD is supposed to be a definition.

The DL lists are a very useful tool for layout. I have seen them used for headlines and articles, speakers and quotes, names and addresses, times and events, and even definition lists. Pretty much anything that can be matched in a Key/Value pair. But most of these things are not meaningful XHTML.

Here is how a conversation is supposed to look:

<ol>
  <li>
    <cite>Me</cite>
    <blockquote>What do you want to do today?</blockquote>
  </li>

  <li>
    <cite>They</cite>
    <blockquote>I dunno, what do you want to do?</blockquote>
  </li>
</ol>

See, it is still a list (ordered list) of spoken statements; each item in the list cites a speaker and quotes what they said. The code becomes more meaningful to the document. Apply a style sheet and it can render exactly like the definition list I use.

I know this is technically correct and valid XHTML and the way of the future and meaningful and all that crap, and I really hate it.

  • I hate it because it is a lot more tags and a lot more programming to do the same thing.
  • I hate it because the overseers of XHTML were thinking Term and Definition instead of Key and Value and took away a very useful set of tags.
  • I hate it because it stinks like programmer snobbery.
  • I hate it because HTML was supposed to be the great liberator of human expression. So simple that anyone could do it and even if it was done wrong it would degrade gracefully and still render on screen.
  • I hate it because it makes it harder to teach to the unwashed masses that wish to communicate through web pages.
  • I hate it because now there is a right way and a wrong way to write a web page. The standard of 'does it work' is depreciated.

Someday I hope there will be created some XHTML tags for key/value pairs so I can get back on the 'correct code' bandwagon, but in the meantime here is what I intend to do about it. First, I am going to stop feeling inferior when I use a 'transitional' doctype. Slightly mungy code is what 'transitional' is for right? I'll save the pure XHTML for when it is really needed. Next I am going to keep right on using DT and DL for my conversations but I will start them this way:

<dl class="conversation">

Now anyone reading the code will know that this is a special sort of definition list. And if they read the style sheets and enough of the document they will realize it is not a definition list at all, but actually a key/value list in the form of a conversation. In other words it will still be meaningful. To human beings at least. Not meaningfully correct XHTML, but the validator wont know the contents of the list is actually a conversation so it will pass.

I will try to grow like a good little webgeek. I will try avoiding my beloved <br />, I will make a habit of <strong> instead of <b>, use <em> instead of <i>, use my classes to clarify wanky code and I will hope that one day web code will be simplified enough to wear down the layers of bureaucracy between the common Joe and the wild wild web of communication.

Comments:
div tags, while better than the old tables, seem to inspire a lot of kludges of their own. when messing with my blog layout, I noticed it was impossible to get it how I really wanted.
 
I am having an awful time at the moment with the xhtml break tag in IE.

I am trying to include a single line break, as opposed to the dreaded para break - but i find that in IE the break tag is actually producing a double line break - of course in sensible mozilla browsers this problem does not arise.

Have you ever come across this - or a fix for single line breaks?
 
Post a Comment

<< Home