views:

1314

answers:

11

There are <meta> tags and other things you can place in the <head> of your HTML document. What <meta> tags etc. and best practices do you make use of in your HTML document to make it more accessible, searchable, optimized etc.

A: 

Title, meta tags for keywords, content-type (if not explicitly set by the web server), and any CSS to be applied to the page.

Declaring the CSS up front allows the browser to lay out the page more efficiently (see http://developer.yahoo.com/performance/rules.html#css_top).

Rob
+12  A: 

in my case,

  • Title (should do [Section Name - Site Name] for better SEO)
  • Meta tag for Content-type, description, and keywords
  • Link to stylesheet(s) (don't forget to specify the media="").
  • <script> tag that links to external javascript files.

All tags should follow the W3C's standard. The W3 site has a more technical and detailed section about the HTML <head> section.

edit: changed "W3's standard" to "W3C's standard"

andyk
"W3C" standard, not "W3" :)
kangax
Titling like [Section Name - Site Name] has nothing to do with SEO. The meta tag of "keywords" is almost useless.
kavoir.com
@andyk: what's media=""?
Marco Demajo
@Marco Demaio: to specify how a document is to be presented on different media: on the screen (you'll be using this mostly), on paper (print-version), with a speech synthesizer, with a braille device, etc. More info here: http://www.w3.org/TR/CSS2/media.html
andyk
+1  A: 

I didn't see this mentioned: the <base> tag, if specified, should be the first element in <head>. (The base URI of the document is assumed to be . before/if not specified.)

eyelidlessness
Um. Why the fuck did anyone downvote this? It's absolutely *correct*.
eyelidlessness
+3  A: 

You'll want to put SCRIPT elements at the end of the page before the close of the BODY element. See http://developer.yahoo.com/performance/rules.html#js_bottom for details.

mattoc
A: 

There is a related question here that may help add some light regarding the order of the tags.

Generally my pages include the following:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd"&gt;
<html>
<head>
    <title>...</title>
    <meta name="Description" ...>
    <meta name="Keywords" ...>
    <meta name="Copyright" ...>
    <meta name="Author" ...>
    <meta name="Language" ...>
    <style type="text/css" ...>

DocType is important to enforce strict rendering (No quirks mode) by the browser. You may want to use XHTML instead - as long as there is one there. I add Copyright and Author purely because I design and create the pages for other companies. Description is for SEO, and Language is for the browser (if it supports it).

I don't believe it makes to much of a difference which meta tag comes first, or whether the title should be above. What counts in most cases is that it exists on the page, and has the correct content.

Raithlin
+1  A: 

IMHO, the two most important child tags of <head> are <title> and the Content Type meta tag. Search engines actively look at <title>. Whereas the other meta tags are often ignored. As a multi-lingual web user - I cannot stress more the importance of adding the Content Type tag because without it, the browser needs to autodetect the character set of the web page and this operation is often flaky. The result ends up being that various characters are not rendered correctly to the user or sometimes none at all in the case of Japanese or Chinese.

Here is an snippet of some of the header code from a current project of mine:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"&gt;
<html xmlns="http://www.w3.org/1999/xhtml"&gt;
<head>
<title>Reports Blah Blah</title>
<meta name="ROBOTS" content="NOINDEX, NOFOLLOW" />
<meta http-equiv="content-type" content="application/xhtml+xml; charset=UTF-8" />
...
</head>
Elijah
Description is what appears against your listing in most search engines - without it, the search engines will usually guess at a snippet from within the page; It's best not to leave this up to chance. The Keywords META tag is also still used by certain search engines, though it carries only marginal weight. However, I also find it useful to populate, just as a reminder as to which keywords are most important, to which keywords need to be emphasised within the content of the page.
CJM
A: 
splattne
+1  A: 

As far as I'm aware, most search engines ignore any "keywords" or "description" meta tags, instead preferring to read the content of the document.

Getting the page title right however, is of extreme importance.

MarkR
They often ignore keywords, but not so much description.
kangax
Last time I checked keywords and description were completely ignored by Google. This may have changed but it seems unlikely. The basic problem was that they didn't add anything to the content on the page and were frequently used by spammers to load inaccurate keywords or description, thus reducing the accuracy of searches. So Google ignored them.
MarkR
kangax
A: 

In addition to the answers above I use the Dublin Core initiative meta-tags.

They are very useful for actual content/papers etc.

<meta name="DC.abstract" content="Document abstract" />
<meta name="DC.audience" content="Target audience" />

etc.

Ross
+2  A: 

Besides the usual doctype, title, etc, I will try and provide you with some things I have learnt and implemented that might be of assistance to you.

Firstly, remember that the title, for best user experience should have the most relevant sub section first. This is because it is usually displayed in the title bar/tab list/bookmark name. Consider this page title...

Stack Overflow - HTML head best practices

becomes Stack Overflow... (munched to save room in tab bar/bookmark list)

Now if you had 5 Stackoverflow tabs open (as I often do :P) then how would the user know which one is which?

Also note with CSS the cascading nature... So the order of these will matter. Same with Javascript, any dependencies on other external sites must be allowed for. I put mine in the head and havn't noticed a performance decrease. I put them there because it to me looks more tidy and logical. Though some other people will recommend putting the <script src=""> links in just before </body> so the browser won't temporarily stall... Just use whatever works best for your site.

Also a Meta tag of 'rating' with 'general' let's Net Filtering software know your site is safe for viewers of all ages (as long as it is, of course!)

I also use..

<link rel="start" href="/" title="Home" />

to let the browser know where the home of my site is. And for any browser prefetching systems, though I believe these are yet to be implemented by browsers without assistance of plugins.

Also consider the 'next' and 'prev' <link rel=""> if your pages are in a sequence of sorts.

alex
I like the next, previous, and start links. There's a toolbar for Firefox which makes use of them.
TRiG
+2  A: 

Do your users a favor and make their IE engine switch to Chrome one when Chrome Frame is installed :)

<meta http-equiv="X-UA-Compatible" content="chrome=1">
kangax