CSS rules defines the properties and values of the attributes of html elements.You can apply the css rules to different html elements.You specify different html elements to which you want to apply the css rules using selectors.For example to apply the background color to table you define the following selector:
table { background-color: pink; }
Similarly to define the rule for anchor element you use
a { color: blue; }
Now if you want to specify the style of the link when user hover over it you use:
a:hover { color: red; }
The hover class we are using here is called the pseudo class.Pseudo classes are applied when the state of the element matches the state specified in the pseudo class.
Pseudo class has the following syntax:
selector:pseudo-class { property: value; }
some of the common pseudo-class are:
- :active when the user activates the element such as by pressing the mouse button
- :hover when the mouse hovers over the element
- :link when element such as anchor(‘a’) has not been visited
- :focus element which has the focus
- :enabled enabled element
- :disabled disabled element
Leave a Reply