HTML 5: Is it
,
, or
?

后端 未结 29 3250
滥情空心
滥情空心 2020-11-22 00:26

I\'ve tried checking other answers, but I\'m still confused — especially after seeing W3schools HTML 5 reference.

I thought HTML 4.01 was supposed to \"allow\" singl

29条回答
  •  慢半拍i
    慢半拍i (楼主)
    2020-11-22 00:33

    I think this quote from the HTML 5 Reference Draft provides the answer:

    3.2.2.2 Void Elements

    The term void elements is used to designate elements that must be empty. These requirements only apply to the HTML syntax. In XHTML, all such elements are treated as normal elements, but must be marked up as empty elements.

    These elements are forbidden from containing any content at all. In HTML, these elements have a start tag only. The self-closing tag syntax may be used. The end tag must be omitted because the element is automatically closed by the parser.

    HTML Example:
    A void element in the HTML syntax. This is not permitted in the XHTML syntax.


    Example:
    A void element using the HTML- and XHTML-compatible self-closing tag syntax.


    XHTML Example:
    A void element using the XHTML-only syntax with an explicit end tag. This is not permitted for void elements in the HTML syntax.


提交回复
热议问题