Home  >  Article  >  Web Front-end  >  16 Guidelines for XHTML1.0 and HTML Compatibility Summary_HTML/Xhtml_Web Page Production

16 Guidelines for XHTML1.0 and HTML Compatibility Summary_HTML/Xhtml_Web Page Production

WBOY
WBOYOriginal
2016-05-16 16:42:591459browse

1.Avoid declaring the page as XML type. The page uses UTF-8 or UTF-16 character set.

2.Add a slash / before the end character > of an empty element tag (a tag that cannot be used to contain content), such as:
,


etc.

3.When a non-empty element (this tag is used to contain content, such as a title, paragraph) is empty, give it a blank character instead of using the ending method like an empty element, for example: when a P tag has no content, please write:

instead of

.

4.When <, &, ]]> or two consecutive horizontal bars -- appear in your style and scripts content, please use external files to import them.

5.Avoid line breaks or multiple spaces in element attribute values.

6.Do not include more than one isindex element in the head part of the document (it is best not to use it). This element is not recommended.
isindex: Causes the browser to display a dialog box prompting the user to enter a single line of text.
In HTML 4, this element is deprecated and the INPUT element is recommended. The isIndex property of the tagName will return the input.
This element is a block element, and this element requires a closing tag.
The following example uses the ISINDEX element to replace the default prompt:

7.When you want to specify language for 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 the element identifier and avoid using the name attribute . Especially on these elements, it is not recommended to use the name attribute as their identifier: a, applet, form, frame, iframe, img, map.

9.Define the document character set for the page , use to define the character set for the xml document, and define the character set for XHTML Use

10.Please use this attribute name for Boolean type element attribute values, 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 Model specify that HTML element and attribute names return uppercase format. Element and attribute names in XHTML are returned in lowercase format.

12.Use & to replace the ampersand in attribute values ​​

13. In XHTML, the CSS style tag style and attribute names must use lowercase ;
In the HTML table, the tbody will be automatically completed during parsing, but this does not work in XML , so you need to add the tbody element yourself, if it is used 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 the Style element when parsing XML documents? In HTML4 and XHTML, the style element can be used to define style rules in the document. In XML, the 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 the XML document, the style element You need to use the id attribute as the identifier, and there must be an XML stylesheet referencing it , such as:



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 items for you Guidelines for XHTML and HTML compatibility!
http://www.w3cgroup.com/article.asp?id=252.



< /html>


15.You need to pay attention to the white space character in HTML and XML. Some characters that are legal in HTML documents may not be legal in XML. For example, in HTML, the formfeed character (Formfeed character U 000C) is parsed as a space, but in XHTML, due to the character definition of XML, it become illegal.

16Pay attention to the special character ' (ellipsis, U 0027) It is introduced in XML1.0, but does not appear in HTML. Use ' to replace ' and it can be used in HTML4 use.

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn