Since 2000, HTML 4 has a successor, called XHTML I. It has exactly the same elements as HTML 4, but it is written using XML syntax. The XML syntax will make it easier in the future to combine XHTML with other XML-based languages, such as MathML (for mathematical expressions), SVG (for diagrams, maps, and other graphics) and SMIL (for multimedia) into a single format for many different types of documents. In this book, we used HTML 4 for the examples, but all browsers also accept XHTML I. The syntax differences are small: All element names must be written in lowercase in XHTML: HTML | XHTML |
---|
<P> | <p> | <H1> | <h1> | <OL> | <ol> | <DIV> | <div> | etc. | |
All elements that don't have an end tag in HTML need a slash (/) just before the > in XHTML: HTML | XHTML |
---|
<img> | <img /> | <hr> | <hr /> | <br> | <br /> | <link> | <link /> | <meta> | <meta /> | <base> | <base /> | <isindex> | <isindex /> | <input> | <input /> |
All elements whose end tag may be omitted in HTML have a required end tag in XHTML: HTML | XHTML |
---|
<html>... | <html>...</html> | <body>... | <body>...</body> | <p>... | <p>...</p> | <li>... | <li>...</li> | <dt>... | <dt>...</dt> | <dd>... | <dd>...</dd> |
In HTML, attributes that consist of only letters or digits, without any spaces or other symbols, don't need quote marks. In XHTML, all attributes, without exception, need to be quoted: HTML | XHTML |
---|
rowspan=2 | rowspan="2" | class=property | | width=45 | width="45" | id=fig17 | | etc. | |
In HTML, some attributes don't have a value; their presence is enough. In XHTML, they require a value that is the same as their name: HTML | XHTML |
---|
checked | checked="checked" | selected | selected="selected" |
XHTML files must have a DOCTYPE just before the <html>. Currently, that looks like this: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"> <html> ...
This indicates the first element of the format (html), the unique name for the format, including the version number (-//W3C//DTD XHTML 1.1//EN), and finally, the place on the Web where one can find a formal grammar for this format. |