-
Notifications
You must be signed in to change notification settings - Fork 2.7k
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
“a start tag must never be omitted if it has any attributes” #10691
Comments
I don't think this can be skipped, because the other conditions are not conditional upon the element not having attributes. |
I had to read that statement a few times and am not sure I understand 🙂 Maybe taking a step back, how can one omit a start tag that has attributes, if attributes can only be set on start tags? From going over the section it doesn’t look like it wouldn’t work without the sentence (or some rephrasing to make clear what omitting a start tag means in the context of attributes being present). Even if this was to miss something, the spec might get clearer by explaining it to everyone. |
Thanks for sharing more context. I’m still not clear about the value of the sentence in question (which humbly includes I might just not get something), but if it’s important to make Like, “A head element’s start tag may be omitted if the element has no attributes, is empty, or if the first thing inside the head element is an element.” (if that’s what this is referring to)? |
Sure, but then we'd have to add that clause for each element whose start tag may be omitted. Instead we use a catch-all clause at the end. |
It sounded like this was just to be extra sure about the There’s still the question how authors would omit a start tag if there are attributes on it, also given that attributes can only be set on start tags. Assuming it’s possible or likely, how about two adjustments:
If I understood you right, that could meet the spirit of the sentence while making the section a bit more easier to read. |
I think Jens is right: that statement as currently written isn’t correct. The actual intent of the requirement regards whether the start tag’s element has attributes — not about whether the start tag itself does. The problem with the text are currently written is the word “it”, which incorrectly refers to the start tag itself. So I’ve raised #10752 with an attempt at fixing that. |
(Love the proactive PR!)
More of a side note but would love to learn—have I been missing something here, am I not seeing the forest for the trees? How can an author omit a start tag—or an element—that has attributes? Anne’s and your response both seem to indicate that it’s possible, but I don’t understand it—I’d appreciate if someone could explain, especially when I’m missing something obvious. I only see something like (While I conceded earlier when Anne suggested this was just about the Thanks! |
The phrasing is a little odd, but it's talking about what transformations you can perform without changing the resulting DOM (and which ones you can't, because it would result in a change). For example, you can omit the Similarly, you can't omit a start tag if it has attributes (because the resulting DOM will then lack those attributes). |
I’ve reached out directly to three peers (some on the thread) but, unfortunately, couldn’t get to more clarity off-thread. (Still, many thanks for the feedback on and off the thread!) Here’s the best I can currently summarize the issue: The way the spec and previous responses put it, there are actually two readings of “[…] a start tag must never be omitted if it has any attributes”:
What’s more, this could come with different motivations:
I understand the spec so that the case is 2.—but the way the sentence is phrased, it seems it’s saying 1. (which had me wonder and file this issue). To avoid ambiguity, the wording benefits from being tweaked—it’s probably a small edit, that with some reordering (bring the statement closer to the other “may or may not be omitted” statements) could make the section clearer and easier to read. If this is hard to explain and resolve because it’s clear to “everyone else,” I hope this shows how it can be understood differently. |
What is the issue with the HTML Standard?
§ 13.1.2.4 (optional tags) states that
If this refers to an esoteric use case (any that come to my mind look like like they would be treated as text), it would be helpful to give a brief example and provide more detail.
If there’s no practical way to set attributes without a start tag (which it looks like), it seems this could be skipped? (Happy to file a PR.)
The text was updated successfully, but these errors were encountered: