Building the template: Adding a head
section
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR /xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> <head> </head> </html>
Notice that the head
element requires no attributes but simply has the opening and closing tags. This identifies the head
region. Table shows some of the various elements that you can place within the head
of your document.
Elements in the Head
Portion of the Document
Element | What It Does |
---|---|
|
This element enables you to title your document. This title will then appear in the title bar of your browser. The |
|
The |
|
This element enables you to insert scripts directly into your document or, as is the preference, link from the page to the script you'd like to use. It is used as needed. |
|
The |
|
The |
The title Element in Detail
The title
element is the only required element within the head
element. This element displays any text within it in the browser bar along with the browser's name at the end of the text.
The title element text will appear in the browser's title bar.
Aside from the fact that you have to have the title
element in place, writing good titles is a first-line technique that accomplishes three things:
-
Provides a title for the page,
-
Offers users orientation that is, it helps them know where they are on the Web and within the site itself
-
Provides additional information about the site page
Writing effective titles means addressing these three concerns. A good title example appears in Example 1-5.
Title example with site name and location for user orientation
<title>HTML & CSS</title>
Note that the page is titled using the site name, the site section, and the subsection, providing useful information for the visitor.
An ineffective example can be seen in Example 1-6.
Title example with site name and location for user orientation
<title>Read All Tutorials!</title>
Here, there's no information that helps us. So while the technical requirement of having a title is fulfilled, the practical needs are not.
Although you cannot use HTML inside a title, you can use character entities, as you can see in above example, where I used the entity &
to create the &
symbol. For more information on available character entities, see XHTML References