Selector Grouping

DataMine
by DataMine · 4 posts
11 years ago in HTML & CSS
Posted 11 years ago · Author
This is a short tutorial on Selector Grouping. Selector Grouping is the process in which you assigned multiple Selectors to a Declaration block. Selector Grouping is very useful for cleaning up your code, making it easier to work with and making it easier for other people to read/understand.

Selector Grouping allows you to use the same block of css code on multiple selectors saving you from having to re write that block of css code over an over again. So if you find that multiple parts of your web page share the same code, Selector Grouping is something to look into.

To group multiple selectors together, separate them with commas before the declaration block.

Below is an example of Selector Grouping:
Code
h1, h2, h3 { color: green; }


The above code does the exact same thing as this:
Code
h1 { color: green }
h2 { color: green }
h3 { color: green }


As you can see, the code with Selector Grouping applied is much smaller and simpler to read and work with. Selector Grouping is just one of the many practices a good coder will learn.

Create an account or sign in to comment

You need to be a member in order to leave a comment

Sign in

Already have an account? Sign in here

SIGN IN NOW

Create an account

Sign up for a new account in our community. It's easy!

REGISTER A NEW ACCOUNT