Does the HTML5 specification ignore CSS inside HTML comments?

Can someone tell me what the next paragraph in the HTML5 specification means? Regarding the processing of the contents of the element <style>:

https://www.w3.org/TR/html5/document-metadata.html#the-style-element

All descendant elements must be processed according to their semantics before the style element itself is evaluated. For styling, languages ​​consisting of pure text (unlike XML), user agents must evaluate the style elements, passing the concatenation of the contents of all Text nodes that are children of the style element ( not any other nodes, such as comments or elements ), in a tree to style system. For XML-based modeling languages, user agents must pass all the children of the style element to the style system.

It seems to me that the HTML parser should remove all HTML elements and comments inside the element <style>before sending the resulting text to the style system.

The content in the HTML comment is also a text node, but it is not a direct child of the style element, so it cannot be included in the text sent to the style system.

Modern browsers do not seem to process comments or elements inside style elements, but treat style contents as CDATA compatible with HTML 4. But this paragraph in the HTML5 specification says that this is not the right behavior, is it? If not, what am I missing?

+4
source share
1 answer

node element node style - DOM- - style DOM , HTML .

, , HTML HTML- <style>…</style>. , .

HTML <style>…</style> , , .

, HTML, - .

, ?

html.spec.whatwg.org/multipage/syntax.html#raw-text-elements style - " ".

HTML 4 , - CDATA. , , HTML5.

, HTML " ", , CDATA HTML4.

, "</style"?

:

" " :

- , , , .

, script, , , <script>, " " </script>.

+2

Source: https://habr.com/ru/post/1661612/


All Articles