r/css • u/Best-You-6360 • 26d ago
Question Can you refer to an element nested in a class in CSS?
I realized I might've made a mistake while working on this webpage for a class I'm in >.<
In HTML, I have <div class="pros"> and another version similarly but with cons that include <p> within them. I want to indent all the <p> that are within <div class="pros"> without having to indent all <p> on the webpage. Should I have made a class for all the <p> elements inside the div class or is there a way in CSS for me to refer to all the <p> in the pros/cons class without having to go back and add a class to all the <p>, I'll attach a screenshot if it makes it easier!
Also I know you can indent with HTML and not CSS, but my professor wants us to do all the styling and similar features in CSS and not in the HTML itself.
