Is there a way to select all custom elements with CSS? I want to make all custom elements block elements by default (most browsers make them inline by default), and then override this as necessary.
My rule may look something like this:
*::custom {
display: block;
}
All custom elements have dashes in the standard, so I could create a rule taking advantage of that, but it would be slower on many/most current browsers, as it would need to use regular expressions. If there were a built-in selector, this would probably be faster.
No, there isn't a pseudo selector to do that.
One certainly not optimal solution, however, would be to use this type of CSS:
It would work! On the down side if ever new elements are added you need to add that element into your not-selector. Yay.
^.^
You can simply use css like below:
I have tested this in Firefox and Chrome. Not sure about actual compatibility though. Please test on your environments.
Add an inert custom attribute to your custom elements: