Web Design

The future language of electronicpublishing is called XML. But in the meantime, XHTML will do very nicely, thankyou
Click to follow
The Independent Online

THE EXTENSIBLE Markup Language andExtensible Style Language (XSL) hold many promises for Web designers,not the least of which is the ability to separate the display of content from itslayout. Freeing the content from its layout means that rather than having tosweat over the details on each page, you can control the layout for a sitefrom a single location.

THE EXTENSIBLE Markup Language andExtensible Style Language (XSL) hold many promises for Web designers,not the least of which is the ability to separate the display of content from itslayout. Freeing the content from its layout means that rather than having tosweat over the details on each page, you can control the layout for a sitefrom a single location.

The question is, how do you get Web designersto switch from HTML, with which they are comfortable, to the more complexXML, which for non-programmers can look dauntingly cryptic? Theanswer is XHTML. XHTML is a hybrid of the recently updated HTML 4.01standard and XML. It ishoped that it will be used to begin the transition - relatively painlessly- from HTML to XML.

XHTML uses the XML Document Type Definitions(DTD) - collections of declarations that tell the browser how totreat the structure, elements and attributes of the tags that it finds in adocument. However, XHTML uses all of the same tags as the HTML DTD.The upshot of this is that while XHTML Web pages can use the strength of XML,the code will still work even if the browser cannot understand XML.

So,if they are so similar, why change? The World Wide Web Consortium(W3C) gives two pretty good reasons: The "X" in XHTML standsfor extensible. That means that it is a lot easier to add new capabilities toXHTML over HTML.

Since the way in which tags act are defined in a DTDrather than by the individual browser, XHTML will be more modular andtherefore its capabilities can be added to for future browsers or otherWeb-enabled devices without sacrificing any backwardscompatibility.

The W3C claims that by the year 2002, 75 per cent of Webtraffic will be on "alternate" platforms such as TVs, PalmPilots andmobile phones. If you think it is hard to code HTML for a few differentbrowsers, imagine dozens of different devices! A standard language isneeded. In addition, since these devices will have a smallerbandwidth, the code will need to be as compact as possible, somethingthat XHTML is perfect for.

The W3C hopes that if Web designers begin usingXHTML now, they can began to reap the benefits of XML without having to giveup the skills they have worked so long to develop in HTML. In fact, ifyou know HTML, then you already know all of the XHTML tags.

The mainthing you will have learn, or relearn, is how these tags can and cannotbe used. XHTML is a good deal stricter than HTML in terms of what it allowsyou to do and not do. However, this leads to cleaner, faster andeasier to understand HTML code.

So what are the differences between HTMLand XHTML? XHTML is far more restrictive, that is, it will not allowyou to "bend" the rules and still get away with it:

No overlappingtags: Most browsers do not care whether HTML tags are properly nested insideof each other or not. So <p>You are <b>great</p></b> works just fine.

Not so in XHTML. The correctsyntax in this case would have to be: <p>You are <b>great</b></p>

Tags and attributes have to be lower case: XML is casesensitive, so <li> and <LI> are different tags. Keep allof your tags and attributes in lower case and you will be fine.

Always usean end tag. Often Web designers will simply slam a <p> tag in toseparate paragraphs. With XHTML, however, you would have to use<p>Your text</p>.

Use a slash in empty tags: rulethree doesn't make much sense for <br> or <li> tags wherethere is no closing tag. Instead, you need to include a slash in the tagto make it self-closing (eg, <br/>).

Don'tnest links. In other words: <a src="this.html">This <asrc="that.html">That</a></a> does not work. But why would you want to dothat in the first place?

Use "id" instead of "name"; Ifyou are identifying an element on the screen, such as an image, use theid attribute instead of the name attribute.

It looks as though XHTML,along with Cascading Style Sheets, may be the future of Web design.Although the browsers have been slow to adapt these standards, the one thingthat the W3C seems to have done right with XHTML is to make sure that it willalways be backwards compatible.

But XHTML is not a standard, yet.Currently, it is a "proposed recommendation" that is likely to becomea full-blown recommendation (ie, standard) some time within thenext few months.

The great thing about the Web is that it is not a passivemedium like television or radio. You can get involved and help to define itsfuture.

This is even true of the languages we use to create it, andXHTML is no exception. The W3C is currently taking public comments on thisstandard until 22 September.

I recommend that any Web designer interestedin the future of the Web take a look at the proposed recommendation(www.w3c.org/TR/xhtml1/) and then write to the W3Cwith any comments (www-html@w3.org) making sure to includeXHTML in the subject line of the e-mail. Oh, and if you could CC meon those e-mails, I would appreciate seeing what you think ofXHTML.

Jason Cranford Teague is theauthor of DHTML for the World Wide Web. You can find an archive of thiscolumn at WebbedEnvironments.

Comments