Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What are the 16 criteria for compatibility between XHTML and HTML

2025-04-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Development >

Share

Shulou(Shulou.com)06/03 Report--

This article introduces what are the 16 principles of XHTML and HTML compatibility, the content is very detailed, interested friends can refer to, hope to be helpful to you.

HTML is a basic Web web page design language, and XHTML is a markup language based on XML. There are also some differences between the two. This paper introduces 16 principles of compatibility between XHTML and HTML.

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

two。 Add a slash / before the Terminator > of an empty element tag (a tag that cannot be used to contain content). For example, wait a minute.

3. When the content of a non-empty element (this tag is used to contain content, such as headings, paragraphs) is empty, give it a blank character instead of using a closing method like an empty element. For example, when a P tag with no content, please write:

Instead of writing.

4. When there are or two consecutive horizontal bars in your style and scripts content, use external files 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 section of the document. This element is not recommended.

◆ isindex: causes the browser to display a dialog box that prompts the user for a single line of text

◆ in HTML 4, this element is not recommended, but the INPUT element is recommended. The tagName property of isIndex will return input

◆ this element is a block element, this element needs to close the tag

The following example of ◆ uses the ISINDEX element to replace the default prompt:

7. Use the lang and xml:lang attributes when you want to assign language to an element. The value of xml:lang has higher priority.

8. Use the id attribute as the element identifier and avoid using the name attribute. The name attribute is especially discouraged for these elements as their identifiers: a, applet, form, frame, iframe, img, map.

9. Define the document character set for the page. Define character set use for xml documents and character set use for XHTML.

Use this property name for element attribute values of type 10.Boolean. For example: checked= "checked", Boolean type elements are: compact, nowrap, ismap, declare, noshade, checked, disabled, readonly, multiple, selected, noresize, defer.

11.HTML 4 and the XML document object model specify that HTML element and attribute names are returned in uppercase format. Element and attribute names are returned in lowercase format in XHTML.

twelve。 Use & instead of the & symbol in the attribute value, such as:

Http://www.w3cgroup.com/default.asp?CateID=2&page=2

Better than the following:

Http://www.w3cgroup.com/default.asp?CateID=2&page=2

13. The CSS style tag style and attribute names must be lowercase in XHTML.

◆ in HTML's table, tbody will automatically complete when parsing, but not in XML, so you need to add the tbody element yourself, if you use it in the CSS selector

◆ CSS uses the # selector when selecting an element with an id attribute

When ◆ CSS selects an element with a class attribute, use. Selector.

14. How do I use Style elements when parsing XML documents? In HTML 4 and XHTML, the style element can be used to define style rules in the document, and 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 an XML document, the style element needs to use the id attribute as an identifier, and a XML stylesheet references it, such as:

An internal stylesheet example code {color: green; font-family: monospace; font-weight: bold;}

W3CGroup introduces 16 guidelines that are compatible with XHTML and HTML! Http://www.w3cgroup.com/article.asp?id=252.

15. You need to pay attention to white space characters in HTML and XML. Some characters that are legal in HTML documents may be illegal in XML. For example, in HTML, the Formfeed character feed 000C is parsed into spaces, while in XHTML, it becomes illegal because of the character definition of XML.

Pay attention to the special character & apos. (ellipsis, apos; 0027) is introduced in XML 1.0 but does not appear in HTML, and using & # 39; replacement & apos; can be used in HTML 4.

This is the end of the 16 guidelines about the compatibility of XHTML and HTML. I hope the above can be helpful to you and learn more. If you think the article is good, you can share it for more people to see.

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Development

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report