SitePoint Sponsor

User Tag List

Results 1 to 12 of 12

Thread: head tag order

  1. #1
    Beer Monster -Ox's Avatar
    Join Date
    Apr 2003
    Location
    sowth afreeka
    Posts
    374
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    head tag order

    Just out of interest is there any different between what order you add tags inside the <head> tag?

    example:

    HTML Code:
    <head>
    <title>[Title]</title>
    <meta http-equiv="Keywords" content="[Keywords]" />
    <meta http-equiv="Description" content="[Description]" />
    <script language="JavaScript" type="text/javascript" src="js/global.js"></script>
    <script language="JavaScript" type="text/javascript" src="js/venue.js"></script>
    <link rel="stylesheet" type="text/css" href="global.css">
    <style type="text/css" title="venue" media="all">
    @import url(css/venues.css); 
    </style>
    </head>
    the meta, javascript and CSS tags is there any relevance to what order you put then in Meta first then JS then CSS, or JS then CSS Then Meta etc..
    My postings are a natural product.
    The slight variations in spelling and grammar enhance its
    individual character and beauty and in no way are to be
    considered flaws or defects - http://www.guinnesspig.net

  2. #2
    Robert Wellock silver trophybronze trophy xhtmlcoder's Avatar
    Join Date
    Apr 2002
    Location
    A Maze of Twisty Little Passages
    Posts
    6,316
    Mentioned
    60 Post(s)
    Tagged
    0 Thread(s)
    Technically the character encoding - if defined via the <meta /> element should come first after the <head> tag: <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> even before the <title> element.

  3. #3
    SitePoint Member
    Join Date
    Dec 2003
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Taken from the website of W3C:

    There is no intended significance to the order of elements in the document head.
    I guess every person just has his or her own preference. However, I do think that the order you posted in the code tags is the preferred order for most people (at least it is the most used order if you ask me).

  4. #4
    Beer Monster -Ox's Avatar
    Join Date
    Apr 2003
    Location
    sowth afreeka
    Posts
    374
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Excellent, Thanks guys
    My postings are a natural product.
    The slight variations in spelling and grammar enhance its
    individual character and beauty and in no way are to be
    considered flaws or defects - http://www.guinnesspig.net

  5. #5
    Robert Wellock silver trophybronze trophy xhtmlcoder's Avatar
    Join Date
    Apr 2002
    Location
    A Maze of Twisty Little Passages
    Posts
    6,316
    Mentioned
    60 Post(s)
    Tagged
    0 Thread(s)
    You would assume there was no difference unless you actually read the HTML DTD EBNF grammar: http://www.w3.org/TR/REC-html40/sgml/dtd.html that states otherwise.

    Though apart from character encoding the rest should not matter.

  6. #6
    ☆★☆★ silver trophy vgarcia's Avatar
    Join Date
    Jan 2002
    Location
    in transition
    Posts
    21,235
    Mentioned
    1 Post(s)
    Tagged
    1 Thread(s)
    My typical order is:
    title
    meta
    links (stylesheets, index, first, last, next, etc.)
    script

  7. #7
    SitePoint Member
    Join Date
    Dec 2003
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I tried to find where it states that the character encoding should come first. I believe you, don't misunderstand me, but I just can't find it, or am I looking in the wrong place?

  8. #8
    Robert Wellock silver trophybronze trophy xhtmlcoder's Avatar
    Join Date
    Apr 2002
    Location
    A Maze of Twisty Little Passages
    Posts
    6,316
    Mentioned
    60 Post(s)
    Tagged
    0 Thread(s)
    Maybe I didn't reference the correct section since it has been a long time since I've used HTML but is to do with byte-order and UA processing.

    Hence why in XML the encoding will typically appear within the first line of the page; obviously you could set the server to pass encoding though believe me encoding should come first, if you use the markup method above.

    I used to think the <title> came first within the HTML <head> but apparently it doesn't.

  9. #9
    SitePoint Member
    Join Date
    Dec 2003
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Okay, thanks for the explanation. I will try and read the entire HTML DTD EBNF grammar in a few days, so I might come across it then. Thanks for the link.

  10. #10
    SitePoint Guru bronze trophy blufive's Avatar
    Join Date
    Mar 2002
    Location
    Manchester, UK
    Posts
    853
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Basically, I believe the quick-and-dirty-for-dorks-like-me explanation is:

    If the browser parser, upon reading the character set meta tag, finds that it's using the WRONG character type, it has to go back and start parsing the page all over again.

    For example, if the page is written in some language which doesn't use the Roman Alphabet, and the browser is using a default US/Western Europe encoding (or the other way round), then any content which has already been read (the <title>, for instance) could have been mangled into complete gibberish, because it was read in the wrong character encoding.

    Given how much stuff can end up in a header if you really go to town (CSS, javascript, etc.) making the browser go back and parse it all again is BAAAD, m'kay?
    Last edited by blufive; Dec 19, 2003 at 15:53.

  11. #11
    SitePoint Addict
    Join Date
    Dec 2002
    Posts
    386
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    there is one small thing which should be taken into account regarding the order in the head...
    http://www.bluerobot.com/web/css/fouc.asp

  12. #12
    SitePoint Member
    Join Date
    Dec 2003
    Posts
    12
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks blufive, it makes way more sense now.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •