Google Ads

Blank Lines and Indentation – HTML5 Style Guide – HTML Code


Blank Lines and Indentation – HTML5 Style Guide – HTML Code

Do not add blank lines without a reason.

For readability, add blank lines to separate large or logical code blocks.

For readability, add two spaces of indentation. Do not use the tab key.

Do not use unnecessary blank lines and indentation. It is not necessary to indent every element:

Unnecessary:

 
 
  1. <body>
  2. <h1>Famous Cities</h1>
  3. <h2>Tokyo</h2>
  4. <p>
  5. Tokyo is the capital of Japan, the center of the Greater Tokyo Area,
  6. and the most populous metropolitan area in the world.
  7. It is the seat of the Japanese government and the Imperial Palace,
  8. and the home of the Japanese Imperial Family.
  9. </p>
  10. </body>

 

Better:

 
 
  1. <body>
  2. <h1>Famous Cities</h1>
  3. <h2>Tokyo</h2>
  4. <p>Tokyo is the capital of Japan, the center of the Greater Tokyo Area,
  5. and the most populous metropolitan area in the world.
  6. It is the seat of the Japanese government and the Imperial Palace,
  7. and the home of the Japanese Imperial Family.</p>
  8. </body>

 

Table Example:

 
 
  1. <table>
  2. <tr>
  3. <th>Name</th>
  4. <th>Description</th>
  5. </tr>
  6. <tr>
  7. <td>A</td>
  8. <td>Description of A</td>
  9. </tr>
  10. <tr>
  11. <td>B</td>
  12. <td>Description of B</td>
  13. </tr>
  14. </table>

List Example:

 
 
  1. <ul>
  2. <li>London</li>
  3. <li>Paris</li>
  4. <li>Tokyo</li>
  5. </ul>

 

 

Have any Question or Comment?

Leave a Reply

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

"