Select all the h tag inside a class

Body picture Body · Jan 25, 2013 · Viewed 13.4k times · Source

Instead of writing the CSS code like,

.dark h1, 
.dark h2, 
.dark h3, 
.dark h4, 
.dark h5, 
.dark h6 {

}

Is there any short way to this like [class*="blah"]?

Regards.

Answer

Zeta picture Zeta · Jan 25, 2013

No, since attribute selectors work only on, well, attributes. You can't use a regular expression or something similar for element names. Certain systems like LESS or SASS enable you to write such expressions with less code, however there is no such thing in native CSS.