Is it possible to have a regex in CSS Selector for a tag?
3 answers
For attributes, yes you can. But for elements, you can separate the values by commas. W3 CSS Selectors
Selector Example Description CSS
element1,element2 h1,h2 Selects every <ul> element that are preceded by a <p> element 3
[attribute~=value] [title~=flower] Selects all elements with a title attribute containing the word "flower" 2
[attribute|=value] [lang|=en] Selects all elements with a lang attribute value starting with "en" 2
[attribute^=value] a[href^="https"] Selects every <a> element whose href attribute value begins with "https" 3
[attribute$=value] a[href$=".pdf"] Selects every <a> element whose href attribute value ends with ".pdf" 3
[attribute*=value] a[href*="w3schools"] Selects every <a> element whose href attribute value contains the substring "w3schools" 3
+1
source to share
Use a comma-separated list of selectors. Use a selector for your case h2, h3
. See the W3C Recommendation for details .
+2
source to share