css comments | css comment out | css comment tag

css comments | css comment out | css comment tag

Hey friends, today I’ll  teach how show how and why to comment in CSS! Btw, I’m CodingPorium and I make coding tutorials and provide Free Source Code on YouTube and Instagram.


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.

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

How to add a comment in CSS

Today, we’ll look through how to add comments in code for CSS instead of HTML or JavaScript. Generally, we use the following code for comments. 

/* 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.

Javascript project ideas with complete source code 

Importance of Comments in css

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

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

Let’s see an example use case.

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.

Check it more

written by @codingporium

Thanks for reading! Do contact me via the methods below if you have to say anything:

Share on:

Leave a Comment