136 days ago · Tech · hide · Fediverse post

Just a brainfart here, but it's odd that even though we have wildcard selectors throughout CSS, and even partial selectors (I'll explain in a bit) we don't have partial wildcard selectors on top level elements. I'm not talking about the "star" rule, but what I imagine would be a wildcard on elements selector. Existing methods If I want to select and style all the .btn-* classes using attribute selector, I'd do this: [class^="btn-" i] { … } This selector says: find all the elements with the class attribute that starts with "btn-" - case insensitive. It's rather brittle, because it requires that the HTML class attribute starts exactly with btn-. Though it works, it does tie the HTML closely to the CSS - which I'd argue you'd want to be very sure you need to do. But it is possible. Equally, and a lot more robust, is the wildcard that says "anywhere in the attribute", so: [class*="btn"] { … } It's fine, but it's a bit sledgehammery. However, if you want to do the same thing for a web…

Commenting on Bubbles has been removed. Why? If you want to talk about this post, write to the author, use the comments on their blog if it has them, or reply with a "RE:" post on your own blog. Suggestions? feedback@bubbles.town