WSS Home   XML/XSL Project

[Current WSSG Projects][XML project home]

Can Web Browsers Acceptably Display XHTML Pages?

The sneaky thing about XHTML 1.0 is that we have carefully designed it so that if you follow a few simple guidelines it will work equally on most existing HTML browsers as well as XML systems.

- Steven Pemberton, W3C's HTML Working Group chair, in An Expert's View on XHTML 1.0.

If we intend to advocate that XHTML be used as a markup language for Web pages, we will first need to be highly confident that most browsers can acceptably display XHTML pages.

Toward this end, the following are results from simple tests of how various Web browsers display pages with selected XHTML markup.

Two XHTML test documents were contrasted with an HTML 3.2 document

Two test documents were used, conforming to the following markup standards, respectively:

  1. First Test Document: XHTML 1.0, with an XML declaration
  2. Second Test Document: XHTML 1.0, without an XML declaration

These two test documents were contrasted with a third document, conforming to the following markup standard:

  1. Third Test Document: HTML 3.2

containing the same set of document features as the two XHTML test documents.

Three XHTML-specific features were tested

Three XHTML-specific features were examined to determine how they were displayed by Web browsers. The first XHTML test document uniquely contained:

The first and second XHTML test documents also both contained:

(Note: this was not an exhaustive display test of all XHTML-specific features. For instance, XHTML is an XML application of HTML 4, and so certain valid XHTML markup elements may not be recognized by older browsers which are not compatible with HTML 4.0 or 4.0.1.)

Conclusion

All of the many Web browsers tested to date - even the earliest Web browsers - acceptably displayed the second XHTML test document.

These browsers displayed the contents of the second XHTML test document identically to the contents of the third document, which used only HTML 3.2 markup. This uniformity of displayed output was apparently irrespective of the extent to which any of these browsers recognized the test document's XHTML-specific declarations, attributes, and closing tags. These results offer some early promise that nearly all Web browsers may be capable of acceptably displaying XHTML documents.

Some browsers did not acceptably display the contents of the first XHTML test document. This is because the XML declaration <?xml version="1.0 ..."?> was literally displayed at the top of this document, which is undesirable behavior. Fortunately, the use of this XML declaration is optional for XHTML documents. By leaving it out, it seems that XHTML documents can then be displayed acceptably in a wide variety of browsers.

In the W3C's formal recommendation for XHTML, XHTML™ 1.0: The Extensible HyperText Markup Language, the authors acknowledged this problem:

[From Appendix C. HTML Compatibility Guidelines:] Be aware that processing instructions are rendered on some user agents.

They pointed out that the use of this XML declaration is optional, although recommended:

[From Section 3. Normative Definition of XHTML 1.0:] An XML declaration ... is not required in all XML documents. XHTML document authors are strongly encouraged to use XML declarations in all their documents. Such a declaration is required when the character encoding of the document is other than the default UTF-8 or UTF-16.

How Various Web Browsers Display Pages Containing Three XHTML Features

Browser
(Platform, Year)
Avoids displaying XML declaration?
<?xml version="1.0"...?>
Avoids displaying XHTML document type?
<!DOCTYPE...XHTML...>
Properly handles XHTML closing tags?
<tag />
Apple Help Viewer 1.2.1
(Mac OS, 1999)

(This offline-only browser was tested by opening local files)
Yes Yes Yes
iCab Preview 2.2
(Mac OS, 2000)
Yes Yes Yes
Lynx 2.8.3rel.1
(Solaris 2.6, 2000)
Yes Yes Yes
MacLynx beta 1 (based on Lynx 2.7.1)
(Mac OS, 1997)
Yes Yes Yes
MacWeb 1.00Alpha3.2
(Mac OS, 1995)

(Tested by opening local files)
Yes Yes Yes
Microsoft Internet Explorer 2.1b1
(Mac OS, 1996)
No

Displayed page contents acceptably, except that the literal XML declaration, <?xml version="1.0" encoding="UTF-8"?>, was displayed at the top of the page.

Yes Yes
Microsoft Internet Explorer 3.01a
(Mac OS, 1997)
No

Displayed page contents acceptably, except that the literal XML declaration, <?xml version="1.0" encoding="UTF-8"?>, was displayed at the top of the page.

