/    /  HTML5 User Manual

HTML5 User Manual

 

HTML Coding Convention:

 

Some convention while using HTML.

 

Use a Consistent CSS:

 

A user must use a consistent style(CSS) while writing HTML. It makes the code simpler and easier to understand for people.

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

 

Correct Document Type:

 

Document type at the starting of your code.

 

Syntax:

 

<!DOCTYPE html>

 

<!DOCTYPE html> to maintain your lower case practice.

 

Lower Case Element Names:

 

HTML5 provides to use upper case and lower case letters in element name. But the only lower case was good practice.

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

Example:

 

Bad practice:

 

<SECTION> 
<p>This is i2tutorials</p> 
</SECTION>

 

Very Bad practice:

 

<Section> 
<p>This is a i2tutorials</p> 
</SECTION>

 

Good practice:

 

<section> 
<p>This is i2tutorials.</p> 
</section>

 

Close all HTML Elements:

 

In HTML5, it is no use to close all HTML tags. But, it is recommended to close tags.

 

Bad practice:

 

<section> 
<p>This is i2tutorials
</section>

 

Good practice:

 

<section> 
<p>This is i2tutorials</p> 
</section>

 

Close empty HTML Elements:

 

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

 

Good practice:

 

<meta charset="utf-8">

 

Don’t Omit <html> and <body>:

 

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

 

Example:

 

<!DOCTYPE html>
<head>
<title>Page Title</title>
</head>
<h1>This is I2tutorials</h1>
<p>Welcome to I2tutorials</p>

 

OUTPUT:

 

HTML5 User Manual

 

Not to omit and tag because is a root element and specifies the web page language.

 

Syntax:

 

<!DOCTYPE html> 
<html lang="en-US">

 

Example:

 

<!DOCTYPE html>
<html lang="en-US">
<head>
<title>Page Title</title>
</head>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
</html>

 

OUTPUT:

 

HTML5 User Manual