demosthenes.info

A blog by Dudley Storey on , , , , , , and anything else that strikes his fancy.

featured articles

popular favourites

Nesting Tags

Tags are nested. Certain tags can only happen inside other tags: that is, between certain opening and closing tags. The order in which tags are opened and closed is vitally important, since using them in the wrong sequence will result in a page in disarray. Tags are closed in the reverse order to which they are opened. The rule is: “First in, last out”. That is, the tag that contains a nested series of tags is the last one to be closed. Another way of thinking about this is a series of matryoshka dolls, the Russian figurines which contain other figures inside themselves.

If the <html> tag starts our page immediately after the optional xml prolog and the doctype (which it does), it must therefore be the last one to be closed:

  1. <html>
  2. </html>

(Note that for the purposes of simple illustration the html tag is simplified: in a real page, it would have at least one attribute.)

Essentially, the <html> tag indicates that everything that follows it is, unsurprisingly, HTML. The opening <html> tag says “HTML starts here”. The closing </html> tag says “this is where the HTML code ends”.

HTML tattooThe rest of our code must be written between these opening and closing tags. There are two major sub-sections: the <head> and <body>.

  1. <html>
  2. <head></head>
  3. <body>
  4. </body>
  5. </html>

The body section contains what is going to appear on our page. The head section contains everything else: essentially, a description of our page, like the card catalog entry of a book. All of our page must be written within these two sections.

web developer guide

featured comment

by JoelB in Goodbye, JQuery Validation: HTML5 Form Errors With CSS3

what i'm reading

A Storm of Swords: A Song of Ice and Fire: Book Three
A Storm of Swords: A Song of Ice and Fire: Book Three

what i'm watching

Californication: The Third Season
Californication: The Third Season

what i'm playing

Mass Effect 3 Collector's Edition
Mass Effect 3 Collector's Edition

what i'm hearing

Dub FX
Dub FX

blogs

podcasts

no ads ever

This blog is free of advertising, and always will be.

creative commons licensed

The content of this blog is free to use in whatever way you wish under the Creative Commons license.