You should comment on HTML and CSS code

Insert CSS comment - comment out CSS areas

As with HTML, we can also comment on our CSS instructions or comment out areas in our CSS instructions (to put it bluntly, switch them off or temporarily deactivate them).

Structure of the CSS comment

The corresponding instruction differs from the HTML comment. The CSS comment is introduced with and followed by. The now enclosed is ignored by the browser:

In the following example for the foreground and background color, we switch off the background color:

The 2 functions of comments

The possibility of commenting out or commenting offers us the following 2 possibilities.

  • Commenting on our CSS code
  • Comment out areas, for example to save them for later or to test something

Insert CSS comments

If we want to add a comment, we can do so directly after our code. In the following example the hex code is commented:

Commenting out areas

We can comment out individual lines and thus play with our CSS code while learning CSS and thus learn to better understand how CSS works.

Or several lines:

In the above example, ours no longer has any CSS instructions. We could also comment out the entire selector:

TIP: Use shortcuts in the editor!

Most editor shortcuts for commenting out areas in CSS allow you to comment out areas very quickly.

For the editor bracket used in the course, the procedure is:

  • Mark the code to be commented out (if you only want to comment out one line, then it is sufficient to place the cursor in the line
  • Shortcut Windows + +
  • Shortcut Mac ++

If you want to "activate" something that has been commented out, simply do the above again. Place cursor in line (if only one line is commented out), otherwise mark the lines. Then press the appropriate shortcut for your operating system.

Recommend • Social Bookmarks • Thank you

If you find a bug, please let us know (no matter if typographical or content-related error).

With a mouse Mark the faulty point and take over with the following button:

After submitting it comes here feedback! Please do not send twice. Thanks.