HTML Coding Convention

You should follow some convention while using HTML:

Use a Consistent CSS

A user must use consistent style while writing HTML. It makes the code simpler and more understandable for people.

Your code must be small, clean and well-formed.

Use Correct Document Type

You should declare document type at the starting of your code.

For example:

You can also use to maintain your lower case practice.

Use Lower Case Element Names

HTML5 facilitates you to use upper case and lower case letters in element name. But it is good practice to use only lower case. Because:

  • Mixing lower case and upper case letters in elements is not a good idea.
  • Lowercase looks neat and clean.
  • Lower case is easy to write.
  • Developers mainly use lower case letters.

Example:

Bad practice:

This is codebridgeplus.com

Note: This example will run but it is not a good practice to write elements in uppercase letters.

Very Bad practice:

This is a codebridgeplus.com

Good practice:

This is codebridgeplus.com.

Close all HTML Elements

In HTML5, it is not required to close all HTML tags. But, it is recommended to close tags.

Bad practice:

This is codebridgeplus.com

Good practice:

This is codebridgeplus.com

Close empty HTML Elements

In HTML5, it is not mandatory to close empty HTML tags. You can close it or let it be unclosed.

Good practice:

 “utf-8”>

Don’t Omitand

HTML5 facilitates you to omit and tag. You can exclude both tags and the program will work well enough.

Example:

Page Title

This is codebridgeplus.com

Welcome to codebridgeplus.com

We recommend you to not to omit and tag because is a root element and specifies the page language.

Syntax:

“en-US”>

Example:

“en-US”>
Page Title

This is a heading

This is a paragraph.