Jump to content

grouped selector in css


clarkson

Recommended Posts

I learnt that there are 5 type of selectors.

  1. Id selector
  2. class selector
  3. grouped selector
  4. context selector,
  5. 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

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

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 by newseed
Link to comment
Share on other sites

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...