Comment in html || HTML Indentation

 Comment in HTML & HTML text Indentation

Comment in HTML:-

Comment in HTML: The <!–  –> is an HTML Comments tag for comment out in html document. Any content within <!– and –> HTML tags will define the commenting in HTML document. Browsers will not show these informations on the screen of the devices.

With the help of commenting the Web developers leave the information notes about their code for the other developers and its functionality or to indicate necessary changes for the future.

This <!–  –>  tag incorporates a comment in the source code of the HTML file.

Comment in HTML example:-

Comment tag Example

Notice that there is an exclamation mark (!) in the start tag, but not in the closing tag.

If You want to write multiple line comments in your source code of an HTML document, Don’t worry this comment<!–  –> tag will work on single line and multiple line comments in html.

Comment in HTML Example:-

Multiple line comment Example

Commenting in HTML source code is also helpful for debugging because you can comment in HTML’s code lines, one at a time, to search for errors:

HTML text Indentation and Spacing:-

 HTML text Indentation and Spacing should be consistent throughout your program code. Many web developers choose to use 2-space and 4-space or indentation in the coding files.

Tip-1: in HTML, each nested element should be indented exactly once spaces inside of its parent tag. You should place a line break after every block element.


indentation examples

Tip-2: Not more than one block element on the same line.

Bad Example:-

indantation bad example

Good Example:-

Indentation Good example


Nesting Tags

Close tags in the opposite order in which they were opened.

Always nest every inline element inside of a block element.
For example, do not put an anchor <a> tag directly between the <body> ….</body> so you should place it inside a  <p> or <li> or other block-level elements.

Bad Example:-

neasted tag bad Example

Good Example:-

neasted tag good example

Line Formatting:-

Long Lines:-

You should not have any lines that are longer than 100 characters in your HTML code. When any line is longer than 100 characters, break it apart into multiple lines.


Long Line example

Note:- When using a long URL, you may keep it on one line if it is longer than 100 characters (breaking apart a URL is a worse style than having this exception for long lines).

Blank Lines:-

Place a blank line between sections of the page and between large elements contain a lot of content. You should not have more than one blank line in a row. You should not use <br /> for the purpose of adding vertical spacing between elements. This tag is used solely for line breaks within a paragraph, and you should not use more than one in a row.

Spacing in tags:-

Do not place whitespace between a tag’s < brace and the element name.

Bad Example below:- 

<     p> This is paragraph </p     >

Good example below:-   

<p> This is paragraph</p>

You can watch video tutorials in Hindi Language Click here to watch