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:
-
Single-line comments: These are created by using
//
for inline comments. -
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>