views:

71

answers:

4

hi,

is there a way to select multiple div with css??

like

div id="text-box4"
div id="text-box5"
div id="text-box7"

etc

+1  A: 

like this?

#text-box4, 
#text-box5, 
#text-box7 {
    /* your properties here */
}
Michael Pardo
A: 

CSS classes are designed for selecting multiple elements:

<div id="text-box4" class="my-text-box"/>
<div id="text-box5" class="my-text-box"/>
<div id="text-box7" class="my-text-box"/>
maerics
A: 

CSS doesn't have a wildcard for that.

However if you use jQuery you can:
http://api.jquery.com/attribute-contains-selector/ or
http://api.jquery.com/attribute-contains-word-selector/

<div id="text-box4"></div>
<div id="text-box5"></div>
<div id="text-box7"></div>
<script>$("div[id*='text-box']").css("color", "red");</script>
Zyphrax
ah, tx those numbers are dynamicly rendered by post-id´s. I need to make their height equal to a photo next to it.
yous
hmm, your suggestion doesn´t seem to work on id="text-box-prod7"and<script>$("div[id*='text-box-prod']").css("color", "red");</script>
yous
sorry it worked mixing things up here
yous
no problem, please mark this or one of the other answers as 'the answer'. That makes it easier for other visitors to track.
Zyphrax
A: 

maerics' answer is correct. The CSS selector used to select the divs in that case would be:

.my-text-box {
  /* Styles go here */
}
Scott Cranfill