Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

HTML Forum


You are currently viewing our HTML Forum as a guest. Please register to participate.
Login



Post a Project »

Find a Professional HTML Freelancer!

Find a Freelancer to help you with your HTML projects

FREE Outsourcing eBook!

Reply
What is the correct ordering of tags inside your <head>
Old 07-13-2009, 09:51 PM What is the correct ordering of tags inside your <head>
TWD
TWD's Avatar
King Spam Talker

Posts: 1,112
Trades: 0
I'd like some opinions about what people think is best practice for arranging tags inside the HEAD section of the web page.

I think everyone would agree that this should come first


Quote:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en">
Next is my question about how things should be ordered between the
<head> and </head>.

Lets assume for the sake of simplicity that there is NO inline CSS or Javascript. Everything is external referenced.

What order would you place:

<title>
<meta tags>
<CSS links>
<JavaScript links>

I can't think what other <head> elements might be relevant but feel free to add them to your answer if you do.

Last edited by TWD; 07-13-2009 at 09:52 PM..
TWD is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 07-13-2009, 10:24 PM Re: What is the correct ordering of tags inside your <head>
konetch's Avatar
Ultra Talker

Posts: 258
Trades: 0
I always use your method just because it was the order I learned them in. When I use a script to build my pages though, it doesn't always come in that order.

I normally include a base href too
__________________
Alex
konetch is offline
Reply With Quote
View Public Profile
 
Old 07-13-2009, 11:10 PM Re: What is the correct ordering of tags inside your <head>
TWD
TWD's Avatar
King Spam Talker

Posts: 1,112
Trades: 0
Quote:
Originally Posted by konetch View Post

I normally include a base href too
Thanks. I didn't know about the tag.
I can see it would have its uses.

What I'm kind of interested in knowing is what is
"best practice" for arranging these tags.

I've read on Google Webmaster Tools that <script> links should always
follow CSS links.
I'm not sure about the <meta> tags and <title> tag though.
I read somewhere that your <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
should come just after the Doc Type.
But I'm not sure.
TWD is offline
Reply With Quote
View Public Profile
 
Old 07-14-2009, 05:57 PM Re: What is the correct ordering of tags inside your <head>
angele803's Avatar
Perfectly Imperfect

Posts: 1,774
Name: Stephanie
Location: Oklahoma
Trades: 2
The order you posted is IMHO correct...with the exception of the meta tags. I think you are correct in your last post about the meta tags though. From what I have read, the "content type" meta tag should come just after your opening "head" tag. The reason is so that the browser knows what character set your title should use. So, I think it should look like this:

<"content-type" meta tag>
<title>
<other meta tags>
<CSS links>
<JavaScript links>
__________________

Please login or register to view this content. Registration is FREE

Last edited by angele803; 07-14-2009 at 06:01 PM..
angele803 is offline
Reply With Quote
View Public Profile
 
Old 07-14-2009, 06:33 PM Re: What is the correct ordering of tags inside your <head>
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,519
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
It really doesn't matter in the slightest. Just as long as the ContentType directive is before the opening <body> (as it only affects the visual elements) nothing will be affected by the head element order.

One exception would be if any javascripts run as the script loads (not by a body onload event) that reference the CSS styles, the stylesheets must be loaded first.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 07-14-2009, 07:45 PM Re: What is the correct ordering of tags inside your <head>
TWD
TWD's Avatar
King Spam Talker

Posts: 1,112
Trades: 0
Quote:
Originally Posted by chrishirst View Post
It really doesn't matter in the slightest. Just as long as the ContentType directive is before the opening <body> (as it only affects the visual elements) nothing will be affected by the head element order.

One exception would be if any javascripts run as the script loads (not by a body onload event) that reference the CSS styles, the stylesheets must be loaded first.
Thats about what I thought.

Now to add an extra element of difficulty:
Suppose we have an inline block of CSS and an inline block of JavaScript.
Where should they be placed in relation to each other and in relation to the other <head> tags for best practice?

I know you shouldn't really be using inline scripts but lets assume for the sake of the argument that it's required.
What then?
TWD is offline
Reply With Quote
View Public Profile
 
Old 07-15-2009, 04:16 AM Re: What is the correct ordering of tags inside your <head>
Average Talker

Posts: 20
Name: Qasim dar
Trades: 0
the tags you already know are enough,
i think the head section should not contain any unnecesry tags like some people add lots of meta tags, i like and use only the meta descrioption and mets keywords.
darfun is offline
Reply With Quote
View Public Profile Visit darfun's homepage!
 
Old 07-15-2009, 05:57 AM Re: What is the correct ordering of tags inside your <head>
TWD
TWD's Avatar
King Spam Talker

Posts: 1,112
Trades: 0
Quote:
Originally Posted by darfun View Post
the tags you already know are enough,
i think the head section should not contain any unnecesry tags like some people add lots of meta tags, i like and use only the meta descrioption and mets keywords.
Errors found while checking this document as HTML 4.0 Transitional!

Result: 84 Errors, 10 warning(s)

Need we say anymore.
TWD is offline
Reply With Quote
View Public Profile
 
Old 07-16-2009, 03:26 PM Re: What is the correct ordering of tags inside your <head>
chrishirst's Avatar
Missing! presumed drunk.

Posts: 41,519
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
Quote:
Originally Posted by TWD View Post
Thats about what I thought.

Now to add an extra element of difficulty:
Suppose we have an inline block of CSS and an inline block of JavaScript.
Where should they be placed in relation to each other and in relation to the other <head> tags for best practice?

I know you shouldn't really be using inline scripts but lets assume for the sake of the argument that it's required.
What then?
Just the same, there is no "right" or "wrong" order. Same as "shouldn't use inline/inpage scripts/styles". It really doesn't matter.
If the style or script only applies to one page, leave it in the page. That way it cannot intefere with any global scripts/styles but can be used to override global scripts/styles.
Same with inlne items, if it only applies to one element in the entire site, set it as inline on that element.
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
A foolish consistency is the hobgoblin of little minds
Thought for today:- I SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to What is the correct ordering of tags inside your <head>
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.35035 seconds with 12 queries