user256034
user256034

Reputation: 4369

Is it possible to set css properties by id prefix?

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..

Upvotes: 13

Views: 9248

Answers (1)

thirtydot
thirtydot

Reputation: 228162

Using the CSS3 attribute-starts-with selector:

div[id^="obj_"] {
    background: #000
}

This will work in all modern browsers.

Upvotes: 27

Related Questions