'What does the HTML <title> tag do?
I have just started learning HTML from W3Schools. I tried my first code and even if I change my title in my HTML code, it doesn’t make any difference. The resulting page remains the same.
<!DOCTYPE html>
<html>
<head>
<title>HTML</title>
</head>
<body>
<h1>HTML lesson 1</h1>
<p>My name is John</p>
</body>
</html>
What difference does it make if I use a random title? what effect will it have?
Solution 1:[1]
Most browsers put the <title>
in the title of the window or tab.
Solution 2:[2]
Look on w3.org at http://www.w3.org/Provider/Style/TITLE.html
It is well explained. Quoting it:
(bolding mine)
The title of a document is specified by the TITLE element. The TITLE element should occur in the HEAD of the document.
There may only be one title in any document. It should identify the content of the document in a fairly wide context.
The title is not part of the text of the document, but is a property of the whole document. It may not contain anchors, paragraph marks, or highlighting. The title may be used to identify the node in a history list, to label the window displaying the node, etc. It is not normally displayed in the text of a document itself. Contrast titles with headings . The title should ideally be less than 64 characters in length. That is, many applications will display document titles in window titles, menus, etc where there is only limited room. Whilst there is no limit on the length of a title (as it may be automatically generated from other data), information providers are warned that it may be truncated if long.
Solution 3:[3]
The reason why you don't see any changes in the browser's window title is because the "try it" examples in W3Schools are run in elements called "IFRAME" (you'll learn about them later). The window's title changes according to the tag when the HTML is displayed in that window (not in any nested IFRAME). In W3Schools you are probably reading "Tryit Editor v2.5" instead of the title specified in the HTML because the "main" HTML's title tag contains that string. Try right-clicking anywhere in the page and click "View Source" and check the tag's content.
Solution 4:[4]
As explained in previous answers, the title tag is the title of a document and will usually show up on the tab/window of whatever browser is displaying it.
More noteworthy in these days, though, is that the title tag is what many search engines use to display your pages in their search results. Furthermore, the words used in the title of a page are crucial to optimize your position in the search engine rankings (read more about search engine optimization (SEO) online).
Here's an only slightly validated page for more information: Title Tag
Solution 5:[5]
Title tags are one of the most important elements of on-page SEO. They are used by browser tab titles, saved bookmark descriptions, search engine result pages (SERP) and increasingly by social media sites when linking to web pages.
Search engine results page (SERP) displaying the title in a large font.
A missing <title> element from a page will result in an invalid HTML page. You can use Google’s HTML Improvements tool to identify any missing title tags on your website.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | Barmar |
Solution 2 | Michael Durrant |
Solution 3 | Claudix |
Solution 4 | Peter Mortensen |
Solution 5 | Peter Mortensen |