1

I am trying to comment internal CSS code as shown in the below image, but it's not working for me. If I comment this way, my code is still working on the site.

Is this is the right way to put comments for internal CSS code?

I tried /* */, but it didn't work for me.

Enter image description here

3
  • try this // or /* */ Commented Apr 18, 2016 at 13:09
  • 1
    You may already find your answer here: html comments in css? Commented Apr 18, 2016 at 13:14
  • as the software i am using for coding showed comment section in different color, so i thought it will work for css too. Commented Apr 18, 2016 at 13:19

3 Answers 3

3

Use /* */, not <!-- -->.

The second type is HTML, not CSS. The use of HTML comments is a hack having to do with some Microsoft browser and does not work as you might expect it to do.

Older answer

Sign up to request clarification or add additional context in comments.

1 Comment

as the software i am using for coding showed comment section in different color, so i thought it will work for css too.
0

Use /* ... */ to comment in CSS:

main {
    /* width: 100%; */
    width: 100px;
}

2 Comments

Atleast read the question man..op already said he used this but not working.
OP already tried that.. read carefully: i tried /* */ but didt worked for me
-1

Are you sure the /* */ don't work? It is working for me:

<html>
<body>
<style>
p { font-size: 2em;}
/*
p { margin:5em;}
*/
p { color: red; }
</style>
<p>Hello World</p>
</body>
</html>

4 Comments

I appreciate that you may not yet have sufficient reputation to leave comments but please do not use the answer system as a replacement. Gaining reputation is fairly easy and only requires a little effort on your part. Thanks!
OK, but still this can be accepted as an answer because this is just correct coding.
@Krant avoid asking questions in your answers, such as Have you tried?, Are you sure?. If you edit your answer and make it look like a real answer, people may upvote your posts.
The OP has already said that that commenting style didn't work...why we don't know.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.