It's perfectly fine to have multiple style elements in between your <head>
and </head>
tags.
You can have as many as you want, together with <link>
or <script>
elements.
It's perfectly fine to have multiple style elements in between your <head>
and </head>
tags.
You can have as many as you want, together with <link>
or <script>
elements.
None of the answers have cited any sources, so the OP cannot be sure. (Note that neither the "cascading" part of "CSS" nor the fact that browsers tolerate many STYLE
elements proves anything; e.g. they tolerate (thank God, BTW!) STYLE
elements in the BODY
as well, even though that's considered heresy by the specs, unless the scoped
attr. is used, which is in turn largely unsupported by browsers, despite being valid...)
Here's what the current HTML spec says today (2017-02-08):
Contexts in which this element can be used:
- If the scoped attribute is absent: where metadata content is expected.
- If the scoped attribute is absent: in a noscript element that is a child of a head element.
- If the scoped attribute is present: where flow content is expected, but before any other flow content other than other style elements and inter-element whitespace.
Which effectively means the answer to the original question is, indeed: yes. :)
Yes, this is perfectly valid. CSS stands for "cascading style sheets" (as in, layered on top of each other.) Multiple <style>
tags allow you to include multiple style sheets or multiple style declarations.