Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Meta tag syntax

Status
Not open for further replies.

cgilover

Programmer
Oct 8, 2004
32
0
0
US
I am writing another script to help with SEO and I need to know every possible syntax-correct way to make a meta tag.

Below is what I have so far. don't worry about doing mixed up quotes (ie: name='name"...).

Can you think of any more?

Code:
<meta name = "name" content = "content" \>   
<meta name = "name" content = "content"> 
<meta name = 'name' content = 'content' \>  
<meta name = 'name' content = 'content'> 
<meta http-equiv = "name" content = "content" \>   
<meta http-equiv = "name" content = "content">  
<meta content = "content" name = "name" \>   
<meta content = "content" name = "name">   
<meta content = 'content' name = 'name' \>
<meta content = 'content' name = 'name' \>
 
You should be able to work it out from the Spec , or from the DTDs.

Basically you must have a [tt]content[/tt] attribute, you should have either a [tt]name[/tt] or a [tt]http-equiv[/tt] attribute, you may have any or all of [tt]lang[/tt], [tt]dir[/tt], [tt]id[/tt] or [tt]scheme[/tt]. Attribute names must be lower case in XHTML, they aren't case-sensitive in HTML. Values may be enclosed in "" or '' (in HTML single word values don't need to be quoted at all). They may be stated in any order.

In HTML, the meta attribute must not be closed, it should be like this:
Code:
<meta name="something" content="something else">
In XHTML all elements must be closed, so it needs to be like one of these:
Code:
<meta name="something" content="something else"/>
<meta name="something" content="something else"></meta>
A compromise, which is valid XHTML and tolerated as HTML is this:
Code:
<meta name="something" content="something else" />

Combining that information, you should be able to come up with a few hundred different tag layouts in XHTML, and a few thousand in HTML. What any of the above has to do with SEO escapes me.

-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd
 
just going to agree with Chris. Especially on this
ChrisHunt said:
What any of the above has to do with SEO escapes me.


Chris.

Indifference will be the downfall of mankind, but who cares?
A website that proves the cobblers kids adage.
Nightclub counting systems

So long, and thanks for all the fish.
 
I love how most people believe meta tags are dead and I find it very silly. Meta tags are still important today even though they're not used the same way they used to.

So is this still related to SEO? Of course it is. And there are still thousands of meta engines out there which still use them anyway.
 
Yes, I was more wondering why you were concerned over the syntax. The order of the attributes doesn't matter, double quote vs single quotes doesn't matter, name and http-equiv are interchangeable for many of the meta tags (if not all) so there is only the required closing tag for XHTML to be even concerned about.
And the syntax is really nothing to do with SEO but all to do with valid HTML.

Chris.

Indifference will be the downfall of mankind, but who cares?
A website that proves the cobblers kids adage.
Nightclub counting systems

So long, and thanks for all the fish.
 
name and http-equiv are interchangeable for many of the meta tags
That's not true. [tt]http-equiv[/tt] means "treat the following as if it had been passed in the http header". Typical values are "Content-type", "Expires" and "Refresh". This would be ignored:
Code:
<meta name="Content-type" content="text/html; charset=ISO-8859-1" />
The [tt]name[/tt] attribute is used to identify information about the page. You can put anything you like in there, but search engines look for particular values. Engines would probably ignore this:
Code:
<meta http-equiv="keywords" content="this, that, the other" />
But then they don't take much notice of keywords these days anyway.

-- Chris Hunt
Webmaster & Tragedian
Extra Connections Ltd
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top