How to Set Page Title in HTML: Simple Guide
To set the page title in HTML, use the
<title> tag inside the <head> section of your HTML document. The text inside <title> appears as the browser tab name and helps users identify the page.Syntax
The page title is set using the <title> tag placed inside the <head> section of your HTML document.
<head>: Contains metadata and settings for the page.<title>: Defines the text shown on the browser tab.
html
<head> <title>Your Page Title Here</title> </head>
Example
This example shows a complete HTML page with a page title set to "Welcome to My Site". The title appears on the browser tab when you open the page.
html
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Welcome to My Site</title> </head> <body> <h1>Hello, world!</h1> <p>This page has a title shown in the browser tab.</p> </body> </html>
Output
Browser tab shows: Welcome to My Site
Page content: Hello, world! and a paragraph
Common Pitfalls
Some common mistakes when setting the page title include:
- Placing the
<title>tag outside the<head>section, which browsers may ignore. - Leaving the
<title>tag empty, resulting in no visible title. - Using multiple
<title>tags, which can confuse browsers.
Always use exactly one <title> tag inside <head> with meaningful text.
html
<!-- Wrong: title outside head -->
<html>
<title>Wrong Title</title>
<body>Content</body>
</html>
<!-- Right: title inside head -->
<html>
<head>
<title>Correct Title</title>
</head>
<body>Content</body>
</html>Quick Reference
Remember these tips for setting page titles:
- Use one
<title>tag inside<head>. - Keep the title short but descriptive (50-60 characters ideal).
- The title helps with SEO and user navigation.
- Always include
langandcharsetin your HTML for best practice.
Key Takeaways
Set the page title using the tag inside the section.
The title text appears on the browser tab and helps users identify the page.
Use exactly one tag with meaningful text for best results.
Avoid placing the tag outside the section.
Keep the title concise and descriptive for better user experience and SEO.