Skip to content

tag-pair can't make exceptions for elements with optional closing tags #243

@Lithl

Description

@Lithl

Certain elements don't need to have a closing tag; it's implied, and the browser closes it for you. From the html spec, the following tags don't need to be closed:

  • html (if </html> is not meant to be immediately followed by a comment)
  • head (if </head> is not meant to be immediately followed by whitespace or a comment)
  • body (if </body> is not meant to be immediately followed by a comment)
  • li (if the li element is immediately followed by another, or if it's the last child of its parent)
  • dt (if the dt element is immediately followed by another, or by a dd)
  • dd (if the dd element is immediately followed by another, by a dt, or if it's the last child of its parent)
  • p (if the p element is immediately followed by any of a long list of elements, or if it's the last child of its parent and that parent is not a, audio, del, ins, map, noscript, or video)
  • rt (if the rt element is immediately followed by another, by a rp, or if it's the last child of its parent)
  • rp (if the rp element is immediately followed by another, a rt, or if it's the last child of its parent)
  • optgroup (if the optgroup element is immediately followed by another, or if it's the last child of its parent)
  • option (if the option element is immediately followed by another, by an optgroup, or if it's the last child of its parent)
  • colgroup (if </colgroup> is not meant to be immediately followed by whitespace or a comment)
  • caption (if </caption> is not meant to be immediately followed by whitespace or a comment)
  • thead (if the thead element is immediately followed by a tbody or tfoot)
  • tbody (if the tbody element is immediately followed by a thead, tfoot, or if it's the last child of its parent)
  • tfoot (if the tfoot element is the last child of its parent)
  • tr (if the tr element is immediately followed by another, or if it's the last child of its parent)
  • td (if the td element is immediately followed by another, a th, or if it's the last child of its parent)
  • th (if the th element is immadiately followed by another, a td, or if it's the last child of its parent)

The tag-pair rule can't enforce tag pairs for elements that require being paired, while allowing optional closing tags. It's all or nothing. Even just being able to provide exceptions (similar to attr-lowercase) would be useful.

Metadata

Metadata

Assignees

No one assigned

    Labels

    keep-unstaleThe issue will not be marked as stale by the stale-bot

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions