5 ms·
Yep not a bug. Or at least if it's a bug, it's a bug in the HTML spec. But really I think it's pretty reasonable behavior. Short answer is standard says to par
by missblit 7y ago
Yep not a bug. Or at least if it's a bug, it's a bug in the HTML spec. But really I think it's pretty reasonable behavior.
Short answer is standard says to parse the contents of <style> elements as text.
Long answer is style start tag triggers [1] the generic raw text element parsing algorithm [2] which switches the parsers insertion mode to "text" [3] which only exits once an end tag is seen. Given that the generic raw text element parsing algorithm switched the tokenizer to RAWTEXT state [4] it will only output an end tag token from the RAWTEXT end tag name state [5] for an appropriate end tag token [6] which by definition will be "</style>"
[1] https://html.spec.whatwg.org/#parsing-main-inhead https://html.spec.whatwg.org/#parsing-main-inhead
[2] https://html.spec.whatwg.org/#generic-raw-text-element-parsing-algorithm https://html.spec.whatwg.org/#generic-raw-text-element-parsi...
[3] https://html.spec.whatwg.org/#parsing-main-incdata https://html.spec.whatwg.org/#parsing-main-incdata
[4] https://html.spec.whatwg.org/#rawtext-state https://html.spec.whatwg.org/#rawtext-state
[5] https://html.spec.whatwg.org/#rawtext-end-tag-name-state https://html.spec.whatwg.org/#rawtext-end-tag-name-state
[6] https://html.spec.whatwg.org/#appropriate-end-tag-token https://html.spec.whatwg.org/#appropriate-end-tag-token
- ChrisSD 7y ago> Or at least if it's a bug, it's a bug in the HTML spec. Then again the HTML5 spec is based on what browsers already did, bugs included. Whether or not it's desirable behaviour or a bug is a moot point now. HTML is the way it is because of its history.