The type attribute in the <style>
element identifies the type of media being used.
If the type attribute is not declared, it defaults to text/css
.
Is there a performance cost (however small) for not declaring type="text/css"
in the <style>
element?
The type attribute applied to the style tag has only one acceptable value: text/css . In theory, other types of styling could also be used between style tags–thus the need for a type attribute.
The type attribute specifies the Internet media type (formerly known as MIME type) of the <style> tag. The type attribute identifies the content between the <style> and </style> tags. The default value is "text/css", which indicates that the content is CSS.
The HTML type Attribute is used to specify the type of button for <button> elements. It is also used in the <input> element to specify the type of input to display. For embed elements like link, object, script, source, and style used to specify the Internet Media Type.
From MDN Style docs on the type
attribute:
This attribute is optional and defaults to text/css if it's missing.
Since it defaults to the correct one, there is no impact.
You might as well ask if there is a performance cost for making an HTTP request in the first place. It is impossible to completely eliminate the notion of performance itself. At some point you're either at 100% performance efficiency for your page, standards compliant or not. The complimentary aspect to performance is standards in this case. Another example would be entrepreneurialism and execution. All the great ideas in the world are utterly useless unless you can execute to make said business fit into an economic model that works in the real world.
Now it is possible to make great leaps in performance. Back in the 80s and 90s, you could either buy a cheap Honda (non-standards here) or you could improve performance (Porsche, Ferrari or McLaren). Then Tesla came along and completely blew away even the best in acceleration. Disclaimer: I really don't care about cars but it's an easy analogy for most to comprehend.
As someone who has left very few rocks untouched, I can attest to you personally that eventually, it is not you though your environment in which performance increases should be sought. So while I commend you for trying to think outside the box I would make other considerations as to where to improve performance.
*
selector.animation
of box-shadow except on ::after
and ::before
pseudo-elements.position
absolute
and fixed
on moderate or minor layout aspects; reserve for only major layout elements.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With