Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to select multiple ids in CSS?

Tags:

css

How can I select multiple IDs in CSS? For example:

#test_id_*{

}
<div id="test_id_10"></div>
<div id="test_id_11"></div>
like image 289
Saiful Avatar asked Aug 23 '26 20:08

Saiful


2 Answers

Use an attribute selector on the id attribute:

[id^='test_id_'] { color: red; }

Description:

[attr^=value] represents an element with an attribute name of attr and whose first value is prefixed by "value".

To use one css for multiple id or class, you need to separate them with ,

#test_id_10,
#test_id_11
{
    //some style
}
like image 41
Carl Binalla Avatar answered Aug 26 '26 04:08

Carl Binalla



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!