Smal SEO Tool

HTML Style Guide

A consistent style creates clean, readable, and maintainable code. It also makes collaboration easier.

Use Lowercase for Tags and Attributes

Writing tag names and attribute names in lowercase is a widely accepted convention. While browsers will render uppercase tags, lowercase is standard and required for stricter document types like XHTML.

Good: <p>This is a paragraph.</p>

Bad: <P>This is a paragraph.</P>

Always Close HTML Elements

In modern HTML, you are not required to close all elements (like the <p> element). However, it is a strong recommendation to always include the closing tag. It makes the code cleaner and avoids unexpected errors in nesting.

Always Quote Attribute Values

Attribute values should always be enclosed in quotes. Double quotes are the most common, but single quotes are also allowed.

Good:

html
<p class="note">

Bad (Avoid):

html
<p class=note>

Use Indentation for Readability

Always use indentation to show the structure of your HTML document. Indenting nested elements makes the code much easier for humans to read and understand.

Indentation Example

Bad (Hard to read):

html
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>

Good (Easy to read):

html
<body>
    <h1>This is a heading</h1>
    <p>This is a paragraph.</p>
</body>

Test Yourself with an Exercise

Which is the recommended way to write tag names in HTML?