Skip to content

Closing tag is missing but valid HTML is still not parseable #294

@benjifs

Description

@benjifs

Is there a reason why the following isn't parseable?

const dom1 = nodeHtmlParser.parse(`<body><main class=h-entry><p>hello</main></body>`)
console.log(dom1.querySelectorAll('.h-entry'))

It seems like the <p> tag is not required to be closed as mentioned in the spec:

Tag omission in text/html:
A p element's end tag can be omitted if the p element is immediately followed by an address, article, aside, blockquote, details, dialog, div, dl, fieldset, figcaption, figure, footer, form, h1, h2, h3, h4, h5, h6, header, hgroup, hr, main, menu, nav, ol, p, pre, search, section, table, or ul element, or if there is no more content in the parent element and the parent element is an HTML element that is not an a, audio, del, ins, map, noscript, or video element, or an autonomous custom element.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions