1

How can I make a link be underlined that I am on at that moment. (This is in my navigation, so when I am actually visiting my "Home" or "About Us" page I want the link to be underlined, but only then. Is that possible to do with CSS? (Not JavaScript.) Thank you!

Novakron
  • 19
  • 1

2 Answers2

0

If you wanted your link to have the underline only when you hovered it. You should write something like this in your CSS:

a:hover {
    text-decoration: underline;
}

This purely adds the underline when the anchor is hovered over.

If you wanted your link to have the underline appear after you clicked it, you should write something like this in your CSS:

a:active {
    text-decoration: underline;
}
Matthias
  • 170
  • 15
  • Thank you for the answer. I actually didn't want it to underline while I hover over the link, I want it to underline when the link is being actively visited! Thank you for the attempt to answer the question, though! :) – Novakron Aug 27 '21 at 00:20
  • @Novakron Sorry I didn’t fully understand your question – Matthias Aug 27 '21 at 00:21
  • Thank so much! I will test it out tmr morning! Thank you! – Novakron Aug 27 '21 at 02:27
  • I would, but your answer still didn't fix my problem. I didn't ask for it to be underlined when the link was being clicked on, only when I was visiting the page at that moment. Thanks for trying to help, anyway! – Novakron Aug 27 '21 at 14:06
  • @Novakron sorry I didn’t quite understand but I can answer the question properly now as long as you share allyour code with me. – Matthias Aug 27 '21 at 23:50
  • @Novakron I can answer the question if you share your code with me. – Matthias Aug 29 '21 at 23:34
0

This sounds like more than just wanting to underline when the link is hovered over. Looks like the suggestion here was to add a CSS class onto each page for the link which is "the current page".