Sub topic 2
Writing a Good Title
Assume you know basic HTML elements, attributes, and document structure. You should also know that browsers display pages and search engines interpret page information.
Write a good title
The <title> element names the document in the browser tab. Search engines often use it as the main link text in results. Write a clear, unique title that identifies the page and its purpose.
<head>
<meta charset="utf-8">
<title>Trail Running Shoes | Example Store</title>
</head>Keep the important words near the beginning. Avoid repeating keywords or using the same title on every page. The visible <h1> heading and the <title> usually describe the same page, but they serve different places and audiences.
Why mobile browsers need the viewport meta tag
A viewport is the area where a browser displays a page. Older mobile browsers used a wide virtual viewport so desktop pages would fit. Without a viewport declaration, a responsive layout may appear zoomed out.
<meta name="viewport" content="width=device-width, initial-scale=1">width=device-width matches the layout width to the device screen. initial-scale=1 sets the starting zoom to 100 percent.
Viewport values and what not to disable
Use the standard values unless you have a specific, tested reason to change them.
| Setting | Purpose |
|---|---|
| `width=device-width` | Uses the device's available width |
| `initial-scale=1` | Sets the initial zoom |
| `user-scalable=no` | Prevents user zooming |
Do not use user-scalable=no, maximum-scale=1, or similar restrictions. They can prevent people with low vision from enlarging content. Responsive CSS should handle layout changes; it should not remove a user's ability to zoom.
Meta description and search snippets
A meta description summarizes the page for search engines and link previews:
<meta name="description" content="Compare lightweight trail running shoes by grip, cushioning, and weight.">Write a specific description that matches the page. Search engines may display it in a result snippet, but they can replace it with page text. It is a helpful hint, not a guaranteed ranking factor or exact snippet.
Exercise
Which viewport declaration gives a responsive page a device-width layout without blocking zoom?
Show answer
Use <meta name="viewport" content="width=device-width, initial-scale=1"> and omit zoom restrictions.