views:

50

answers:

1

Hi

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 :)

+9  A: 
/* * /

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

David Thomas
that's it. thank you :)
Alex
+1 for the interesting factor! Personally I'd just use an editor where you can easily see the end of the comment and just use normal commenting.
RichardOD
@Alex, you're quite welcome, I'm glad to have been of use. @RichardOD, it's still fairly new to me (I found the technique mentioned in a "best hidden facts of..." type question on here in the past week or so). It is useful, albeit I tend to write in Gedit with CSS/JS/PHP highlighting. It saves time finding/removing the comment-close, when you're debugging blocks of code.
David Thomas