NEW

6/recent/ticker-posts

Header Ads Widget

HTML5 User Manual

 

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:

  1. <!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:

  1. <SECTION>  
  2. <p>This is javatpoint.com</p>  
  3. </SECTION>  

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

Very Bad practice:

  1. <Section>  
  2. <p>This is a javatpoint.com</p>  
  3. </SECTION>  

Good practice:

  1. <section>  
  2. <p>This is javatpoint.com.</p>  
  3. </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:

  1. <section>  
  2. <p>This is javatpoint.com  
  3. </section>  

Good practice:


  1. <section>  
  2. <p>This is javatpoint.com</p>  
  3. </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:

  1. <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:

  1. <!DOCTYPE html>  
  2. <head>  
  3. <title>Page Title</title>  
  4. </head>  
  5. <h1>This is javatpoint.com</h1>  
  6. <p>Welcome to javatpoint.com</p>  
Test it Now

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

Syntax: 

  1. <!DOCTYPE html> 
  2. <html lang="en-US">  

Example:

  1. <!DOCTYPE html>  
  2. <html lang="en-US">  
  3. <head>  
  4. <title>Page Title</title>  
  5. </head>  
  6. <body>  
  7. <h1>This is a heading</h1>  
  8. <p>This is a paragraph.</p>  
  9. </body>  
  10. </html>  

Post a Comment

0 Comments

Recents Post

Exploring Paidwork - Your Gateway to Earning Online