Hey. Welcome to A Slacker's Guide to XHTML. What I'm thinking is that you are here for a crash course in XHTML. You wanna know why the hell you should care about XHTML, and I'm going to try to tell you.
- - What is XHTML and Why Do I Care?
- - The Three Flavors of XHTML
- - Useful Information for HTML/XHTML Authors
What is XHTML and why should I care?
Well, I'm not really saying you should care, but you should definitely take notice of some of the changes taking place. Read the rest of this page for the background information and what the basic point of switching to XHTML is. If you want to skip ahead and get right to the meat of it and find out exactly how this change affects the way you will make web documents, then click on "Rules" to the right.
As the W3C states, "With a wealth of features, XHTML 1.0 is a reformulation of HTML 4.01 in XML, and combines the strength of HTML4 with the power of XML."
In the immortal words of (once again) the W3C "XHTML 1.0 is the first major change to HTML since HTML 4.0 was released in 1997. It brings the rigor of XML to Web pages and is the keystone in W3C's work to create standards that provide richer Web pages on an ever increasing range of browser platforms including cell phones, televisions, cars, wallet sized wireless communicators, kiosks, and desktops.
XHTML is modular making it easy to combine with markup tags for things like vector graphics, multimedia, math, electronic commerce and more. content providers will find it easier to produce content for a wide range of platforms, with better assurances as to how the content is rendered."
The Three Flavors of XHTML
. Sounds yummy, right? Well, it's really not. There will be three ways to implement, or carry out, your XHTML markup. You specify which of these variants you are using by inserting a line at the beginning of the document. For example, the HTML for this document starts with a line which says that it is using XHTML 1.0 Transitional. Thus, if you want to validate the document (or simply view it with a browser), the tool used knows which variant you are using. Each variant has its own DTD - Document Type Definition - which "sets out the rules and regulations for using HTML in a succinct and definitive manner." - W3C
- One way is for the bad-ass, hardcore perfectionist or professional web-designer (strict). "Use this when you want really clean structural mark-up, free of any tags associated with layout. Use this together with W3C's
Cascading Style Sheet language (CSS) to get the font, color, and layout effects you want." - W3C
- The other way is for the average Joe, like you and I. This is called Transitional. "The idea is to take advantage of XHTML features including style sheets but nonetheless to make small adjustments to your mark-up for the benefit of those viewing your pages with older browsers which can't understand style sheets." - W3C
- The final of the three tasty flavors of XHTML is for when you want to use HTML
frames to partition the browser window into two or more frames. This is frameset XHTML.
Useful information for HTML/XHTML authors
Guidelines for authoring
Here are some rough guidelines for HTML authors. If you use these, you are more likely to end up with pages that are easy to maintain, look acceptable to users regardless of the browser they are using, and can be accessed by the many Web users with disabilities.
A question of style sheets. For most people the look of a document - the color, the font, the margins - are as important as the textual content of the document itself. But make no mistake! HTML is not designed to be used to control these aspects of document layout. What you should do is to use HTML to mark up headings, paragraphs, lists, hypertext links, and other structural parts of your document, and then add a style sheet to specify layout separately, just as you might do in a conventional Desk Top Publishing Package. That way, not only is there a better chance of all browsers displaying your document properly, but also, if you want to change such things as the font or color, it's really simple to do so.
Basically, you aren't supposed to use HTML for layout anymore. Instead, use HTML tags to do things like make text bold, to make a table, or whatever, but leave the layout to CSS.
FONT tag considered harmful! Many filters from word-processing packages, and also some HTML authoring tools, generate HTML code which is completely contrary to the design goals of the language. What they do is to look at a document almost purely from the point of view of layout, and then mimic that layout in HTML by doing tricks with FONT, BR and (non-breaking spaces). HTML documents are supposed to be structured around items such as paragraphs, headings and lists. Yet some of these documents barely have a paragraph tag in sight!
The problem comes when the content of pages needs to be updated, or given a new layout, or re-cast in XML (which is now to be the new mark-up language). With proper use of HTML, such operations are not difficult, but with a muddle of non-structural tags it's quite a different matter; maintenance tasks become impractical. To correct pages suffering from injudicious use of FONT, try an HTML validating program, which will do its best to put things right and generate better and more manageable HTML.
Make your pages readable by those with disabilities. The Web is a tremendously useful tool for the visually impaired or blind user, but bear in mind that these users rely on speech synthesizers or Braille readers to render the text. Sloppy mark-up, or mark-up which doesn't have the layout defined in a separate style sheet, is hard for such software to deal with. Wherever possible, use a style sheet for the presentational aspects of your pages, using HTML purely for structural mark-up.
More: the Rules of XHTML