ACCC Home Page Academic Computing and Communications Center  
Accounts / Passwords Email Labs / Classrooms Telecom Network Security Software Computing and Network Services Education / Teaching Getting Help
 
The A3C Connection, July/August/September 2000 The A3C Connection
July/Aug/Sept Contents Welcome Back! XML and the Future XHTML: Straddling the Fence Processing XML: XSLT
SOAP: Under the Covers RSS: Spreading the News Web Resources Roaming with Eudora About the A3C Connection

XHTML: Straddling the Fence Between HTML and XML

 
News on the Net
WWW Everyone

XML is here, but full support in even the newest Web browsers is problematic, not to mention the older browsers that so many people still use that don’t know anything about XML at all. And virtually all documents on the Web, including yours, are written in HTML, not XML.

Still, you want to get started on XML, without the pain of maintaining multiple versions of files. Maybe you have a compelling need to define your own tags or to use a specialized tag set for math or chemistry; if you do, you know who you are. More likely, you just want to make new documents (and convert old ones if it’s not too hard) that will work with both traditional HTML-based browsers and new XML-based applications as they come along.

What’s a poor developer to do? Yet another acronym: XHTML, Extensible HyperText Markup Language.

  • XHTML is an XML tag set, so XML tools work with it.

  • XHTML can be written to work in existing HTML-based browsers. (Cool!)

  • XHTML looks pretty much like regular HTML, so there isn’t much to learn. You just have to be a bit more strict about your markup.

The defining document for XHTML1 (version 1 of XHTML) is on the W3C Web site: http://www.w3.org/TR/xhtml1/

Fortunately, it’s pretty readable. Some highlights:

  • Tags must nest properly. For example:

    BAD: <font><p> ... </font></p>
    GOOD: <p><font> ... </font></p>

  • Tag names must be lower case. XML is case sensitive, whereas HTML is not. So <h1> or <H1> is fine in HTML, but only <h1> is proper in XHTML.

  • You must enclose attribute values in quotation marks. <font size=1> is OK in HTML, but for XHTML -- actually for all XML -- you have to do it like this: <font size="1">

  • Most HTML elements have content, the “...” between the begin and end tags, e.g., <p> ... </p>
    In XHTML, you must include both the begin tags and the end tags for tags that have content. So, if you use tags such as <p> or <li> or <td>, you must explicitly use the corresponding </p>, </li> or </td> appropriately. And that’s just fine with browsers; in fact, it’s good HTML programming.

  • The HTML tags that that don’t have content, such as <br>, <hr>, and <img>, are a problem. XML requires “empty tags” to be written as <br/>, <hr/>, or <img src="file.gif" />

    Unfortunately, most HTML browsers will choke on <br/>. The good news is you can write it as <br /> with the extra blank space before the “/>” part. That’s valid XML and it will satisfy existing browsers.

There are a few other considerations, but you can see that coding to XHTML standards is pretty easy. Be sure to check the W3C Web site for other links such as validators. It’s not too early to get started with XML. Nor is it particularly difficult.

Bob Goldstein, bobg@uic.edu
ACCC Operating System Support and Development

 
The A3C Connection, July/Aug/Sept 2000 Previous:  XML and the Future Next:  Processing XML: XSLT


2000-10-12  connect@uic.edu
UIC Home Page Search UIC Pages Contact UIC