selector { propertyNameOne:value; propertyNameTwo:value; }
p { color: red; text-align: center; }
#para1 { text-align: center; color: red; }
.center { text-align: center; color: red; }
h1, h2, p { text-align: center; color: red; }
The following example selects all p elements inside div elements:
div p { background-color: yellow; }
The following example selects all p elements that are immediate children of a div element
div > p { background-color: yellow; }
The following example selects all p elements that are placed immediately after div elements:
div + p { background-color: yellow; }
The following example selects all p elements that are siblings of div elements
div ~ p { background-color: yellow; }
Select all elements, and set their background color to yellow:
* { background-color: yellow; }
It is possible to style HTML elements that have specific attributes or attribute value
input[type="text"] { width: 150px; display: block; margin-bottom: 10px; background-color: yellow; } input[type="button"] { width: 120px; margin-left: 35px; display: block; }
A pseudo-class is used to define a special state of an element.
Style an element when a user mouses over it
Style visited and unvisited links differently
Style an element when it gets focus
a:link { color: #FF0000; } /* visited link */ a:visited { color: #00FF00; } /* mouse over link */ a:hover { color: #FF00FF; } /* selected link */ a:active { color: #0000F
A CSS pseudo-element is used to style specified parts of an element.
Style the first letter, or line, of an element
Insert content before, or after, the content of an element
p::first-line { color: #ff0000; font-variant: small-caps; } p::first-letter { color: #ff0000; font-size: xx-large; }
p { text-align: center; /*color: red;*/ }
Total : 10919
Today :12
Today Visit Country :