tags:

views:

88

answers:

5

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.

+9  A: 

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>
John T
This won't work, as you need to hit the anchor tag specifically to change it's appearance. So the correct selector would be `#someDiv a`
peirix
Yes..waqasahmed answer was correct
lols
@lols referencing a class wouldn't have fixed the problem for you, you still need to change it to a pound sign or use <div class="someDiv">
John T
A: 

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.

Stefano Verna
+1  A: 

use

.someDiv a {

   font-size:14px;
   color:#c62e16;
}
waqasahmed
that did the trick!
lols
A: 
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".

A: 

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

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