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?
CSS ID selector To use an ID selector in CSS, you simply write a hashtag (#) followed by the ID of the element. Then put the style properties you want to apply to the element in brackets.
You can create a selector that will target specific elements with the class applied.
The .class selector selects elements with a specific class attribute. To select elements with a specific class, write a period (.) character, followed by the name of the class. You can also specify that only specific HTML elements should be affected by a class.
Approach: Use the :not(selector), also known as negation pseudo-class which takes a simple selector as an argument and allows you to style all the elements except the element specified by the selector.
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 alphabetize and break the selectors on two separate lines like so:
#ParentDiv input, #ParentDiv label { display: inline; }
Also, this should work just fine in IE 6/7/8, and is valid according to w3c.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With