As Quentin already said, such selectors are not available. An easy solution to this is to put the element's name also as a class name:
<my-element-one class="my-element-one"></my-element-one>
<my-element-two class="my-element-two"></my-element-two>
<div></div>
This way you could use attribute wildcard syntax, for example
[class^="my-element-"]
would target all elements that have a class attribute beginning with my-element-
.
You can also use $=
(ends with), *=
(contains) and more, check
https://developer.mozilla.org/en-US/docs/Web/CSS/Attribute_selectors
To make it more fail-safe and dedicated to the task, the best idea is probably to have a data-tagname
attribute:
<my-element-one data-tagname="my-element-one"></my-element-one>
<my-element-two data-tagname="my-element-two"></my-element-two>
This would make the starts with attribute selector variant more failsafe, since, other than class, there won't be anything additional or dynamic inside it.
[data-tagname^="my-element-"]