Is it necessary to write HEAD, BODY and HTML tags?

后端 未结 6 2089
清酒与你
清酒与你 2020-11-22 05:10

Is it necessary to write , and tags?

For example, I can make such a page:



        
6条回答
  •  终归单人心
    2020-11-22 05:52

    It's valid to omit them in HTML4:

    7.3 The HTML element
    start tag: optional, End tag: optional
    
    7.4.1 The HEAD element
    start tag: optional, End tag: optional
    

    http://www.w3.org/TR/html401/struct/global.html

    In HTML5, there are no "required" or "optional" elements exactly, as HTML5 syntax is more loosely defined. For example, title:

    The title element is a required child in most situations, but when a higher-level protocol provides title information, e.g. in the Subject line of an e-mail when HTML is used as an e-mail authoring format, the title element can be omitted.

    http://www.w3.org/TR/html5/semantics.html#the-title-element-0

    It's not valid to omit them in true XHTML5, though that is almost never used (versus XHTML-acting-like-HTML5).

    However, from a practical standpoint you often want browsers to run in "standards mode," for predictability in rendering HTML and CSS. Providing a DOCTYPE and a more structured HTML tree will guarantee more predictable cross-browser results.

提交回复
热议问题