Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support HTML Tags with Optional Closing Tag #94287

Closed
nikeee opened this issue Apr 2, 2020 · 2 comments
Closed

Support HTML Tags with Optional Closing Tag #94287

nikeee opened this issue Apr 2, 2020 · 2 comments
Assignees

Comments

@nikeee
Copy link
Contributor

nikeee commented Apr 2, 2020

HTML5 has tags where the closing tag is optional. These are: html, head, body, p, dt, dd, li, option, thead, th, tbody, tr, td, tfoot, colgroup (source)

A <p> tag automatically closes the one before, if there was one. So this:

<p>Lorem
<p>ipsum
<p>dolor
<p>sit
<p>amet

is equivalent to this:

<p>Lorem</p>
<p>ipsum</p>
<p>dolor</p>
<p>sit</p>
<p>amet</p>

The breadcrumbs (and the document outline) do not seem to be aware of this semantic. Instead of treating both code samples equally, it treats the paragraphs as nested elements when the optional closing tag is omitted.
image
image

This behaviour is the same for all of the above mentioned tags.

Link to spec: https://html.spec.whatwg.org/multipage/syntax.html#optional-tags ("12.1.2.4 Optional tags")

This also effects automatic indentation. VSCode formats the code as follows:

<p>Lorem
    <p>ipsum
        <p>dolor
            <p>sit
                <p>amet

...which is unexpected.

The feature requested is that VSCode should detect HTML tags that get implicitly closed and treat them as if they were closed explicitly. This should be reflected in the document outline as well as in code formatting.

@vscodebot
Copy link

vscodebot bot commented Apr 2, 2020

(Experimental duplicate detection)
Thanks for submitting this issue. Please also check if it is already covered by an existing one, like:

@aeschli
Copy link
Contributor

aeschli commented Apr 3, 2020

duplicate of #89850

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants