Home Videos Exercises MCQ Q&A Quiz E-Store Services Blog Sign in Appointment Payment

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.

Comments can help you explain and organize your CSS, and control which parts of your stylesheet get applied on the front end.

CSS, comments are notes that explain CSS code without affecting the styling of a web page. How to use comments in CSS.

Comments are useful in adding explanatory notes of annotations within your stylesheet that are not interpreted as styling instructions by the web.

A comment is a piece of text within a style sheet that is not interpreted by the browser. It can be used to provide additional information.

A css comment is used to add explanatory notes to the code or to prevent the browser from interpreting specific parts of the style sheet.

A CSS comment is placed inside <style> element, and starts with /* and ends with */.


Example:
/*This is a single line comment*/


HTML and CSS comments

From the HTML tutorial, you learned that you can add comments to your HTML source by using syntax.


Here are the key points of css comments

  • 1. Syntax: CSS comments start with /* and end with */. They can span multiple lines.
  • 2. Purpose:Comments are used to explain the purpose or function of specific sections of code, making the CSS easier to understand for yourself or other developers.
  • 3. Ignored By Browsers: Browsers ignore comments in CSS, so they have no impact on how styles are renderd on the page.
  • 4. Organizational Tool: Comments help organize CSS into sections (e.g., typography, layout, colors), making it easier to navigate and maintain the stylesheet.
  • 5. Temporary Disablement: Comments can be used to temporarily disable CSS code by surrounding it with comment markers, which is helpful for debugging.
  • 6. No Nesting: CSS does not support nested comments, Each comment block must be closed individually, or it may cause errors.