Content deleted Content added
Line 405:
Like HTML 4.01, XHTML 1.0 has three sub-specifications: strict, transitional, and frameset.
 
Aside from the different opening declarations for a document, the differences between an HTML 4.01 and XHTML 1.0 document—in each of the corresponding DTDs—are largely syntactic. The underlying syntax of HTML allows many shortcuts that XHTML does not, such as elements with optional opening or closing tags, and even empty elements which must not have an end tag. By contrast, XHTML requires all elements to have an opening tag and a closing tag. XHTML, however, also introduces a new shortcut: an XHTML tag may be opened and closed within the same tag, by including a slash before the end of the tag like this: {{code|lang=html|code=<br />}}. The introduction of this shorthand, which is not used in the SGML declaration for HTML 4.01, may confuse earlier software unfamiliar with this new convention. A fix for this is to include a space before closing the tag, as such: {{code|lang=html|code=<br />}}.<ref>Freeman, E (2005). Head First HTML. O'Reilly.</ref>
 
To understand the subtle differences between HTML and XHTML, consider the transformation of a valid and well-formed XHTML 1.0 document that adheres to Appendix C (see below) into a valid HTML 4.01 document. Making this translation requires the following steps:
Line 413:
# If present, '''remove the XML declaration.''' (Typically this is: {{code|lang=xml|code=<?xml version="1.0" encoding="utf-8"?>}}).
# '''Ensure that the document's MIME type is set to <code>text/html</code>.''' For both HTML and XHTML, this comes from the HTTP <code>Content-Type</code> header sent by the server.
# '''Change the XML empty-element syntax to an HTML style empty element''' ({{code|lang=html|code=<br />}} to {{code|lang=html|code=<br />}}).
 
Those are the main changes necessary to translate a document from XHTML 1.0 to HTML 4.01. To translate from HTML to XHTML would also require the addition of any omitted opening or closing tags. Whether coding in HTML or XHTML it may just be best to always include the optional tags within an HTML document rather than remembering which tags can be omitted.