
- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
Selects all <div> elements and all <p> elements with CSS
To style, more than one element, use a comma. Separate each element with the comma to achieve this. You can try to run the following code to select <div> and <p> elements,
Example
<!DOCTYPE html> <html> <head> <style> div, p { color: blue; background-color: orange; } </style> </head> <body> <h1>Demo Website</h1> <h2>Fruits</h2> <p>Fruits are good for health.</p> <div> <p>This is demo text.</p> </div> </body> </html>
- Related Questions & Answers
- Selects all <p> elements inside <div> elements with CSS
- Selects all <p> elements that are placed immediately after <div> elements with CSS
- Selects all <p> elements where the parent is a <div> element with CSS
- Selects specific elements like <p> with CSS
- Selects every <ul> element that are preceded by a <p> element with CSS
- Style all <input> elements with a valid value with CSS
- Style all <input> elements with an invalid value with CSS
- Selects all elements with CSS
- How to horizontally center a <div> in another <div>?
- Are new HTML5 elements like <section> and <article> useless?
- '></a></li></ul><i>xssi</i>
- Style every <p> element that is the only <p> element of its parent with CSS
- Style every <p> element that is the first <p> element of its parent with CSS
- Style every <p> element that is the last <p> element of its parent with CSS
- Style every <p> element that is the nth <p> element of its parent with CSS
Advertisements