Register to Better Coder! It's free.
Enjoy the premium features and succeed at every job interview.
How can we group selectors?
Experience Level: Junior
If you have multiple selectors with the same style definition, you can save some space and merge all the styles to one. If you do this, you will get the following advantages:
- Shorter code: The resulting code will be shorter and more readable.
- Faster to download: Downloading the shorter web page will be faster and it will consume less bandwidth. Mobile users will appreciate this.
- Easier to maintain: The styles will be easier to maintain. In case some change needs to be done to the style definition, it can be done on just one place. Without the selector grouping it would be necessary to do the change on many places.
Related CSS job interview questions
What is the difference between external, embedded and inline styles?CSS Junior
How to write comments and what are they used for?CSS Junior
What is a selector and what selector types do you know?CSS Junior
Can you describe CSS syntax?CSS Junior
What problem does CSS solve?CSS Junior