XHTML Tutorial - Chapter 3: Head and Body

OK, so, if you read the previous chapter, you were briefly acquainted with the HTML tag <apple>. Sadly, the two of you will never meet again, as it was just something I made up for the example. Instead the time has now come to start looking at some actual existing HTML tags instead.

Besides the mandatory <html> which you have already come across, there are two more tags that would be considered mandatory in an HTML document, and those are the <head> and the <body> tags. The head is used to hold a bunch of general attributes that sum up the contents of the page, and the body of the page contains the actual content itself.

Right now, we're not going to worry too much about those general document settings in the head area, since they're mostly used to optimize the page for search engines and such indexing services. We will however take a brief look at one of them, and that is the <title> tag. The title tag sets the title of the page, you know, the one that shows up in the top bar of your web browser.

Let's throw head, body and title together and see how it comes out:

    <title> My web page </title>
    Just some random content.

Eventually I might include some screenshots here to show you the result of every example, but for the time being I'll leave it to you to paste any example code snippet you're curious about into a text file of your own and open it with your browser. The example above will set the title bar to "My web page" and display "Just some random content." onto an otherwise empty page.

You have probably noticed by now the indentation of the tags as well - how I tend to space certain tags out further to the right than others? This is a way of making it easier to see what's contained "inside" another element, and the relationship between two elements in this way is usually referred to as parent and child. The "title" is a child of the parent tag "head", and "head" would be the child element of the main parent tag "html".

When I say "element" above I'm referring to the unit that is formed by both tags and the content inbetween. You could also call it an "object".

< Previous: Introduction

robert@eagleowl.se     +46 (0)26-16 13 61     www.eagleowl.se
©2021 EagleOwl