3 ms·
If this were true, I'd expect this HTML: <p>A<br B</p> <p>C</p> To render as this: A B C But instead it renders as this: A C T
by lolinder 3y ago
If this were true, I'd expect this HTML:
<p>A<br B</p>
<p>C</p>
To render as this:
A
B
C
But instead it renders as this:
A
C
The parser treats `B<` and `p` as attributes of `br`, and determines that the `<br` tag ends with the `>` at the end of line 1.
If I end the `<br` with either `/>` or `>`, it parses correctly. Which means that `/>` and `>` are both considered valid endings for the `<br` tag, but you have to have one or the other and it will keep looking until it finds one.
- phatskat 3y agoRight, I think the person you’re replying to is partially correct in that the parser gets to “<br “ and recognizes that “this is be a br tag”, but it doesn’t close because tags can have any arbitrary attributes, and the W3C says br may also contain any of the global attributes. So, the parser indeed doesn’t just stop because it knows what tag it is and then doesn’t allow any attributes, it has to keep going until it reaches a valid closing “>”.