Apply CSS

Grouping of Selectors
We can group selectors. Separate each selector with a comma.

h1,h2,h3,h4,h5,h6
{
color:red;
font-size:12px;
}

This css class will show all headers in red color with font size 12px.

 

Apply  Styles to Elements with Particular Attributes
You can also apply styles to HTML elements with particular attributes.
The style rule below will match all input elements that have a type attribute with a value of "text":

input[type="text"] {background-color:yellow;font-size:11px;}

The id Selector
You can also define styles for HTML elements with the id selector. The id selector is defined as a #.
The style rule below will match the element that has an id attribute with a value of "green":

#green {color:green}

The style rule below will match the p element that has an id with a value of "para1":

p#para1
{
text-align:center;
color:red
}

Note: Never start an ID name with a number it will not work in Mozilla/Firefox.

CSS Comments
A CSS comment begins with "/*", and ends with "*/"
/*This is a comment*/
p
{
text-align:center;
/*This is another comment*/
color:black;
font-family:arial
}