21 Nov CSS – Comments
The comments in CSS are used to describe the code and are ignored by the web browsers i.e. whatever you mention in the comments won’t be displayed.
To add comments, use:
1 2 3 |
/* This is a comment in CSS */ |
The following are the type of comments in CSS:
- Single-line comments
- Multi-line comments
Single-line comments in CSS
Allows you to set single-line comments as in the below example:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
<!DOCTYPE html> <html> <head> <style> p { border-style: solid; /* Set the border style */ border-color: blue; /* Set the border color */ border-width: 3px; /* Set the border width */ } </style> </head> <body> <h2>Studyopedia</h2> <p>A website with courses on programming and web development.</p> </body> </html> |
When we will run and get the output, the comments won’t be visible on the web page:
Multi-line comments
To span comments on multiple lines at a time, use the multi-line comments in CSS. Let us see the above example and set multi-line comments which won’t be visible on the web browser:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
<!DOCTYPE html> <html> <head> <style> /* Set border style, color and width */ p { border-style: dashed; border-color: red; border-width: 2px; } </style> </head> <body> <h2>Studyopedia</h2> <p>A website with courses on programming and web development.</p> </body> </html> |
When we will run and get the output, the multi-line comments won’t be visible on the web page:
If you liked the tutorial, spread the word and share the link and our website Studyopedia with others.
Read More:
No Comments