Comments

  • Revision slug: CSS/Comments
  • Revision title: Comments
  • Revision id: 360073
  • Created:
  • Creator: ethertank
  • Is current revision? No
  • Comment

Revision Content

{{CSSRef}}

Summary

Comments are used to add explanatory notes or prevent the browser from interpreting parts of the stylesheet.

Syntax

/* Comment */

Examples

/* A single line comment */

/*
A comment
which stretches
over several
lines
*/

Notes

The /* */ comment syntax is used for both single and multi line comments. There is no other way to specify comments in external stylesheets. However, when using the <style> element, you may use <!-- --> to hide CSS from older browsers, although this is not recommended. As in most programming languages that use the /* */ comment syntax, comments cannot be nested. In other words, the first instance of */ that follows an instance of /* closes the comment.

Specifications

Revision Source

<div>{{CSSRef}}</div>
<h2 id="Summary">Summary</h2>
<p>Comments are used to add explanatory notes or prevent the browser from interpreting parts of the stylesheet.</p>
<h2 id="Syntax">Syntax</h2>
<pre class="syntaxbox">
/* Comment */</pre>
<h2 id="Examples">Examples</h2>

<pre class="brush:css">
/* A single line comment */

/*
A comment
which stretches
over several
lines
*/
</pre>
<h2 id="Notes">Notes</h2>
<p>The <code>/* */</code> comment syntax is used for both single and multi line comments. There is no other way to specify comments in external stylesheets. However, when using the <code>&lt;style&gt;</code> element, you may use <code>&lt;!-- --&gt;</code> to hide CSS from older browsers, although this is not recommended. As in most programming languages that use the <code>/* */</code> comment syntax, comments cannot be nested. In other words, the first instance of <code>*/</code> that follows an instance of <code>/*</code> closes the comment.</p>
<h2 id="Specifications">Specifications</h2>
<ul>
  <li><a href="http://www.w3.org/TR/CSS21/syndata.html#comments">CSS 2.1 Syntax and basic data types #comments</a></li>
</ul>
Revert to this revision