does it matter at all what order the <link>
or <script>
or <meta>
tags are in in the <head></head>
?
(daft question but one of those things i've never given any thought to until now.)
Within a web page, some HTML tags are required for the page to be displayed correctly. These tags are <html> , <head> , <title> and <body> . The <html> tags must begin and end the document and the <head> tags must appear before the <body> tags. Also, the <title> tags must be within the <head> tags.
Hence, Option 1 is correct. The HTML <title> tag is used for indicating the title of the HTML document. The body title is placed between the <head> and the </head> tags. HTML document title is visible via the browser's title bar.
HTML <head> Tag. The <head> tag in HTML is used to define the head portion of the document which contains information related to the document.
The head tag is an element in HTML files that can contain metadata (data about data) and script calls. The head tag is placed between the opening <HTML> and <body> tags at the beginning of the HTML file. The metadata in the head tag is not displayed, but the information is used by browsers and by search engines.
Optimization
According to the folks over at Yahoo! you should put CSS at the top and scripts at the bottom because scripts block parallel downloads. But that is mostly a matter of optimization and is not critical for the page actually working. Joeri Sebrechts pointed out that Cuzillion is a great way to test this and see the speed improvement for yourself.
Multiple Stylesheets
If you are linking multiple stylesheets, the order they are linked may affect how your pages are styled depending on the specificity of your selectors. In other words, if you have two stylesheets that define the same selector in two different ways, the latter will take precedence. For example:
Stylesheet 1:
h1 { color: #f00; }
Stylesheet 2:
h1 { color: #00f; }
In this example, h1
elements will have the color #00f
because it was defined last with the same specificity:
Multiple Scripts
If you are using multiple scripts, the order they are used may be important if one of the scripts depends on something in another script. In this case, if the scripts are linked in the wrong order, some of your scripts may throw errors or not work as expected. This, however, is highly dependent on what scripts you are using.
The accepted answer is kind of wrong, depending on the encoding of the document. If no encoding is sent by in the HTTP header, the browser has to determine the encoding from the document itself.
If the document uses a <meta http-equiv="Content-Type" …
declaration to declare its encoding, then any ASCII-valued character (character code < 128) occurring before this statement must be an ASCII value, as per HTML 4 spec. Therefore, it's important that this meta
declaration occurs before any other element that may contain non-ASCII characters.
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