Reputation: 375
I'm wondering if I can somehow "inherit" a class property to some elements such as body, like:
.playfont{font-family: 'Play', sans-serif;}
body{.playfont}
I know I can do this with JavaScript or LESS, or even adding the class in HTML markup, but is there any pure css way for this? Thanks.
Upvotes: 2
Views: 7743
Reputation: 800
No, but you can do like this:
<html>
<head>
<style type="text/css">
h1, .test {
color: red;
}
</style>
</head>
<body>
<h1>Test</h1>
<h2 class="test">Test</h2>
</body>
</html>
Upvotes: 0
Reputation: 55732
The closest you can come with pure CSS is like this:
.playfont,
body { /* .... rules here */ }
Other than that, you'll need a preprocessor. And the way I described above gets messy pretty fast.
Upvotes: 4