After introducing how to correctly use JavaScript and CSS in XHTML, W3CGroup continues to provide 16 Guidelines for XHTML compatibility with HTML! 1.
Avoid page declaration as XML type, The page uses the UTF-8 or UTF-16 character set.
2.Add a slash/Such:
,
And so on.
3.When the content of a non-empty element (this label is used to contain content, such as a title or paragraph) is empty, a blank character is given, instead of an end method like an empty element.For example, if there is no content for a P tag, please write it:
Instead of writing
.
4.When <, &,]> or two consecutive horizontal bars appear in your style and scripts content, use an external file to introduce them.
5.Avoid line breaks or multiple spaces in element attribute values.
6.Do not include more than one isindex element in the head of the document.(Not recommended). This element is not recommended.
Isindex: enables the browser to display a dialog box prompting the user to enter a single line of text.
In HTML 4, this element is not recommended, but the INPUT element is recommended. The tagName attribute of isIndex will return input.
This element is a block element, which needs to be closed.
The following example uses the ISINDEX element to change the default prompt:
Enter the index keyword to search
7.To specify a language for an element, use the lang and xml: lang attributes., Xml: lang has a higher priority.
8.Use the id attribute as the element identifier to avoid using the name attribute.In particular, these elements do not favor using the name attribute as their identifiers: a, applet, form, frame, iframe, img, map.
9.Define document character set for the pageTo define character sets for xml documents. To define the character set for XHTML.
10.Use the attribute name for attribute values of Boolean elements.Such as: checked = "checked", Boolean Type elements include: compact, nowrap, ismap, declare, noshade, checked, disabled, readonly, multiple, selected, noresize, defer
11.HTML 4 and XML Document Object Models specify the uppercase format for HTML elements and attribute names. The element and attribute names in XHTML are returned in lowercase.
12.Use & replace & Symbol in attribute values
13.In XHTML, the CSS style label style and attribute names must be in lower case.;
In an HTML table, tbody will be automatically filled during parsing, but not in XML. Therefore, you need to add the tbody element yourself, if it is used in the CSS selector;
When CSS selects an element with the id attribute, use the # selector.;
When CSS selects an element with the class attribute, it uses the. selector.;
14. How do I use the Style element when parsing XML documents? In HTML4 and XHTML, style elements can be used in the document to define style rules. In XML, XML stylesheet is used to define style rules. To be compatible with this rule,If you need to use the style element when parsing XML documents, the style element must use the id attribute as the identifier, and an XML stylesheet must reference it.Such:
PUBLIC "-// W3C // dtd xhtml 1.0 Strict // EN"
Http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd>
An internal stylesheet example
W3CGroup introduces 16 Guidelines compatible with XHTML and HTML!
http://www.w3cgroup.com/article.asp?id=252
.
15.Note the white space characters in HTML and XML.. Some valid characters in HTML documents may be invalid in XML. For example, in HTML, The Formfeed character U + 000C is parsed as a space, in XHTML, XML is invalid due to its character definition.
16Note the special character '(ellipsis, U + 0027)It is introduced in XML1.0 but not in HTML. You can use 'offset' in html4.