XHTML 1.0: Where XML and HTML meet (4/8) - exploring XML | WebReference

XHTML 1.0: Where XML and HTML meet (4/8) - exploring XML

XHTML 1.0: Where XML and HTML meet

How to ensure backwards compatibility?

Here are some design guidelines to follow for XHTML documents to render correctly in existing HTML user agents.

  1. Properly format empty elements I
    Include a space before the trailing / and > of empty elements, e.g. <br />, <hr /> and <img src="photo.jpg" alt="Photo" />. Also, use the minimized tag syntax for empty elements, e.g. <br />, as the alternative syntax <br></br> allowed by XML gives uncertain results in many existing user agents.
  3. Properly format empty elements II
    Given an empty instance of an element whose content model is not EMPTY (for example, an empty title or paragraph) do not use the minimized form (e.g. use <p> </p> and not <p />).
  5. Eliminate embedded Style Sheets and Scripts
    Use external style sheets and scripts if they use < or & or ]]> or --. XML parsers are permitted to silently remove the contents of comments, so the historical practice of "hiding" scripts and style sheets within comments to make the documents backward compatible is likely to not work as expected in XML-based implementations.
  7. Avoid Line Breaks within Attribute Values
    Avoid line breaks and multiple whitespace characters within attribute values. These are handled inconsistently by user agents.
  9. Use only one isindex element
    Don't include more than one isindex element in the document head. It is deprecated in favor of the input element.
  11. Use the lang and xml:lang Attributes
    Use both the lang and xml:lang attributes when specifying the language of an element.
  13. Fix up Fragment Identifiers
    In XML, URIs [RFC2396] that end with fragment identifiers of the form "#target" do not refer to elements with an attribute name="target"; rather, they refer to elements with an attribute defined to be of type ID, e.g., the id attribute in HTML 4. Many existing HTML clients don't support the use of ID-type attributes in this way, so identical values may be supplied for both of these attributes to ensure maximum forward and backward compatibility (e.g., <a id="target" name="target">...</a>).
  15. Add the XML Character Encoding declaration
    To specify a character encoding in the document, use both the encoding attribute specification on the xml declaration (e.g. <?xml version="1.0" encoding="EUC-JP"?>) and a meta http-equiv statement (e.g. <meta http-equiv="Content-type" content='text/html; charset="EUC-JP"' >>).
  17. Use Ampersand entities in Attribute Values
    When an attribute value contains an ampersand, it must be expressed as a character entity reference (e.g. "&amp"). For example, when the href attribute of the a element refers to a CGI script that takes parameters, it must be expressed as
    NOT: http://webref.com/cgi-bin/xml/demo1.pl?style=none&name=user
    BUT: http://webref.com/cgi-bin/xml/demo1.pl?style=none&amp;name=user

next page


Produced by Michael Claßen
All Rights Reserved. Legal Notices.

URL: http://www.webreference.com/xml/column6/4.html
Created: Feb. 07, 2000
Revised: Feb. 07, 2000