เราสามารถเขียนความคิดเห็นสำหรับการประกาศ CSS เพื่อช่วยปรับปรุงความอ่านง่ายและทำให้เข้าใจง่ายขึ้น CSS ปฏิบัติตามไวยากรณ์แบบภาษา C สำหรับความคิดเห็น ซึ่งเริ่มและจบด้วยเครื่องหมายทับนำหน้าที่ปิดล้อมเนื้อหาด้วยเครื่องหมายดอกจัน การประกาศใดๆ ที่เขียนไว้ภายใน /**/ จะถูกละเว้น
ไวยากรณ์
ไวยากรณ์ของความคิดเห็น CSS ดังนี้:
/*Comments*/
ตัวอย่างต่อไปนี้แสดงความคิดเห็น CSS:
ตัวอย่าง
<!DOCTYPE html> <html> <head> <style> ul { list-style: none; /*To remove the solid circles*/ } </style> </head> <body> <ul> <li>Σ1</li> <li>Σ2</li> <li>Σ3<li> </ul> </body> </html>
ผลลัพธ์
ได้ผลลัพธ์ดังนี้:

ตัวอย่างเพิ่มเติม
<!DOCTYPE html> <html> <head> <style> div {/*this <div> selects all >div> elements and the declares the following*/ margin: 8px; float: left; width: 100px; height: 100px; /*border: 2px solid black;*/ /*removed border*/ background-color: lightpink; } div + div { /*this makes a circle*/ border-radius: 50%; } </style> </head> <body> <div></div> <div></div> </body> </html>
ผลลัพธ์
ได้ผลลัพธ์ดังนี้:
