Select the id that begins and ends with certain values

Published on

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:
<br /> [id^=value] // Element with the id beginning with "value"<br /> [id$=value] // Element with the id ending with "value"<br />
So we have:

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