19/09/2025, 23:25 CSS Comments - GeeksforGeeks
Search... Sign In
Full Stack Course HTML CSS JavaScript TypeScript jQuery AngularJS ReactJS Next.js
CSS Comments
Last Updated : 29 Nov, 2024
CSS comments are used to add notes or explanations to your code,
helping you and others understand it better. They start with /* and end
with */ and can be used for both single-line and multi-line comments.
Note: Comments are ignored by browsers, so they won’t affect how
your webpage looks or works.
Syntax
/* Code comments */
Comments can be added anywhere in the code, and they can span
across multiple lines. It’s a good practice to add comments to clarify
complex parts of your code for future reference or collaboration.
Older methods like <!-- --> for hiding CSS in older browsers are
outdated and not recommended. Comments are simply ignored by
the browser, so they don't affect the output in any way.
Example 1: This example describes the single-line comment.
<!DOCTYPE html>
<html>
<head>
<title>Single line comment</title>
<style>
h1 {
color: green;
}
/* Single line comment */
</style>
</head>
https://www.geeksforgeeks.org/css/css-comments/ 1/4
19/09/2025, 23:25 CSS Comments - GeeksforGeeks
<body>
<h1>Study portal</h1>
<p> Study portal for CS students</p>
</body>
</html>
Output
Single line comment
Example 2: This example describes the multi-line comment.
<!DOCTYPE html>
<html>
<head>
<title>Multiline Comment</title>
<style>
h1 {
color: green;
}
/* This is a multiline
comment */
</style>
</head>
<body>
<h1>Study portal</h1>
<p> A Computer Science portal </p>
</body>
</html>
Output
https://www.geeksforgeeks.org/css/css-comments/ 2/4
19/09/2025, 23:25 CSS Comments - GeeksforGeeks
multiline comment
CSS comments are universally supported across all modern
browsers and platforms. Since they are ignored by the browser,
they do not affect the visual layout or functionality of the web
page. No special handling or cross-browser testing is required for
comments.
Comment More info
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate
Tower, Sector- 136, Noida, Uttar Pradesh
(201305)
Registered Address:
K 061, Tower K, Gulshan Vivante
Apartment, Sector 137, Noida, Gautam
Buddh Nagar, Uttar Pradesh, 201305
Company Explore
About Us POTD
Legal Job-A-Thon
Privacy Policy Connect
Careers Community
Contact Us Blogs
https://www.geeksforgeeks.org/css/css-comments/ 3/4
19/09/2025, 23:25 CSS Comments - GeeksforGeeks
Corporate Solution Nation Skill Up
Campus Training Program
Tutorials Courses
Programming Languages IBM Certification
DSA DSA and Placements
Web Technology Web Development
AI, ML & Data Science Data Science
DevOps Programming Languages
CS Core Subjects DevOps & Cloud
Interview Preparation GATE
GATE Trending Technologies
School Subjects
Software and Tools
Offline Centers Preparation Corner
Noida Aptitude
Bengaluru Puzzles
Pune GfG 160
Hyderabad DSA 360
Patna System Design
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
https://www.geeksforgeeks.org/css/css-comments/ 4/4