0

...and if not, why not? :)

PHP and JS have this simple, intuitive, useful feature: You can place two slashes (//) to comment out everything from the slashes to the end of the line, without having to actually go to the line's end and place something that terminates the comment.

CSS hasn't had anything like this in my experience, but I'm wondering if maybe there's been some development there yet. And if not, does anyone know of a hack, a workaround, or a practice of some sort, that might mimic such a feature?

equazcion
  • 596
  • 1
  • 7
  • 14
  • 2
    did you try using it? you just need to add a letter to a css property to make it invalid. which will ofcourse act as commenting. – Mr_Green Apr 04 '14 at 09:56
  • I guess breaking the code in the line is a good hack :) Though I still wonder if there's a legitimate way... Also if not, I'm curious **why** CSS never implemented this. – equazcion Apr 04 '14 at 10:04

2 Answers2

1

I'm pretty sure there is no valid way to do an inline comment in CSS. If you have a reason to use a CSS preprocessor such as LESS or SASS, they'll let you do inline comments.

Your best bet may just be getting a text editor that can autocomplete the ending tag for the multiline comment.

  • In Sublime Text, all you have to do is hit "CTRL + /" to start a comment.
  • In Notepad++, you use "CTRL + SHIFT + Q" to start a comment.
jsea
  • 3,859
  • 1
  • 17
  • 21
0

With some browsers the "//" can be tolerated so you may try it if it works for you. But it is definitely not guarenteed to work and i dont think there is any widely known way to do this. There is software that will automatically close out the end of the line, or you can get into the habit of typing the /**/ and moving in between the two lines.

This pretty much covers this: Is it bad practice to comment out single lines of CSS with //?

Community
  • 1
  • 1
gstetsyuk
  • 1
  • 1