CSS Comments Tag Explain
This Blog You Will Learn
ஃ What is CSS comment tag
ஃ Why use comments in CSS?
ஃ Best Practices
ஃ Syntax
ஃ Explain Program
ஃ Output
What is CSS comment tag
✅ CSS comment tag written inside stylesheet that ignored by browser.
✅ CSS comments tag use reminders in your own stylebook.
✅
✅ CSS comment starts with /* and ends with */. Anything written inside these symbols is ignored by the browser and does not affect the webpage design.
✅ Comments can be written on one line or across multiple lines.
✅ They are very useful when learning CSS, fixing errors, or temporarily disabling styles without deleting the code.
Why use comments in CSS?
1) improve Readability.
2) Help Collaboration
3) Temporarily Disable code.
4) Mark Sections or TODOs
5) Help explain your code.
6) code stylesheets easier to read and maintain.
Best Practices
- comments tag short but meaningful.
- update comments when change the code.
- use comments to mark sections or clarify non-obvious logic.
CSS Comments Tag Explain
- Start with /*
- Ends with */
- CSS comment tag use single-line or multiple line.
- CSS comment tag use code remember things later
- CSS comment tag use code temporarily disable
- CSS comment tag use code easy to understand for other.
CSS Comments Tag Explain
Example
CSS Comments Tag Explain
Explain Program
Step 1] <!DOCTYPE html>
- This declare the document type.
- browser that the document is written in html
Step 2 ]
<html>
- html is the root element of the html page.
- Every thing inside it is part of the webpage.
Step 3]
- <head> section
- head section contains metadata about page. not visible on the page itself.
- <title> tag title section set the title of the page shows the browser tab.
Step 4] <body>
- Contains all visible of the webpage.
- Everything inside <body> tag visible content of the webpage.
- User will display/see their browser.
Step 5]
Step 1]
<!DOCTYPE html>
- This declare the document type.
- browser that the document is written in html
Step 2 ]
<html>
- html is the root element of the html page.
- Every thing inside it is part of the webpage.
Step 3]
- <head> section
- head section contains metadata about page. not visible on the page itself.
- <title> tag title section set the title of the page shows the browser tab.
<body>
- Contains all visible of the webpage.
- Everything inside <body> tag visible content of the webpage.
- User will display/see their browser.
Step 5]
<style> p{ text-align:center; color:rgb(19, 47, 253); font-size: 20px; } /* style is comment so will not word*/ /* h2{ background-color:pink; } */ </style>
- <P> ⇨ all paragraph tag
- text-align:center; ⇨ all <p> tag center the text.
- color: rgb(19,47,253); ⇨ all paragraph tag color blue.
- font-size:20px; ⇨ text size
- this code inside a comment tag.
- <h2> tag will not work.
- background color is not applied.
Step 7]
Body Section
- body tag all contains visible content of the webpage.
- all <P> paragraph tag
- text center
- text color blue
- text font size 20px
- heading tag
- Display a heading
- <h2> tag not css applied because the <h2> tag style is commented
</body> </html>
CSS Comments Tag Explain
Output
Related Post :-
