HTML and CSS Reference
In-Depth Information
<li>Parmesan</li>
<li>Swiss</li>
</ul>
So, when dealing with div , span , and the class attribute, be sure you aren't using them
instead of more appropriate (X)HTML elements, and be sure you are using as few of them as
possible. They're useful when used properly, but they can clutter up your document and cause
a great deal of confusion if you're not careful.
Choosing Your Markup Language and DOCTYPE
HTML isn't the only game in town when it comes to web markup. XHTML has hit the ground
running and is now very popular among many web designers and developers. Even after you
choose one of the two, you'll still have to decide exactly which version you intend to write
against. There are several factors to consider, and it's important to think them through and
choose the right markup language for your project—changing down the road may prove
tedious and time consuming.
HTML vs. XHTML: Why the Decision Does—and Doesn't—Matter
HTML was the original language of the Web, and it continues to be the most widely used.
HTML 4.01 is both the most recent and last version of HTML—it is the final W3C specification
for HTML. XHTML 1.0 was created after HTML 4.01 to encourage a transition to a new genre
of markup languages. XHTML is a reformulation of HTML in XML. Because of this, XHTML
documents are both hypertext documents and XML documents.
As far as the users of your web site are concerned, there is almost no real-world benefit to
using XHTML over HTML. However, there are still a few compelling reasons why you, as
a developer, may prefer XHTML.
XHTML, because of its XML roots, has far more rigorous syntax rules than HTML. Although
this may seem like a bad thing at first glance, it actually forces authors to be more precise, which
in turn makes XHTML documents easier to maintain than their HTML counterparts. The most
relevant examples of XHTML's more particular syntax requirements include insisting that all ele-
ment and attribute names be lowercase, requiring that all attribute values be quoted, and
demanding that all elements—even empty ones—be properly closed.
As valid XML, your XHTML documents can theoretically be parsed by XML utilities that
would choke on HTML pages. Also, as valid XML your XHTML documents are ready to be
manipulated by Extensible Stylesheet Language Transformations (XSLT). While we don't dis-
cuss XSLT in this topic, you may find it to be relevant in your organization, and preferring XHTML
to HTML will give you this extra layer of compatibility.
Note If you want to find out more about using XML and XSLT in your work, check out Beginning XML with
DOM and Ajax:From Novice to Professional,by Sas Jacobs (Apress, 2006, ISBN 1590596765) and Beginning
XSLT 2.0:From Novice to Professional,by Jeni Tennison (Apress, 2005, ISBN 1590593243).
Search WWH ::




Custom Search