Course Content
CSS Basic
0/1
CSS Selectors
0/1
CSS Comments
0/1
CSS Backgrounds
0/1
CSS Borders
0/1
CSS Outline
0/1
CSS Fonts
0/1
CSS Height and Width
0/1
CSS Margins and Paddings
0/2
CSS Icons
0/1
CSS Links
0/1
CSS Lists
0/1
CSS Tables
0/1
CSS Display Properties
0/1
CSS Max-Width Property
0/1
CSS Positioning Elements
0/1
CSS Z-Index Property
0/1
CSS Overflow
0/1
CSS Float
0/1
CSS Opacity
0/1
CSS Forms
0/1
CSS Dropdowns
0/1
CSS Buttons
0/1
CSS Media Queries
0/1
About Lesson

Difination:

CSS comments are used to add explanatory notes within your CSS code. Comments are ignored by the browser and are not displayed on the webpage. They are useful for documenting your code or temporarily disabling specific styles for testing purposes.

In CSS, there are two types of comments:

  1. Single-line comments: These are created by using // for inline comments.

  2. Multi-line comments: These are enclosed between /* and */ and can span multiple lines.

Example:

<!DOCTYPE html>
<html lang=”en”>
<head>
  <meta charset=”UTF-8″>
  <meta name=”viewport” content=”width=device-width, initial-scale=1.0″>
  <title>CSS Comments Example</title>
  <style>
    /* This is a multi-line comment */
   
    body {
      font-family: Arial, sans-serif;
      margin: 20px;
      /* Comment for the margin property */
    }
    h1 {
      color: #008080; /* Single-line comment for the color property */
    }
    p {
      font-size: 16px;
      line-height: 1.5;
    }
    /* Styling for a class */
    .highlight {
      background-color: yellow;
      border: 2px solid #f00;
    }
  </style>
</head>
<body>
  <h1>This is a Heading</h1>
  <p>This is a paragraph of text.</p>
  <p class=”highlight”>This paragraph has a special highlight.</p>
</body>
</html>

 

Output: