Example
Set for all divs with ids starting obj_
a black background color.
Is this possible just using CSS ?
EDIT
Ups I wrote class name in the title byt I ment Id name..
This is not possible with CSS selectors. But you could use two classes instead of one, e.g. status and important instead of status-important.
The CSS id Selector To select an element with a specific id, write a hash (#) character, followed by the id of the element.
A CSS ID selector uses the ID attribute of an HTML element to select one unique element on a page. To use an ID selector in CSS, you simply write a hashtag (#) followed by the ID of the element. Then put the style properties you want to apply to the element in brackets.
The #id selector allows you to target an element by referencing the id HTML attribute. Similar to how class attributes are denoted in CSS with a “period” ( . ) before the class name, ID attributes are prefixed with an “octothorpe” ( # ), more commonly known as a “hash” or “pound sign”.
Using the CSS3 attribute-starts-with selector:
div[id^="obj_"] {
background: #000
}
This will work in all modern browsers.
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