Yes Yes
Microsoft Internet Explorer 4.01 SP1
(Microsoft Windows 32-bit, 1998)
Yes Yes Yes
Microsoft Internet Explorer 4.5
(Mac OS, 1998)
Yes Yes Yes
Microsoft Internet Explorer 5.0
(Mac OS, 2000)
Yes

However, when opening the first XHTML test document, xhtml-testdoc1.html, as a local file, this browser appeared to interpret the file in an XML context, rather than in an HTML context. It then displayed the message An error occurred parsing the XML file ... and identified line 3 of this file, which begins with <!DOCTYPE ...>, as the location of this error.

Yes Yes
Microsoft Internet Explorer 5.5
(Microsoft Windows 32-bit, 2000)
Yes Yes Yes
NCSA Mosaic 1.0.3
(Mac OS, 1994)

(Tested by opening local files)
Yes Yes Yes
NCSA Mosaic 2.0.1
(Mac OS, 1995)
Yes Yes Yes
Netscape Navigator 2.02
(Mac OS, 1996)
No

Displayed page contents acceptably, except that the literal XML declaration, <?xml version="1.0" encoding="UTF-8"?>, was displayed at the top of the page.

Yes Yes
Netscape Navigator 3.01
(Mac OS, 1997)
No

Displayed page contents acceptably, except that the literal XML declaration, <?xml version="1.0" encoding="UTF-8"?>, was displayed at the top of the page.

Yes Yes
Netscape Navigator 4.08
(Mac OS, 1998)
Yes Yes Yes
Netscape Communicator 4.76
(Mac OS, 2000)
Yes Yes Yes
Netscape 6.0
(Mac OS, 2000)
Yes Yes Yes
Netscape 6.0
(Microsoft Windows 32-bit, 2000)
Yes Yes Yes
Opera 4.02
(Microsoft Windows 32-bit, 2000)
Yes Yes Yes
Sassafras HTML Viewer 1.3.1
(Mac OS, 1997)

(This offline-only browser was tested by opening local files)
Yes Yes Yes
WebTV Viewer 1.1
(WebTV simulator for Mac OS, 1999)
Yes

Displayed page contents acceptably. However, the separate Page Notes window (only present in the simulator and thus not visible to end users of the WebTV browser) displayed the "error": Unrecognized tag "<?XML>"

Yes Yes

Displayed page contents acceptably. However, the separate Page Notes window displayed three distinct Unrecognized attribute "notes" pertaining to the 'space-slash' closings of <br>, <hr>, and <img> tags, as well as Unrecognized attribute notes pertaining to the following three attributes of the <html> tag, of which two are XHTML-specific: xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"

WebTV Viewer 2.0
(WebTV simulator for Mac OS, 1999)
Yes

Displayed page contents acceptably. However, the separate Page Notes window (only present in the simulator and thus not visible to end users of the WebTV browser) displayed the "error": Unrecognized tag "<?XML>"

Yes Yes

Displayed page contents acceptably. However, the separate Page Notes window displayed three distinct Unrecognized attribute "notes" pertaining to the 'space-slash' closings of <br>, <hr>, and <img> tags, as well as Unrecognized attribute notes pertaining to the following three attributes of the <html> tag, of which two are XHTML-specific: xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"

WebTV Viewer 2.5
(WebTV simulator for Microsoft Windows 32-bit, 2000)
Yes

Displayed page contents acceptably. However, the separate Page Notes window (only present in the simulator and thus not visible to end users of the WebTV browser) displayed the "error": Unrecognized tag "<?XML>"

Yes Yes

Displayed page contents acceptably. However, the separate Page Notes window displayed three distinct Unrecognized attribute "notes" pertaining to the 'space-slash' closings of <br>, <hr>, and <img> tags, as well as Unrecognized attribute notes pertaining to the following three attributes of the <html> tag, of which two are XHTML-specific: xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"

Credits: Thanks are offered to Björn Höhrmann of Adobe Systems for his excellent corrections and suggestions, and to Peter-Paul Koch for his test reports using Netscape 6 for the Mac OS and Microsoft Windows (98 and NT).

URL:http://seaotter.berkeley.edu/xml/xhtml-compatibility.html
Last modified on Wednesday, 09-May-2001 15:57:54 PDT