I have DIV ids in an application that are generated dynamically, with an ID at the end. For example: <div id="vote_score_72">
, <div id="vote_score_73">
, <div id="vote_score_74">
and so on.
How can I write that id in the CSS file so I can apply a style to it?
Further to the suggestion that you should use classes for this functionality (and you should), you can, instead, use the attribute-value-begins-with selector (this may not be the formal name):
div[id^=vote_score] {
color: #f00;
/* and so on... */
}
JS Fiddle demo.
References:
You should add a common class to all these elements and use this class in your CSS.
Classes are the best way to handle common style for different elements.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With