Kaigai Blog living abroad in my twenties

【My Study Note】Practical use of pseudo

CSS Programming

Practical use of pseudo

This article is about

pseudo-classes that you can use to style links on web pages, namely web-link states.

Although, you can use web-link states for many functionalities, developers often use them to style the color of links that a user already opened.

Example

a:link {
   color: blue;
}
a:visited {
   color: purpole;
}

But if you’re using multiple pseudo-classes for a specific element, there is an important rule to keep in mind.

The order in which you apply pseudo-classes in a document determines which style will be displayed. So be careful not to accidentally overwrite a style you want to set.

Developers use the acronym LVHA to remind them of the order that they need to follow when writing pseudo-class rules.

LVHA stands for link, visited, hover, active. So always apply pseudo-class styles in the correct order.

First link, then visited, next hover, and lastly active.