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 (//).
Copyright © 2006 of the German translation, dpunkt.verlag GmbH
You may print the online version for your private use.
Otherwise, this chapter from “CSS − Anspruchsvolle Websites mit Cascading Stylesheets” is subject to the same conditions as the bound edition: the work, including all its parts, is protected by copyright. All rights reserved, including reproduction, translation, microfilming, and storage and processing in electronic systems.
dpunkt.verlag GmbH, Ringstraße 19, 69115 Heidelberg
back to top