ADVERTISEMENT

What is a Comment in CSS? Comment Out CSS Code

Telegram Group Join Now

ADVERTISEMENT

What is a Comment in CSS? Comment Out CSS Code

 
What is a Comment in CSS? Comment Out CSS Code
What is a Comment in CSS? Comment Out CSS Code

 

ADVERTISEMENT

ADVERTISEMENT

Hello Coder, today I’ll teach how to show how and why to Comment in CSS.

What is a Comment in CSS?

Comments are lines of advice or sentences that explain your code in detail. For example, maybe you have an HTML code that states body{background: green;} and you can describe its function with a comment beside it.

ADVERTISEMENT

The power of comments is that it doesn’t appear in public but remain in the code only. We will also look through why you should start using comments and why it’s a good practice.

ADVERTISEMENT

How to add a Comment in CSS

Today, we’ll look through how to Add comments in CSS Code. in Css we have only 1 way to add comments /* CSS Comment */ So lest see with an example.

/* This is a comment to explain my code */

The output on the main page is none. This is because as said earlier, there is no public output of comments. Comments are mainly to help explain your code blocks only.

50+ HTML, CSS & JavaScript Projects With Source Code

ADVERTISEMENT

one more Example Of  Comment Out CSS Code

/* Box Code Start Form Her */
.box{
  width: 200px;
}

/* Box1 Code Start Form Her */

.box1{
  width: 200px;
}

/* Box2 Code Start Form Her */

.box2{
  width: 200px;
}

Importance of Comments in CSS

Now let’s see why it is so essential to add comments in code and why it even exists.

Many people say adding comments makes you a better and good coder. But have you ever wondered why they say so?

ADVERTISEMENT

Let’s see an example use case.

ADVERTISEMENT

Imagine you’re working in a coding company. However, one day you decide to resign and leave your job. What happens is that someone else will take over your previous project. When you add comments, this helps them or junior developers to understand what you have coded and how to complete the project.

 

 

That is just a real-life scenario. However, honestly, the ultimate reason you should add comments in code is so that you understand your code even better. When you start explaining parts of your code through comments, you will have a clearer understanding of your code.

Thus, that is why you should start using comments in your projects.

10+ Javascript Projects For Beginners With Source Code

ADVERTISEMENT

written by @codingporium

ADVERTISEMENT

Thanks for reading!!!

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT

Telegram Group Join Now

Share on:

Leave a Comment

ADVERTISEMENT

ADVERTISEMENT

ADVERTISEMENT