Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Comma separated selectors

Tags:

html

css

I'm having a bit of a hard time explaining what I want to do. Here's my CSS code:

div#addannouncmentdiv form button,input,textarea{
    width:50%;
}

But for some reason the inputs and the text areas even not in the div#addannouncmentdiv form still have the 50% width property. I know I can do this:

div#addannouncmentdiv form button,div#addannouncmentdiv form input,div#addannouncmentdiv form textarea{
    width: 50%;
}

But is there a shorter way than writing the div#addannouncmentdiv form every time again and again?

like image 245
NonameSL Avatar asked Jun 21 '26 09:06

NonameSL


1 Answers

This can't be done in the current version of CSS. What you're looking for is a CSS Pre-Processor like SaSS or LESS.

SaSS / LESS

div#addannouncmentdiv form {
    button, input, textarea {
        width: 50%;
    }
}

Edit:

As @Mr.Alien says. This can be cleaned up to:

#addannouncmentdiv {
    button, input, textarea {
        width: 50%;
    }
}
like image 170
micah Avatar answered Jun 24 '26 00:06

micah



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!