Pseudoclases
A veces, XHTML da algunas etiquetas a su propio estilo: por ejemplo, los enlaces están por defecto coloreados y subrayados. Estos elementos son pseudoclase. Por ahora, sólo se definen para <a> etiquetas.
Esto define un estilo para una pseudoclase:
etiqueta:pseudoclase {propapiedad1:valor;...;propiedadN:valor}
Por ejemplo, si nos gustaría ver todos los enlaces sin estrés, definiríamos estos estilos:
a:link,a:visited,a:active {text-decoration:none}
Las pseudoclases se puede utilizar junto con las clases, sólo para aplicar este estilo a casos específicos, siguiendo esta notación:
a.NombreClase:pseudoclase
y también se puede utilizar de acuerdo con el contexto.
Special for links are that they can be styled differently depending on what state they are in.
The four links states are:
a:link {color:#FF0000;} /* unvisited link */
a:visited {color:#00FF00;} /* visited link */
a:hover {color:#FF00FF;} /* mouse over link */
a:active {color:#0000FF;} /* selected link */
When setting the style for several link states, there are some order rules:
In the example above the link changes color depending on what state it is in.
Lets go through some of the other common ways to style links:
The text-decoration property is mostly used to remove underlines from links:
a:link {text-decoration:none;}
a:visited {text-decoration:none;}
a:hover {text-decoration:underline;}
a:active {text-decoration:underline;}
The background-color property specifies the background color for links:
a:link {background-color:#B2FF99;}
a:visited {background-color:#FFFF85;}
a:hover {background-color:#FF704D;}
a:active {background-color:#FF704D;}
Add different styles to hyperlinks
This example demonstrates how to add other styles to hyperlinks.
This example demonstrates a more advanced example where we combine several CSS properties to display links as boxes.
Ejercicio 25
Definir las reglas CSS que permiten mostrar 4 enlaces con los siguientes estilos:
#CC0000
.#CC0000
y la letra de color blanco #FFF
.#CCC
. con color de fondo verde claro.