ad

Monday, December 15, 2025

CSS Comment Tag Explain

CSS Comments Tag Explain


web designing theory

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 comments tag is CSS is note written by a programmer to explain the code the browser not              read  comments  so they do not affect the program output.

 ✅  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

Syntax :-

/*  this is css comment  */

  •                           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 


<!DOCTYPE html>
<html>
<head>
<title> css comment tag </title>

    <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>

</head>
<body>
           
       <p>Hello every one</p>
      <p >learn to programming language</p>
        <h2>HTML,CSS,PHP</h2>
    <p>https://webdesigningtheory.blogspot.com/</p>
  </body>
  </html>


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>
        <title> CSS comment tag </title>


  •   <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]

<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 

    CSS Comment 

     
    /* style is comment so will not word*/
         /*
         h2{
         background-color:pink;
         }  
         */      
       

    • this code inside a comment  tag.
    • <h2>  tag  will not work.
    • background color is not applied.
    Step 6]

    closing the Tag

     
    </style>
    </head>

    Step 7]

    <body>
               
           <p>Hello every one</p>
          <p >learn to programming language</p>
            <h2>HTML,CSS,PHP</h2>
        <p>https://webdesigningtheory.blogspot.com/</p>

    Body Section

    • body tag all contains  visible content of the webpage.
    • all <P> paragraph  tag  
    •   text center
    • text color blue
    • text font size 20px

    <h2> tag 

    • heading tag 
    •  Display a heading  
    • <h2> tag not css applied because  the <h2> tag style is commented 
    Step 8]

    closing the Tag

    </body>
    </html>

    CSS Comments Tag Explain

    Output

    web designing theory blogspot.com

    Related Post :-

    How to Use Textarea in HTML

    How to Add Border To Image in HTML

    How To Use The HTML Img Tag