Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Selector for all a tag descendants

Sorry if this sounds pretty basic to those who follow the css tag.

The webpage in question has multiple sections:

<section id="top"> ; <section id="tab-banner">

Within these sections there is much html with many levels of nesting.

I just want to say grab all <a> tags that are descendants of each section. E.g.

#tab-banner a { /* css here */ }

How do I say grab all elements of a certain type (a) that are descendents of elements with specific IDs?

like image 800
Doug Fir Avatar asked Jan 28 '14 15:01

Doug Fir


2 Answers

For all descendants, use:

#tab-banner *

For direct descendants, use:

#tab-banner > *

Edit:

As the op changed/clarified the question:

To find all descendants of a specific type, just use that type instead of *. Example:

#tab-banner a

So, what you are trying is correct. If the style doesn't apply to the elements that you expect, then those elements are actually not descendants of that section, or you have another rule that takes prescedence.

like image 94
Guffa Avatar answered Sep 18 '22 02:09

Guffa


Sounds like you might need the Universal selector, but I'd suggest you were more specific in how you attach your css

#tab-banner * {css here}
the star selector will append the styles to all the decendants but this isn't best practice as it has performance effects

Universal_selectors

for more help checkout this helpful article The 30 CSS Selectors you Must Memorize

like image 36
Kristian Phillip Hamilton Avatar answered Sep 21 '22 02:09

Kristian Phillip Hamilton