What do you call tags that need no ending tag?

后端 未结 13 1450
旧时难觅i
旧时难觅i 2020-12-13 00:12

There are HTML tags, such as , and

相关标签:
13条回答
  • 2020-12-13 00:41

    Optional closing tags like p, li, etc.

    It is also worth mentioning that several other tags besides those mentioned in the question don't need a closing tag: they just close automatically when something specified in the standard appears.

    For example:

    <body>
    <p>abc
    <p>def
    </body>
    

    is equivalent to:

    <body>
    <p>abc
    </p>
    <p>def
    </p>
    </body>
    

    because the p closes both at:

    • the start of another p
    • when the parent of the p closes

    This is specified at 12.1.2.4 "Optional tags" https://html.spec.whatwg.org/multipage/syntax.html#optional-tags but I don't think there's an actual name besides "an element with an optional closing tag".

    See also: P-end-tag (</p>) is not needed in HTML

    0 讨论(0)
提交回复
热议问题