A Document That Is Ready for Mobile
<!doctype html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>My first page</title>
</head>
<body>
<h1>Hello, web.</h1>
</body>
</html>
Use a descriptive title and set the language to match the page. The viewport declaration helps the layout use the device width.
Links Navigate; Buttons Perform Actions
<a href="/resources">Explore resources</a>
<button type="button">Show a hint</button>
Choose the native element for the job. A button needs JavaScript when its action changes the page.
Give a Useful Image a Useful Description
<img src="network-diagram.png"
alt="A browser sends a request to a web server"
width="640" height="360">
Describe the information the image contributes. Use an empty alt attribute for a purely decorative image.
Connect a Form Label to Its Input
<label for="email">Email address</label>
<input id="email" name="email" type="email" autocomplete="email">
The label's for value matches the input id. Placeholder text is not a replacement for a visible label.
Create a Readable Page Structure
<header>Hacktronian</header>
<nav aria-label="Main">...</nav>
<main>
<h1>Learning resources</h1>
<section aria-labelledby="web-heading">
<h2 id="web-heading">Web development</h2>
</section>
</main>
<footer>...</footer>
Use headings to describe the content hierarchy. Landmarks help visitors move between the main parts of a page.