Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

CSS CSS Basics (2014) Basic Selectors CSS Comments

Why doesn't // (two slashes) comment out the text? Isn't that still valid CSS?

Why doesn't // (two slashes) comment out the text? Isn't that still valid CSS?

3 Answers

Manish Giri
Manish Giri
16,266 Points

// is a valid comment in JavaScript. For CSS, it's /* ... */

Nick Bollard
Nick Bollard
3,432 Points

You can use // to comment out CSS. Most browsers support this. It works for Google Chrome for example, but is not part of the official CSS standard. I guess this is why it's not taught at Treehouse. https://stackoverflow.com/questions/12298890/is-it-bad-practice-to-comment-out-single-lines-of-css-with

Hi there, For CSS we use /* This Comment is for CSS */. // (two slashes) comment out the text is used for Programming languages like JavaScript, Java, C# etc.

Hope this helps!