How to remove underline from a link and add underline on hover? (images attached)

12,291

Solution 1

You need to turn off the CSS property text-decoration for the link and then use the :hover dynamic pseudo class to add the text-decoration back when hovering.

a {
    text-decoration:none;
}

a:hover {
   text-decoration:underline;
}

Demo

Also, you might also need to style the :visited:hover pseudo class so that the underline appears on links a user has already visited. link order in css is a good answer because the order of the CSS rules matters.

Solution 2

Assuming your login link has the id login...

#login {
   text-decoration: none;
}

#login:hover {
   text-decoration: underline;
}
Share:
12,291

Related videos on Youtube

sumit
Author by

sumit

Updated on June 01, 2022

Comments

  • sumit
    sumit about 2 years

    I want underline to be removed from a link. Also I want underline to appear when I hover it with my mouse pointer. How can this be done? Pls help.

    No hover: NO Hover - Normal link

    When I hover the Login link: When I hover the Login link