How to change the link color in a specific class for a div CSS

208,329

Solution 1

.register a:link{
    color:#FFFFFF;
}

Solution 2

It can be something like this:

a.register:link { color:#FFF; text-decoration:none; font-weight:normal; }
a.register:visited { color: #FFF; text-decoration:none; font-weight:normal; }
a.register:hover { color: #FFF; text-decoration:underline; font-weight:normal; }
a.register:active { color: #FFF; text-decoration:none; font-weight:normal; }

Solution 3

how about something like this ...

a.register:link{
    color:#FFFFFF;
}

Solution 4

I think there is a confusion about what the OP is actually asking.

This solution:

a.register:link {color:#FFF}

...changes the color of a link whose class is "register". But that's not what the OP was asking.

And this solution:

.register a:link {color:#FFFFFF;}

...changes the color of a link that itself has no class but is placed inside of a div with class "register". And that's what the OP was asking.

Both of these answers are being upvoted here but only the second one is correct answer to the original question.

Solution 5

#register a:link
{
color:#fffff;
}
Share:
208,329
Anil Jain
Author by

Anil Jain

Updated on July 09, 2022

Comments

  • Anil Jain
    Anil Jain almost 2 years

    In my Page the following CSS is set:

    a:link {
        color: #0094DE;
        text-decoration: none;
    
    
    }
    a:visited {
            text-decoration: none;
    color: #0094DE;
    
    }
    a:hover {
    text-decoration: underline;
    color: #DD127B;
    
    }
    

    I want to Change the Link color inside a div which has a class assigned to it. I tried the following :

    register:link{color:#FFFFFF;
            }
    

    Where register is the name of the div in which i want to change the link color. How can i do that? Also how to change the color for hover link over the same div?

  • carrabino
    carrabino over 10 years
    note that this should be #register, not .register ... the OP said div not class
  • Nels Beckman
    Nels Beckman over 9 years
    @Anthony The OP said div with a class assigned to it. Does what you say still apply?
  • carrabino
    carrabino over 9 years
    OP: "Where register is the name of the div in which i want to change the link color" ... which to me says register is the id value, not the name of a class that's been assigned to the div.
  • Ryan S
    Ryan S over 8 years
    This is actually the problem I was trying to solve: this places styling on something like this: <a class="register">click me</a> Thanks!
  • ZeekLTK
    ZeekLTK over 7 years
    The top voted answer did not work for me, but using this syntax did work. Voting for this one.
  • Magiranu
    Magiranu over 6 years
    Same for me too. +1
  • Magiranu
    Magiranu over 6 years
    This answer doesn't work for multiple users. See stackoverflow.com/a/30296997/8314623 for a different solution.
  • JenVander
    JenVander about 6 years
    This was the only syntax that worked for me as well. Thanks so much!
  • Aditya P Bhatt
    Aditya P Bhatt about 6 years
    @JenVander thanks for your motivation :) it helps a lot!
  • Adam
    Adam about 3 years
    Thank you for your answer! Make sure you take a look at the other answers in the thread as well before submitting. It looks like this answer is the same as the current top voted but was determined to not be the final working solution.
  • fuxoft
    fuxoft about 3 years
    Currently the most upvoted answer is correct and the second most upvoted answer is wrong but it's getting upvoted and praised anyway because it's correct for people who are trying to solve different problem than the OP posed. That's why I posted this to hopefully clear the confusion.
  • ZioBit
    ZioBit over 2 years
    I can confirm I had the same problem with the top voted, this one worked immediately