lols
lols

Reputation: 267

Change Color of Link

I have a link inside a DIV. How can I change the color of this link inside this div. This code does not seem to work

<style type="text/css">
.someDiv
{

    font-size:14px;            
    color:#c62e16;
}
</style>

<div id="someDiv">
<a href="http://www.some.com" id="someLink">SOne Text</a> 
</div>

Thanks.

Upvotes: 0

Views: 386

Answers (5)

Ross
Ross

Reputation: 46987

While you're using the wrong selector for someDiv you will usually need to set a colours separately:

 #someDiv, #someDiv a {
     color: red;
 }

Upvotes: 0

user36457
user36457

Reputation:

ids are accessed by a pound sign (#), and classes are accessed by a period (.)

<style type="text/css">
#someDiv a
{
    font-size:14px;            
    color:#c62e16;
}
</style>

<div id="someDiv">
<a href="http://www.some.com" id="someLink">SOne Text</a> 
</div>

Upvotes: 10

Stefan Konno
Stefan Konno

Reputation:

div#someDiv a{
 color: #hexcode;
}

That will work too, you use the selector to select ALL the elements of the type "a" in a div with the id="someDiv".

Upvotes: 0

waqasahmed
waqasahmed

Reputation: 3825

use

.someDiv a {

   font-size:14px;
   color:#c62e16;
}

Upvotes: 1

Stefano Verna
Stefano Verna

Reputation: 642

You are using the wrong selector. You have an id="someLink", and the CSS is looking for the class="someLink". Try with #someLink, it'll work.

Upvotes: 0

Related Questions