spacer

Webref WebRef   Sitemap · Experts · Tools · Services · Newsletters · About i.com

home / experts / xml / column6

XHTML 1.0: Where XML and HTML meet

Technical Lead
Thomson Reuters (Markets) LLC
US-NY-New York

Justtechjobs.com Post A Job | Post A Resume
Developer News
Microsoft Shows Off Silverlight 4, IE9 Plans
Metasploit Expands Vulnerability Test Framework
HyperCard Reborn?


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.
  2. 
    
  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 />).
  4. 
    
  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.
  6. 
    
  7. Avoid Line Breaks within Attribute Values
    Avoid line breaks and multiple whitespace characters within attribute values. These are handled inconsistently by user agents.
  8. 
    
  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.
  10. 
    
  11. Use the lang and xml:lang Attributes
    Use both the lang and xml:lang attributes when specifying the language of an element.
  12. 
    
  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>).
  14. 
    
  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"' >>).
  16. 
    
  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

http://www.internet.com

internet.commediabistro.comJusttechjobs.comGraphics.com

Search:

WebMediaBrands Corporate Info

Legal Notices, Licensing, Permissions, Privacy Policy.
Advertise | Newsletters | Shopping | E-mail Offers | Freelance Jobs

webref The latest from WebReference.com Browse >
Rolling Out Your Own HTML Application Version Control · HTML 5: Client-side Storage · Working with Ajax Server Extensions
Sitemap · Experts · Tools · Services · Email a Colleague · Contact FREE Newsletters 
 The latest from internet.com
Wi-Fi Product Watch, November 2009 · Chip Market Recovering From '08 Collapse · Low-Cost Tools to Kickstart Your New Business

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