HTML5 User Manual

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:

<!DOCTYPE html>  

You can also use <!DOCTYPE html> 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:

<SECTION>  

<p>This is javatpoint.com</p>  

</SECTION

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

Very Bad practice:

<Section>  

<p>This is a javatpoint.com</p>  

</SECTION>

Good practice:

<section>  

<p>This is javatpoint.com.</p>  

</section>

Close all HTML Elements

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

Bad practice:

<section>  

<p>This is javatpoint.com  

</section>

Good practice:

<section>  

<p>This is javatpoint.com</p>  

</section>

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:

<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 javatpoint.com</h1>  

<p>Welcome to javatpoint.com</p>

We recommend you to not to omit and tag because is a root element and specifies the 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>

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *