Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

CSS – Selectors with class for several labels

There is any way to simplify this code? I want to change the color to the child labels with the class "container-quill"

 <style>
        .container-quill p {
          color: black !important;
        }
    
        .container-quill h1 {
          color: black !important;
        }
    
      </style>
    
    <div id="editor" class="container-quill">
      <p></p>
      <h1><h1/>
     </div>

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Here you go with :is(...selectors):

.container-quill :is(p, h1) { 
  color: black !important; 
}

which is the modern version of

.container-quill p,
.container-quill h1 { 
  color: black !important; 
}

Depending on your specificity needs you can also consider :where(...selectors), which doesn’t add anything to the specificity of the full selector it’s used in, but in your case doesn’t make much sense since you are applying your rules no-matter-what by stating !important anyway:

.container-quill :where(p, h1) { 
  color: black !important; 
}

Browser support:

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading