Home › HTML Tutorial › HTML best practices
HTML best practices
Habits that keep pages clean and accessible.
Always declare <!DOCTYPE html> and lang, write lowercase tags, give images alt text, use one h1, and close every element.
Commands in this lesson
alt
Definition: Text description of an image, shown if it fails to load and read by screen readers.
Syntax:
<img src="file" alt="text">
Example:
<img src="x.png" alt="A sleeping cat">h1
Definition: Defines the main heading of the page. Use one per page.
Syntax:
<h1>Heading text</h1>
Example:
<h1>Welcome</h1>Example code
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Good page</title>
</head>
<body>
<h1>A well-formed page</h1>
</body>
</html>