HTML · HTML Tutorial · Lesson 33
HTML Style Guide
Write clean, consistent HTML.
A consistent, clean and tidy HTML code makes it easier for others to read and understand your code.
- Always declare the document type:
<!DOCTYPE html> - Use lowercase element and attribute names
- Close all HTML elements
- Always quote attribute values
- Always specify
alt,widthandheightfor images - Do not add spaces around equal signs:
class="x" - Always add
<html>,<head>,<body>and a<title> - Add the
langattribute and thecharsetmeta tag - Use lowercase file names
Good example
Example
<!DOCTYPE html>
<html lang="en-us">
<head>
<meta charset="UTF-8">
<title>Page Title</title>
</head>
<body>
<img src="https://picsum.photos/id/1015/128/128" alt="Lake" width="128" height="128">
</body>
</html>
Keep reading “HTML Style Guide”
Sign up to read the full lesson, try every example in the live editor, and take the 5-question quiz.