3.2    <title>: Heading of the HTML Page

In every HTML document, you should use a title that gets displayed in the header of the web browser. You can write such a title between the <title> and </title> tags within the head element. If no title is used, what appears here depends on the web browser. Often, you’ll then find a title such as Untitled Document or Untitled, for example. You can use only one title element in total for an HTML document.

In Figure 3.2, you can see the title element used in the following example being rendered:

<!doctype html>
<html lang="en">
<head>
<title>The Heading of the HTML Page</title>
<meta charset="UTF-8">
</head>
...

Listing 3.1     /examples/chapter003/3_2/index.html

The Title Is Usually Displayed in the Header Bar and/or Tab of the Web Browser

Figure 3.2     The Title Is Usually Displayed in the Header Bar and/or Tab of the Web Browser

Invalid HTML

If you omit the title element, an error message displays when you check the validity of the HTML code (e.g., at http://validator.w3.org). This means a title element must exist in every HTML document for it to be valid HTML. In addition, no other HTML elements are allowed in between <title> and </title>.

Besides the display in the header bar or tabs of the web browser, there are two much more important reasons to use the title element: first, this title is used as a name suggestion by the web browser when setting bookmarks (favorites), and second—and even more importantly—the title has a high significance with the search engines on the web. As you can see in Figure 3.3, the title is often the first thing your visitors see when your website is listed in a search engine. You can create such a search result yourself for testing purposes with a SERP snippet generator (e.g., www.serpsimulator.com). It often occurs that the title is also a clickable link to your website. In addition, the title is important for the hit list and for the rank of the page in the hit index of the search engine.

For Search Engines, the Importance of the <title> Element Shouldn’t Be Ignored

Figure 3.3     For Search Engines, the Importance of the <title> Element Shouldn’t Be Ignored

Titles for Search Engines

The topic of search engine optimization (SEO) can’t be described in a few paragraphs and encompasses many subareas. It isn’t possible either to make a general statement about when exactly something is “optimal.” Even the SEO experts often disagree on this. Nevertheless, it’s safe to say that the title is very important in search engines. It’s often recommended to use one or two keywords, followed by a slogan and perhaps the web address (e.g., Keyword 1, Keyword 2—A short heading—www.domain.com). In practice, for example, the following title would make sense: Smartphones, Cell Phones—buy cheap smartphones—www.domain.com. In addition, the title shouldn’t be too long, otherwise it will be truncated when listed in the search engine. The common recommendation ranges between 60 and 70 characters.