DEV Community


Posted on • Updated on


What is a Comment?
A comment is an explanation or description of the source code of a program, They are piece of codes that are ignored the compiler or interpreter
The syntax of comments in various programming languages varies considerably.

Importance and Uses of Comment
As a programmer comments helps in making codes easy to understand, easy to debug and also stimulate code readability between the programmer and others.
Comments are also used to document programs and remind programmers of what tricky things they just did with the code and also helps the later generation for understanding and maintenance of code.

HTML5 comments are placed in between <!-- ... --> tags. So, any content placed with-in <!-- ... --> (comment)tags will be treated as a comment and will be completely ignored by the browser.


<!-- This is a HTML5 comment -->

Comments do not nest each other, i.e a comment should not be placed inside another comment. Also when writing comments we do well to make sure that there are no spaces in the start-of comment string.


< !-- This is an invalid HTML5 comment -->

from that example we can say it is an invalid comment because a space occurs between the left angle bracket and the exclamation mark and as a result the web browser will not ignore it.

<!-- This is an valid HTML5 comment -->
This is a valid comment because it contains no space between the left bracket and the exclamation mark.

So far we have seen single line comments, but HTML supports multi-line comments as well. You can comment multiple lines by the special beginning tag <!-- ... and ending tag --> placed before the first line and end of the last line as shown in the given example below.

         This is a multiline comment and it can
         span through as many as lines you like.

CSS Comment
CSS uses the C-like "comment block"-style comments: /* */ . This allows for multi-line comments, and you can quickly use it to disable portions of your code.


/* css comment */

Don't use comments as an excuse for unclean code. It can be tempting, when you're in a rush, to poorly write codes, then write a comment that explains what it actually does or why you took the shortcuts that you did.
This might be OK as a temporary fix, but don't make it standard practice. Instead, strive to make your code itself as clean and readable as possible. This keeps the need for comments minimal in the first place.

Top comments (2)

waleedd1 profile image
waleedd1 • Edited

As there are many who are into HTML AND CSS COMMENTS, USES AND IMPORTANCE so we all can say that do my accounting homework will be what we are looking forward to for them as well. You can see that and we will be able to talk about this for now as well.

simfpayn profile image

Students may use the dissertation writing services review to contact top essay writing experts who will aid them with high-quality assignments. If the pupils choose seasoned specialists, the experts have years of experience in the industry.