Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS - smarter code comments

Tags:

comments

css

I read some time ago about a way to comment a css block in a such way that you only need to remove one end of the comment character set in case you want to uncomment the block later.

But I can't remember how it was done :( Maybe someone here does know :)

like image 949
Alex Avatar asked Sep 14 '10 19:09

Alex


People also ask

How do you write a good comment in CSS?

To comment in CSS, simply place your plain text inside /* */ marks. This tells the browser that they are notes and should not be rendered on the front end. You can also format them as multi-line comments: /* These words…

Can you nest comments in CSS?

-- --> to hide CSS from older browsers, although this is not recommended. As with most programming languages that use the /* */ comment syntax, comments cannot be nested. In other words, the first instance of */ that follows an instance of /* closes the comment.

How do I remark HTML code?

To “comment out” a button — or any HTML element— simply wrap the element in the< ! ╌ ╌> tags. Everything between those tags will not be shown on the front end.


1 Answers

/* * /

.class { color: #ffa; }

/* */

The space between the * and / in the first line causes the comment block to be un-closed until the final, paired, */ on the last line.

If you close that space then the .class css is un-commented.

For languages such as php and JavaScript the opening /* in the last line can be replaced with a // as a single-line comment:

/* */
$name = $_POST['first_name'] . " " . $_POST['last_name'];
// */

I think it's called 'lazy-commenting' or something, but I'm not sure.

like image 109
David Thomas Avatar answered Oct 05 '22 16:10

David Thomas