How to use title tag in HTML Page?


Titles are used to grab attention and predict the content of the web page.

The <title> tag defines the title of the content on the web page. It is required in an HTML document to display a title for the page in search-engine results.

The title of the content should be placed between the <title>…</title> tags. This title is used inside the head tag.

There should be one <title> element in an HTML document. If we write more than one title for the content the first title tag is considered as a title.

Syntax

Following is the syntax for the <title tag>.

<title> Title of the content </title>

Example

Following is the example program for the title of the web document.

<!DOCTYPE html> <html> <head> <title>HTML Articles</title> </head> <body> </body> </html>

Following is the output of the title tag, the title is displayed on the top of the browser window.

Example

Following is another example program for the title of the web document.

<!DOCTYPE html> <html> <head> <title>Look at the browser tab...</title> </head> </html>

Now let’s use two title tags in the HTML document.

Example

Following is the example program with two title tags.

<!DOCTYPE html> <html> <head> <title>HTML Articles</title> <title>HTML tutorial</title> </head> <body> </body> </html>

The first title tag of the HTML is displayed, and the second title tag gets ignored.

Updated on: 11-Nov-2022

545 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements