clarkson Posted June 11, 2013 Share Posted June 11, 2013 I learnt that there are 5 type of selectors. Id selector class selector grouped selector context selector, element selector In grouped selector is it possible to use only ELEMENTS seperated with comma. Can this code be considered as a grouped selector. {#form input,#form textarea{border:2px solid blue;} Also what's the difference of context selector and grouped selector? Link to comment Share on other sites More sharing options...
jeffman Posted June 11, 2013 Share Posted June 11, 2013 A grouped selector is a list of any selectors separated by commas. The individual selectors can be element selectors, class selectors, contextual selectors, whatever. Unlike the other kinds of selectors, group selectors are a kind of shorthand. So yes, your example is a group selector. Hopefully, that answer helps you understand why it is not meaningful to ask the difference between a context selector and a group selector. It's like the difference between a package and a delivery truck. Link to comment Share on other sites More sharing options...
newseed Posted June 11, 2013 Share Posted June 11, 2013 (edited) What you have is both group and context. You can almost do anything to get what you want either to define broad list of styles or a style that is specific for one element overriding the all other styles. p {color: blue;} This is the element selector. #article p {color: red;} This will override any p with the id 'article'. This is called context selector. h1, p{ color: blue;} This is group selectors #articles h1, #articles p {color: red;} This is using context and group selectors. UPDATE: Sorry, didn't mean to supersede you Deirdre Edited June 11, 2013 by newseed Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now