style and script tags in HTML body… why not?

后端 未结 7 2038
野的像风
野的像风 2020-11-29 06:57

[This is related to this question, but not since it\'s not about email.]

In many cases -- especially when working with a CMS or someone else\'s fram

7条回答
  •  囚心锁ツ
    2020-11-29 07:45

    The short answer:

    • STYLE element is only allowed as child of the HEAD element
    • SCRIPT element is allowed as child of the HEAD element, the BODY element and wherever inline-level elements are allowed.

    The detailed answer:

    STYLE is defined to be in head.misc:

    
    

    And elements of head.misc are only allowed to be children of the HEAD element. So STYLE is only allowed to be child of the HEAD element.

    SCRIPT is defined to be in head.misc and in special:

    
    

    And special is defined to be in inline:

    
    

    Additionally SCRIPT is also allowed to be child of the BODY element. So SCRIPT is allowed in the HEAD element nad wherever inline is allowed.

提交回复
热议问题