I have some generated CSS and would like to use some css that could select e.g.
<p id="loremIndexIpsum">Text in here</p>
Using on lorem
and Ipsum
disregarding Index
. Something similar to:
p#lorem*Ipsum { }
I can generate some more classes, but wondered if this was possible with CSS.
Wildcard selectors allow you to select multiple matching elements. In CSS, three wildcard selectors exist i.e. $, ^, and * The * wildcard is known as the containing wildcard since it selects elements containing the set value. With the ^ wildcard, you get to select elements whose attribute value starts with the set ...
Wildcard selector is used to select multiple elements simultaneously. It selects similar type of class name or attribute and use CSS property. * wildcard also known as containing wildcard.
The [attribute*="value"] selector is used to select elements whose attribute value contains a specified value.
Your answerAsterisk (*): It is used for replacing 1 or more characters from a selector attribute.
You can't use a wildcard like that, but to get the desired result (ID starts with lorem
and ends with Ipsum
) you can use the attribute starts-with and ends-with selectors instead, like so:
p[id^="lorem"][id$="Ipsum"]
Remember that by linking multiple attribute selectors like this (along with the p
type selector), you're doing an AND match with all of them on the same element.
jsFiddle demo
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With