CSS Comments
Add CSS Comments
Comments are used to explain your code and they are ignored by browsers.
A CSS comment begins with "/*
", and ends with "*/
", like this:
/*This is a comment*/
p{/*from www . ja v a 2s . c o m*/
color:red;
text-align:center;
}
The following code uses CSS comments in a html document.
<!DOCTYPE HTML>
<html>
<head>
<style type="text/css">
/*This is a comment*/
p{<!--from www. j a v a2s .c o m-->
color:red;
text-align:center;
}
</style>
</head>
<body>
<p>Visit the website</p>
</body>
</html>
The code above generates the following result.
Comment among the declaration
We can even put comment among the declaration.
<!DOCTYPE HTML>
<html>
<head>
<style type="text/css">
p{<!-- ww w. j a v a 2s .c om-->
color:red;
/*This is a comment*/
text-align:center;
}
</style>
</head>
<body>
<p>Visit the website</p>
</body>
</html>
The code above generates the following result.
HTML CSS Tutorial HTML CSS Basic
HTML Introduction
HTML Documents
HTML Element
HTML Attributes
HTML Core Attributes
HTML Comments
HTML Headings
HTML Paragraphs
HTML Rules (Lines)
HTML Line Breaks
CSS Introduction
CSS Syntax
CSS Color
CSS Lengths
Grouping/nesting Selectors
Add CSS to HTML
Compare em measurement and pixel measuremen...
Select class along with tag name in HTML an...
Select Next Sibling with Next Sibling Selec...
Select with Descendant Selectors in HTML an...
Set color to purple in HTML and CSS
Set color with rgb function in HTML and CSS
Set text color for body element in HTML and...
Show the difference between block and inlin...
HTML Introduction
HTML Documents
HTML Element
HTML Attributes
HTML Core Attributes
HTML Comments
HTML Headings
HTML Paragraphs
HTML Rules (Lines)
HTML Line Breaks
CSS Introduction
CSS Syntax
CSS Color
CSS Lengths
CSS Comments
CSS selectorGrouping/nesting Selectors
Add CSS to HTML
Compare em measurement and pixel measuremen...
Select class along with tag name in HTML an...
Select Next Sibling with Next Sibling Selec...
Select with Descendant Selectors in HTML an...
Set color to purple in HTML and CSS
Set color with rgb function in HTML and CSS
Set text color for body element in HTML and...
Show the difference between block and inlin...