CSS Comments
CSS comments are not displayed in the browser, but they can help document your source code.
CSS Comments
Comments are used to explain the code, and may help when you edit the source code at a later date.
Comments are ignored by browsers.
A CSS comment is placed inside the <style> element, and starts with /* and ends with */:
Example 1: Single-line Comment
Hello World!
Example 2: Multi-line Comment
Comments can also span multiple lines:
Hello World!
Example 3: Commenting Out Code
You can use comments to prevent code from running, which is useful for debugging.
This text is red, but not centered.
Example 4: HTML vs CSS Comments
Remember that HTML comments and CSS comments are different.
<!DOCTYPE html>
<html>
<head>
<style>
/* This is a CSS comment */
p {
color: red;
}
</style>
</head>
<body>
<!-- This is an HTML comment -->
<p>Hello World!</p>
</body>
</html>