Reputation: 11355
So I have this div called top nav, i.e.:
<div id="topnav">
And I would like to style all of the A
elements under this div, however NOT the A
elements outside of this div.
How would I go about that in CSS?
Upvotes: 0
Views: 72
Reputation: 2904
if you want this to all the elements inside the div, it must be...
jquery
$('#topnav a').css('color', 'red')
css
#topnav a {
color:red;
}
Upvotes: 0
Reputation: 344803
Specify a
as a descendant of #topnav
in the selector:
#topnav a {
/* styles */
}
See http://www.w3.org/TR/CSS2/selector.html#descendant-selectors.
Upvotes: 5
Reputation: 7458
I'd say a simple #topnav a
selector would do.
Edit: sorry I misread. I thought you wanted to style all the elements under it, not just the <a>
elements. Fixed.
Upvotes: 1