user621819
user621819

Reputation:

Target children without repeating selector

I'm trying to apply style { border: 0; padding:0; margin: 0; } to all elements in a <section id="contact">

I don't want to do:

section#contact form { whatever style }
section#contact ul { whatever style }
section#contact p { whatever style }

Can I do:

section#contact form, ul { ... }

Upvotes: 5

Views: 88

Answers (1)

web-tiki
web-tiki

Reputation: 103810

Can I do: section#contact form, ul { ... } ?

No you can't. You need to refence the whole CSS path if you don't want the style to apply outside the section#contact element.

BUT

If you want to apply the style to all the children (and grand-children) elements, you can use the universal selector :

section#contact * { ... }

If you want to apply the style only to the direct children, you can use the direct child selector :

section#contact > * { ... }

Upvotes: 5

Related Questions