tags:

views:

20

answers:

3

My code creates CSS divs with dynamic names

i.e.
  cke_record_body_19
  cke_record_body_54

Is it possible to style all divs that contain the string cke_record_body_ in their name using CSS?

+2  A: 

Can you just have your code give these divs a class="cke_record_body" attribute? Then you can just apply a style to them however you want and ignore the ids.

If you really have to this should work:

div[id*="cke_record_body_"] {

}

Keep in mind I believe this is CSS3 so I have no idea what current support is, but really this is the only way to do it in straight CSS without other libraries. If you are using jQuery or something see Nealv's answer.

jwsample
Doesn't work in IE6.
Gert G
Its not going to work in much, but if he's talking straight CSS there isn't really away unless he adds class attributes or a jQuery like library.
jwsample
thanks a lot - this technique actually works fine - i am however, going to use the JS approach suggested by Nealv as my admin pages already rely heavily on prototypejs - thanks again as this technique will possibly be of use to me in other projects
stephenmurdoch
+1  A: 

sure:

$("[id^=cke_record_body]*").something()

Nealv
I don't think he's using jQuery
jwsample
Thanks, I hadn't even thought of using JS for this, and since I have prototype installed, I will just use this approach - thankyou
stephenmurdoch
+2  A: 

The best cross browser solution is to style them by adding a class to each div.

Gert G
yeah, if I hack around with the code for ckEditor, I'm sure I could apply a classname - if it wasn't for the fact that both Nealv and jwsample's suggestions work, then I'd probably do just that :) thanks
stephenmurdoch