Home > Mobile >  Right comment indentation in HTML5
Right comment indentation in HTML5

Time:11-01

I'm deepening my HTML knowledge and currently I'm learning HTML indentation, but i don't know how to indent multiline comments, my IDE (PhpStorm) indents comment like this:

<!--
hello,
how are you?
-->

and on some websites i saw something like this:

<!--
   hello,
   how are you?
-->

What's the proper way to indent multiline comments in HTML?

CodePudding user response:

It doesn't really matter. The only thing to keep in mind is that once you have started a style, you should continue to do so throughout the entire application.

What there is, however, is Conditional comment.

<!--[if IE 6]>
   Special instructions for IE 6 here
<![endif]-->

Conditional comments only work in Internet Explorer (IE) on Windows , but they are ignored by other browsers. They are supported from Explorer 5 and above, and you can use them to give conditional instructions to different versions of IE.

Only a small Note. The following points are more important when commenting:

  • Always try to explain yourself in the code.
  • Do not be redundant.
  • Do not add obvious noise.
  • Don't comment out code. Just remove it.
  • Use as a statement of intent or to clarify code.
  • Use as legal and informational comments.

CodePudding user response:

I don’t think there is a “proper” way. Comments are used to help you, and others to better understand your code. They also have few limitations about how they can be created.

To answer your question, no. Comments are there to help you understand your code, so whichever way is best for you is the way that you should use.

  •  Tags:  
  • html
  • Related