Skip to content

Buzzingz

Unleashing the Power of Code

  • HTML
  • CSS
  • Toggle search form

CSS Comments

Posted on March 12, 2023March 12, 2023 By shani No Comments on CSS Comments

CSS comments are used to add notes or explanations to your CSS code. Comments are not displayed on the web page and are ignored by the browser.

There are two ways to add comments in CSS:

  1. Single-line comments: To add a single-line comment in CSS, you can use the // syntax. Anything after // on a line will be treated as a comment. For example:
/* This is a CSS comment */

p {
  color: red; /* This is another CSS comment */
}

/* This line is not a comment
   But it can be a multi-line comment */

In the above example, the first and second lines are single-line comments, while the third line is an actual CSS rule.

  1. Multi-line comments: To add a multi-line comment in CSS, you can use the /* ... */ syntax. Anything between /* and */ will be treated as a comment. This allows you to add comments that span multiple lines. For example:
/*
This is a multi-line CSS comment
that spans multiple lines.
*/

p {
  color: red;
}

In the above example, the first three lines are multi-line comment, while the fourth line is an actual CSS rule.

Comments are useful for documenting your CSS code, explaining your thought process, or leaving notes for future updates. It’s good practice to use comments in your CSS code to make it more readable and easier to maintain.

CSS

Post navigation

Previous Post: How To Add CSS
Next Post: CSS Colors

Leave a Reply Cancel reply

Your email address will not be published. Required fields are marked *

CSS Tutorial

  • Basic CSS Tutorial For Beginners
  • CSS Introduction
  • CSS Syntax
  • CSS Selectors
  • How To Add CSS
  • CSS Comments
  • CSS Colors
  • CSS Backgrounds
  • CSS Borders
  • CSS Margins
  • CSS Margin Collapse
  • CSS Padding
  • CSS Height, Width and Max-width
  • CSS Box Model
  • CSS Outline
  • CSS Text
  • CSS Fonts
  • CSS Web Safe Fonts
  • CSS Font Fallbacks
  • CSS Font Style
  • CSS Font Size
  • CSS Google Fonts
  • CSS Great Font Pairings
  • CSS Icons
  • CSS Links
  • CSS Lists
  • CSS Tables
  • CSS Layout – display: inline-block
  • CSS Layout – float and clear
  • CSS Layout – Horizontal & Vertical Align
  • CSS Layout – Overflow
  • CSS Layout – The display Property
  • CSS Layout – The z-index Property
  • CSS Layout – width and max-width
  • CSS Layout – The position Property
  • CSS Attribute Selectors
  • CSS Image Sprites
  • CSS Image Gallery
  • CSS Dropdowns
  • CSS Horizontal Navigation Bar
  • CSS Vertical Navigation Bar
  • CSS Navigation Bar
  • CSS Opacity / Transparency
  • CSS Pseudo-elements
  • CSS Pseudo-classes
  • CSS Combinators
  • CSS Math Functions
  • CSS The !important Rule
  • CSS Specificity
  • CSS Units
  • CSS Website Layout
  • CSS Counters
  • CSS Forms
  • About Us
  • Contact Us
  • Privacy Policy
  • Terms & Conditions

Copyright © 2023 Buzzingz.

Powered by PressBook WordPress theme