Select the id that begins and ends with certain values

CSS selectors have gone a long way from their beginnings. Today you have multiple choices to select elements in the page.
Today I needed to select all the elements with the id matching this regex:


But CSS doesn’t let regex. To do this, you can combine these two attribute selectors:

[id^=value] // Element with the id beginning with "value"
[id$=value] // Element with the id ending with "value"

So we have:

div[id^=fixed_string_][id$=_digit] {
  color: red;


Leave a Reply

Your email address will not be published. Required fields are marked *