Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to style an element wit random css id

I want to style an Id from an external form rendered (javascript) on my site. Problem is that the ID is random like this:

  1. page refresh one: div#4-register-form-container57287c94e2312
  2. page refresh two: div#4-register-form-container35469e56e2278
  3. page refresh tree: div#4-register-form-container6575c98e1274
  4. page refresh four: div#4-register-form-container25242e33e6584
  5. and so on...

If I try to style it without that the random number it won't works... Is it possible to style it?

like image 434
bpy Avatar asked Dec 14 '25 20:12

bpy


1 Answers

you can use the starts-with ^= operator and group the id in []:-

div[id^="4-register-form-container"] {
  height: 50px;
  border: 1px solid red;
}
<div id="4-register-form-container25242e33e6584">

</div>
like image 144
BenG Avatar answered Dec 17 '25 12:12

BenG



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!