With CSS, links can be styled in many different ways.
Links can be styled with any CSS property (e.g. color
, font-family
, background
, etc.).
In addition, links can be styled differently depending on what state they are in.
The four links states are:
a:link
- a normal, unvisited linka:visited
- a link the user has visiteda:hover
- a link when the user mouses over ita:active
- a link the moment it is clickedHere, we want to use a font named "Trirong" from Google Fonts:
When setting the style for several link states, there are some order rules:
The text-decoration
property is mostly used to remove underlines from links:
The background-color
property can be used to specify a background color for links:
This example demonstrates a more advanced example where we combine several CSS properties to display links as boxes/buttons:
This example demonstrates how to add other styles to hyperlinks:
Another example of how to create link boxes/buttons:
This example demonstrates the different types of cursors (can be useful for links):