- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Grouping Selectors in CSS
The CSS grouping selector is used to select multiple elements and style them together. This reduces the code and extra effort to declare common styles for each element. To group selectors, each selector is separated by a space.
Syntax
The syntax for CSS grouping selector is as follows −
element, element { /*declarations*/ }
The following examples illustrate CSS grouping selector −
Example
<!DOCTYPE html> <html> <head> <style> article, p, img { display: block; margin: auto; text-align: center; border-bottom: double orange; } </style> </head> <body> <article>Demo Text</article> <p>This is demo text.</p> <br/> <img src="https://www.tutorialspoint.com/swing/images/swing.jpg"> </body> </html>
Output
This gives the following output −
Example
<!DOCTYPE html> <html> <head> <style> div::after,p::after{ content: "Demo text"; margin: 4px; box-shadow: inset 0 0 4px darkorange; } </style> </head> <body> <div></div> <p>This is example text.</p> </body> </html>
Output
This gives the following output −
Advertisements