1 reply [Last post]
colorrush
colorrush's picture
Offline
newbie
Last seen: 4 years 37 weeks ago
Timezone: GMT+1
Joined: 2016-01-29
Posts: 1
Points: 2

Hello!

Let's say you have a div where there for example is some text in h2, h3 and p tags. Let's say you want to style the h2's and the h3's the same way. If the div class is "container" - the way I would do it now is:

.container h2, .container h3 {
font-size: 16px;
{

But then I thought, that the ".container" part is there two times.

Is there a smarter way to write it, so that you only write .container once to make the code as short as possible?

Thanks! Smile

gary.turner
gary.turner's picture
Offline
Moderator
Dallas
Last seen: 5 hours 10 min ago
Dallas
Timezone: GMT-5
Joined: 2004-06-25
Posts: 9772
Points: 3854

Why?

I suppose you could use some sort of pre-processor. Of course, that only adds a layer of abstraction that requires you to learn and use another syntax. In the end, your new complication is re-written back to the same syntax you're complaining about.

You'd be messing with the very fabric of time and space and more importantly, making debugging and maintenance more expensive.

CSS is what it is for very good reasons.

gary

If your web page is as clever as you can make it, it's probably too clever for you to debug or maintain.