XML technologies / CSS / Advanced websites with CSS / Behind the scenes / CSS comments

(Excerpt from “CSS − Advanced websites with Cascading Stylesheets” by Rachel Andrew & Dan Shafer)

HTML comments such as the following are familiar:

<!-- das ist ein HTML-Kommentar -->

Comments contain explanations in a document’s source code. Browsers ignore them completely. If you have ever had to work on and modify another author’s code, you will appreciate the value of good documentation.

CSS also has a comment syntax. HTML comments start with <!-- and end with -->, whereas CSS comments are enclosed between /* and */:

<style type="text/css">
/* Diese Regel stellt sämtlichen Text auf der Seite rot dar. 
Wir weisen die Regel auch extra den HTML-Elementen für Abschnitte und Tabellen-Zellen zu. 
Somit werden auch ältere Browser unterstützt, bei denen Vererbung nicht richtig funktioniert. */
body, p, td, th {
  color: red;
}
</style>

Anyone familiar with multiline JavaScript comments will recognise this syntax. Unlike JavaScript, however, CSS does not support single-line comments with double slashes (//).

  

 

 

 

back to top