Target children without repeating selector

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

I do not want to do:

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

Is it possible:

 section#contact form, ul { ... } 
+5
source share
1 answer

Is it possible: section#contact form, ul { ... } ?

No, you can’t. You need to undo the entire CSS path if you do not want the style applied outside the section#contact element.

BUT

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

 section#contact * { ... } 

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

 section#contact > * { ... } 
+5
source

Source: https://habr.com/ru/post/1239139/


All Articles