Style can be applied to specific html elements by specifying the html elements, then enclosing the styles within curly brackets .The following example shows a style being applied to the html element <p>.
p{color:blue;}
In this example all html <p> elements in the document would have a text color of blue.
There are many different types of selectors that allow great flexibility in applying style to elements.
Class and ID Selector:
In addition using the html element selectors custom selector can also be defined,in the form of Class and ID selectors.This allow having the same html elements , but styled differently depending on its cl;ass and Id .An Id selector can be used to identify one element,whereas a class selector can be used to identify more than one elements.
In CSS a Class selector is a name prrceded by a period (.) and ID selector is a name preceded by a pound sign (#).
The following example shows a class selector and an Id selector.
.highlight{
color:blue;
font-weight:bold;
}
#codebox{
background-color:#000000;
padding:15px;
border-style:solid;
border-width:1px;
}
This following example uses these style in html code...
<div id="codebox">
<p>
"normal" text here
</p>
<p class="highlight">
"highlight" text here.
</p>
</div>
CSS Comments:
In CSS a comments start with /* and end with */ sign.
Comments can span multiple lines but may not be nested.
Example:
/* This is one line comment */
/* This is multiple
lines comments */
p{color:blue;}
In this example all html <p> elements in the document would have a text color of blue.
There are many different types of selectors that allow great flexibility in applying style to elements.
Class and ID Selector:
In addition using the html element selectors custom selector can also be defined,in the form of Class and ID selectors.This allow having the same html elements , but styled differently depending on its cl;ass and Id .An Id selector can be used to identify one element,whereas a class selector can be used to identify more than one elements.
In CSS a Class selector is a name prrceded by a period (.) and ID selector is a name preceded by a pound sign (#).
The following example shows a class selector and an Id selector.
.highlight{
color:blue;
font-weight:bold;
}
#codebox{
background-color:#000000;
padding:15px;
border-style:solid;
border-width:1px;
}
This following example uses these style in html code...
<div id="codebox">
<p>
"normal" text here
</p>
<p class="highlight">
"highlight" text here.
</p>
</div>
CSS Comments:
In CSS a comments start with /* and end with */ sign.
Comments can span multiple lines but may not be nested.
Example:
/* This is one line comment */
/* This is multiple
lines comments */
0 comments :