Are Type Attributes on SCRIPT, STYLE, and LINK elements still needed?

前端 未结 4 503
时光取名叫无心
时光取名叫无心 2021-01-12 02:41

You will see many sites with the following type of code:

Script elements:



        
4条回答
  •  滥情空心
    2021-01-12 03:22

    In short, they are not required since HTML5, but are required by W3C standards in HTML4/XHTML.


    In HTML5 type of script tag:

    type - This attribute identifies the scripting language of code embedded within a script element or referenced via the element’s src attribute. This is specified as a MIME type; examples of supported MIME types include text/javascript, text/ecmascript, application/javascript, and application/ecmascript. If this attribute is absent, the script is treated as JavaScript.

    in HTML4 and XHTML it's required by W3C standards.

    For style and link type:

    In HTML5, the type attribute is no longer required. Default value is "text/css".

提交回复
热议问题