HTML <title> Tag

The <title> tag is used to specify the page title. Page titles are not so important for users, but they are very important for SEO (Search Engine Optimization). This tag is placed in the <head> section of the page.

HTML Tag

Example

#

A <title> element in a <head> section.

<html>
 <head>
  <title>Introduction to Programming</a>
 </head>
 <body>
   <!-- content here -->
 </body>
</html>

Using <title>

The <title> tag defines the page title. A page can only have a single <title> element.

Text inside the <title> element will be shown on the browser tab.

The <title> text will also be used when the page is added as a favorite.

Search engines use the <title> as the title of search results.

The purpose of <title>

To the average user the page title is not important. Its value displays in the browser tab which often is too small to show the full title. Only when hovering over the tab is the text visible in a tooltip. In general, H1 tags are far more relevant to the user.

In contrast, the title tag is extremely important for SEO (Search Engine Optimization) purposes. Google's search result displays the page title prominently as a link to your site. The page title is also used for indexing. Therefore, with a public facing site, pay great attention to the page title and ensure it represents the page content well.


SEO Example

Below are Google's search results for 'history of C#'. As you can see, the title is used as a direct link to the page. Google also uses the title as part of their algorithm to find a match with the search string that was entered.



Attributes for <title>

The <title> element itself has no attributes, but it does accept global attributes.
They are rarely, if ever, used.


Did you know?

Did you know?

Changing the page title with JavaScript

Changing the page title can be done with the following line of JavaScript.

document.title = 'New page title';

Tip: Some search engines don't interpret JavaScript code, therefore this method is not recommended in setting page titles.


Page Tags

The <title> tag is part of a group of tags that define the structure of a web page. This group is referred to as the Page tag group. Together, these tags allow you to create solid, well-structured web pages.

Here is the complete list.

Element Description
<!DOCTYPE> Must appear on the first line of a page. Specifies the HTML version
<html> Defines the root container for an HTML document
<head> Creates a head container that holds page-level metadata elements
<meta> Provides metadata about a web page
<link> Defines a link to an external source, such as a style sheet
<base> Sets the base URL for all relative URLs on a page
<script> Adds JavaScript to a page. Either client- or server-side
<style> Adds CSS style elements to a page
<title> Specifies the page title that displays in the browser's tab
<body> Specifies a container for the content of the page, with text, links, images, etc.

Browser support

Here is when <title> support started for each browser:

Chrome
1.0 Sep 2008
Firefox
1.0 Sep 2002
IE/Edge
1.0 Aug 1995
Opera
1.0 Jan 2006
Safari
1.0 Jan 2003

You may also like

Guides