0% found this document useful (0 votes)
8 views3 pages

CSS Tutorial 3

The document explains the use of comments in CSS, which are ignored by the compiler and serve to enhance code readability. It details the syntax for single-line and multi-line comments, emphasizing the best practices for using comments in code. Additionally, it provides examples to illustrate both single-line and multi-line comments in HTML with CSS styling.

Uploaded by

Rohit Raut
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views3 pages

CSS Tutorial 3

The document explains the use of comments in CSS, which are ignored by the compiler and serve to enhance code readability. It details the syntax for single-line and multi-line comments, emphasizing the best practices for using comments in code. Additionally, it provides examples to illustrate both single-line and multi-line comments in HTML with CSS styling.

Uploaded by

Rohit Raut
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

CSS

Topperworld.in

Comments

⚫ The Comments in CSS, are the statements in your code that are ignored by
the compiler and are not executed.
⚫ Comments are used to explain the code. They make the program more
readable and understandable.

Syntax:

/* content */

✓ Comments can be single-line or multi-line.


✓ The /* */ comment syntax can be used for both single and multiline
comments.
✓ We may use <!– –> syntax for hiding in CSS for older browsers, but this is no
longer recommended for use.
✓ Adding comments to the code is a good practice that can help to understand
the code if someone reads the code or if it is reviewed later.

Note: The outputs are the same because comments are ignored by the
browser and are not interpreted.

©Topperworld
CSS

Example 1: This example describes the single-line comment.

<!DOCTYPE html>
<html>
<head>
<style>
h1 {
color: green;
}

/* Single line comment */


</style>
</head>

<body>
<h1>Topper World</h1>
<p> A Computer Science portal for students </p>

</body>
</html>

Output:

©Topperworld
CSS

Example 2: This example describes the multi-line comment.

<!DOCTYPE html>
<html>
<head>
<style>
h1 {
color: green;
}

/* This is a multiline
comment */
</style>
</head>
<body>
<h1>Topper World</h1>
<p> A Computer Science portal for student </p>
</body>
</html>

Output:

©Topperworld

You might also like