2

I am currently preparing for the microsoft exam 70-480. In a praxistest I found the following question whose answer I can not explain.

Can someone explain why this is the right answer?

You are developing a web page by using HTML5 and CSS3. Hyperlinks on the page must be rendered with a style that reflects the last user action performed. You need to style the four anchor elements in the document. In what order should you specify the four anchor selectors?

Right Answer:

a:link a:visited a:hover a:active

1
  • There is just a standard rule of the order anchor styles must come in, in order for them to display/work properly -- And that answer is the correct order they must show in.
    – n_plum
    Feb 1, 2017 at 21:19

4 Answers 4

3

As in CSS and HTML5 links can be standardized to follow color coding which helps user to understand which are link is visited and which is not. technically, A:hover must be placed after the A:link and A:visited rules, since otherwise the cascading rules will hide the 'color' property of the A:hover rule. Similarly, because A:active is placed after A:hover, the active color (lime) will apply when the user both activates and hovers over the A element.

Hope this helps.

1
  • Accepted answer because completely and well explained without referring to external links. Thank you Feb 1, 2017 at 21:34
3

There are five pseudo-classes for hyperlinks and should you define rules against one or more of these, it is important that you do so in the following order:

a:link {}

a:visited {}

a:focus {}

a:hover {}

a:active {}

Referencing them in a different order may cause them to cancel each other out. One of my favorite mnemonics for remembering this order is (LVFHA - Link Visited Focus Hover Active) is Let Victoria Free Her Armies, my least favorite being LoVe For Hell's Angels, which I find rather creapy...

1
  • Nice. I personally am a fan of: Lord Vader's Handle Formerly Anakin (source)
    – Mentalist
    Aug 5, 2019 at 5:33
1

From here: In order to style appropriately links, you need to put the :visited rule after the :link rule but before the other ones, defined in the LVHA-order: :link — :visited — :hover — :active.

1
  • I understand it. Many Thanks :) Feb 1, 2017 at 21:26
1

As it states:

  • a: hover MUST come after a: link and a: visited in the CSS definition in order to be effective!
  • active MUST come after a: hover in the CSS definition in order to be effective!!

Reference: Meet the Pseudo Class Selectors; CSS Pseudo-classes

http://css-tricks.com/pseudo-class-selectors/ http://www.w3schools.com/css/css_pseudo_classes.asp

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.