Where does internal CSS go?
I know that internal CSS should be in the <head></head>
section of a (X)HTML document, but does it need to be before/after certain <meta>
or <title>
elements or can it be any o开发者_开发问答rder?
According to the HTML5 spec, non-scoped <style>
elements can go basically anywhere in the <head>
.
It doesn't matter. As long as it's in the head, it can be before all the <meta>
tags, or after the <title>
and <script>
s.
In short: <style>
elements can be anywhere in the <head>
element.
The elements in the head tag can be placed in any order.
Any order, if memory serves. However, I've generally experienced the common practice to be after the meta data and title
I assume that it is valid in any order, but you can confirm using: W3C's validator: http://validator.w3.org/
As long as elements in the head tag doesn't rely on each other (for example when a script relies on another script being loaded first), the order doesn't matter.
The browser will be looking for the meta tag that contains the content type and encoding, before decoding the file, so it's good to have that early in the file.
精彩评论