Meta Tags, Nesting and the XMLNS Attribute

Today I wanted to continue on with proper document format in HTML. If you recall in my last lesson, I introduced doctypes and what they are used for. Now I want to introduce you to meta tags, nesting and the xmlns attribute.

Meta Tag

Although the doctype tag says what type of language you are using to code the document with, the meta tag says what the document itself is all about. You can put all kinds of attributes in with the meta tag. The following are some examples:

<head>
 <meta name="description" content="My Beginning Web" />
 <meta name="keywords" content="web design,HTML,CSS,XML" />
 <meta name="author" content="Justin May" />
 <meta http-equiv="Content-Type" content="text/html;charset=UTF-8" />
 <title>My Beginning Web</title>
</head>

Notice that the meta tag data always is nested in the head tag. You can also see some extra attributes and their respective designations. For example the first meta tag, simply put, describes what our web page is about. The second tag tells us what the key subjects are of our web page, next is the author/creator of the page and what we are using to make the page with (straight text/html code) and type of character set we are using; UTF-8 being the most common and recommended one.

Meta tags are not always necessary, however it can come in handy. For example, maybe you're talking about HTML and of course it's related to web design, but you don't specifically use that word in your content. Then you can put it in the keyword attribute of the meta tag. The only time the meta tag is required is if you are using the XHTML strict doctype. In that case you specifically need to use the http-equiv attribute as shown above.

XMLNS Attribute

Also required for the XHTML doctype is the xmlns attribute. It looks like this and is part of the html opening tag:

<html xmlns="http://www.w3.org/1999/xhtml">

This attribute basically says nothing more than the doctype already does, but it's required nonetheless.

Nesting

Backing up a second here, you may have seen that nesting term I mentioned and wondered what that meant. Just like how all tags (with a few exceptions) must have opening and closing tags, they also have to be nested. If you see the example of the meta tag above, it's opening and closing are held within the opening and closing of the head tag. For instance:

This is not allowed...

<head>
<title>
</head>
</title>

This is the right way...

<head>
<title>
</title>
</head>

Next up comes a little more on basic HTML and a VERY bare-bones web page.

<<--  Back ... Next  -->>


Leave a Reply

Your email address will not be published. Required fields are marked *

*

6 visitors online now
0 guests, 6 bots, 0 members
Max visitors today: 8 at 06:10 am HST
This month: 13 at 02-01-2012 09:43 pm HST
This year: 13 at 02-01-2012 09:43 pm HST
All time: 72 at 03-07-2010 11:16 am HST