Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

CSS: How to target all elements within a given ID

Tags:

css

Instead of doing the following to give a text color to all elements on the page:

* {color: red;}

Is there a way to only apply it to all elements within a certain id? Something like this:

#container * {color: red;}
like image 380
RandyLahey Avatar asked Feb 15 '12 21:02

RandyLahey


2 Answers

#container * {color: red;}

Should work.

If you only want direct children to get the class, try

#container>*{color: red;}

What browser are you using? (brand + version)

like image 34
mpm Avatar answered Oct 23 '22 14:10

mpm


Actually yes, exactly like you mentioned.

#container * { color: red; }
like image 176
Madara's Ghost Avatar answered Oct 23 '22 12:10

Madara's Ghost