Reputation: 267
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
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
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
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
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