Basic Concept Behind CSS Comment Tag
CSS Comment Concept:
  • CSS comment is not displayed on the screen.It helps to understand the source code by the developers.
  • It applies inside any CSS file or inside <style>element.
  • It starts with /* and ends with */.
  • Multi Line Comments-Write more than one comment inside /* and */.

Note:The CSS comment statement does not display on the screen & it is useful for a screen reader.

Single Line Comment

Write a single line inside /* and */ to make a single-line comment.

General Syntax

p { color: red; /* Set text color to red */ }    

Source Code

Download
p{ color: red; /* Set text color to red */ }

Code Explanation

Note:The CSS single line comment statement is written inside / * Your CSS Comment Statement */ statement.

Multi Line Comment

Write more than one line inside /* and */ to make multi-line comments.

General sysntax for writing multi line comment:

General Syntax

/*
This is
a multi-line
comment 
*/    

Source Code

Download
/*
This is
a multi-line
comment 
*/

Code Explanation

Note:Follow the above mention steps to create single and multi-line comments.

Difference Between HTML & CSS Comment

  • HTML comment starts with <!-- and end with -->
  • CSS comment starts with /* and end with */

Example

General Syntax

p { color: red; /* This is css comment syntax */ }
<h3>This is HTML commented line</h3>
<!-- This is HTML Comment synatx  -->    

Source Code

Download
p{ color: red; /* This is CSS comment syntax. font-size:1.2rem; */ }
<!-- <h2>This is HTML Comment syntax</h2>  -->
<h3>This is HTML commented line</h3>

Code Explanation

Note:Please keep in mind that HTML and CSS comments are useful for screen readers as well as other developers.

Online Test / Quiz

Our Tutorials

Html Tutorial HTML
Css Tutorial CSS
Bootstrap 5 Tutorial BOOTSTRAP 5
Bootstrap 4 Tutorial BOOTSTRAP 4
Materialize CSS Tutorial MATERIALIZE CSS
2021-22 © shapeyourpath.com