1. Avoid declaring pages as XML type , and use UTF-8 or UTF-16 character sets on pages.
2. Add a slash/ before the ending character > of the empty element label (not used to contain content) , such as: <br />, <hr />, etc.
3. When a non-empty element (this label is used to contain content, such as title, paragraph) is empty, give it a blank character, and do not use an ending method like an empty element , such as: When a P label with no content, please write: <p> </p> instead of <p />.
4. When <, &, ]]> or two consecutive horizontal bars appear in your style and scripts content, please use external files to introduce them.
5. Avoid breaking lines or multiple spaces in element attribute values.
6. Do not include more than one isindex element in the head part of the document (preferably not used). This element is not recommended.
isindex: Makes the browser display a dialog box that prompts the user to enter a single line of text.
In HTML 4, this element is deprecated, and the INPUT element is recommended. The tagName property of isIndex will return input.
This element is a block element, and this element needs to close the tag.
The following example uses the ISINDEX element to replace the default prompt:
<isindex prompt=Enter the index keyword to search/
7. When you want to specify language to an element, please use the lang and xml:lang attributes , the value of xml:lang has higher priority.
8. Please use the id attribute as element identifier, avoid using the name attribute , especially on these elements, it is more disapproving of using the name attribute as their identifier: a, applet, form, frame, iframe, img, map.
9. Define the document character set for the page , use <?xml version=1.0 encoding=UTF-8?> for the xml document, use <meta http-equiv=Content-type content=text/html; charset=UTF-8 />
10. Please use the attribute name for Boolean type element attribute value , such as: checked=checked. Boolean type elements include: compact, nowrap, ismap, declare, noshade, checked, disabled, readonly, multiple, selected, noresize, defer
11. HTML4 and XML document object models specify HTML element and attribute names to return to capital format. Elements and attribute names in XHTML return to lowercase format.
12. Use & to replace the & symbol in the property value
13. In XHTML, CSS style tag style and attribute names must be lowercase ;
In HTML tables, tbody will be automatically filled in when parsing, but not in XML. Therefore, you need to add the tbody element yourself, if you use it in the CSS selector;
When CSS selects an element with an id attribute, use the # selector ; When CSS selects an element with a class attribute, use the . selector ;14. How to use Style elements when parsing XML documents? In HTML4 and XHTML, the style element can be used to define style rules in documents. In XML, XML stylesheet is used to define style rules. In order to be compatible with this rule, if you need to use the style element when parsing XML documents, the style element needs to use the id attribute as an identifier, and there must be an XML stylesheet to refer to it , such as:
<?xml-stylesheet href=http://www.w3.org/StyleSheets/TR/W3C-REC.css type=text/css?>
<?xml-stylesheet href=#internalStyle type=text/css?>
<!DOCTYPE html
PUBLIC -//W3C//DTD XHTML 1.0 Strict//EN
http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd>
<html xmlns=http://www.w3.org/1999/xhtml xml:lang=en lang=en>
<head>
<title>An internal stylesheet example</title>
<style type=text/css id=internalStyle>
code {
color: green;
font-family: monospace;
font-weight: bold;
}
</style>
</head>
<body>
<p>
W3CGroup introduces 16 guidelines for compatible XHTML and HTML!
<code>http://www.w3cgroup.com/article.asp?id=252</code>.
</p>
</body>
</html>
15. Pay attention to whitespace characters in HTML and XML . Some characters that are legal in HTML documents may be illegal in XML. For example, in HTML, the page feed character (Formfeed character U+000C) is parsed into spaces, while in XHTML, it becomes illegal due to the character definition of XML.
16 Note that the special characters "(ellipsis, U+0027) are introduced in XML 1.0, but they do not appear in HTML. If you use "replace ", you can use it in HTML4.