tags:

views:

385

answers:

2

I have a div element that has an id and this div contains a set of inputs and labels. I ONLY want to style the inputs inside this specific div but .. the following styles everything (global) instead of keeping the scope inside #ParentDiv

#ParentDiv label,input { display: inline; }

Also, is it possible to do this type of thing with valid css in IE6/7?

+17  A: 

you need this:

#ParentDiv label, #ParentDiv input { display: inline; }

A comma indicates a new selector statement.

Often, so that I remember what each of the selectors is, and to make it easier to see what elements are being selected at a glance, I will break the selectors on to separate lines like so:

#ParentDiv label,
#ParentDiv input{
    display: inline;
}

Also, this should work just fine in IE 6/7/8, and is valid according to w3c.

cdeszaq
A: 

Try

#ParentDiv label, #ParentDiv input { display: inline; }

EDIT: vote cdeszaq

StingyJack
This will find things with the classes of "label" and "input", and not elements contained in the #ParentDiv. In fact, that can only apply to one element, because only one element can have a particular ID to still be valid and well formed.
cdeszaq
Yes, you are correct... I was having a moment of stupidity and not thinking. Thanks.
StingyJack