Some conventions must be followed while using HTML:
Use a Consistent CSS:
A consistent style must be used while writing an HTML code to make a code simple and easy to understand. A small, clean, and well-formed code is always recommended.
Use Correct Document Type:
The document type should be declared at the start of an HTML code. The <!DOCTYPE html> tag can also be used to maintain the lowercase practice.
Example:
<!DOCTYPE html>
Use Lower Case Element Names:
In HTML5 it is recommended to use only the lowercase letters in element names to avoid mixing the lowercase and uppercase letters in elements. The lowercase also provides a neat and clean look along with being easy to write.
Example:
Very Bad practice:
<!DOCTYPE html> <html> <body> <ARTICLE> <p>Hello World!!</p> </article> </body> </html>
Bad practice:
<!DOCTYPE html> <html> <body> <ARTICLE> <p>Hello World!!</p> </ARTICLE> </body> </html>
Good practice:
<!DOCTYPE html> <html> <body> <article> <p>Hello World!!</p> </article> </body> </html>
Close all HTML Elements:
Though it is not mandatory but is recommended to close all tags in HTML 5.
Example:
Bad practice:
<!DOCTYPE html> <html> <body> <ARTICLE> <p>Hello World!! </ARTICLE> </body> </html>
Good practice:
<!DOCTYPE html> <html> <body> <article> <p>Hello World!!</p> </article> </body> </html>
Close empty HTML Elements:
Though it is not mandatory but is recommended to close empty tags in HTML 5.
Example:
Good practice:
<meta charset="utf-8">
Don’t Omit <html> and <body> elements:
Though it is not mandatory but is recommended to use both the <html> and <body> elements in HTML 5. The <html> tag is often used to specify the page language.
Example:
Bad practice:
<!DOCTYPE html> <ARTICLE> <p>Hello World!! </ARTICLE>
Good practice:
<!DOCTYPE html> <html> <body> <article> <p>Hello World!!</p> </article> </body> </html>