Has Selector, Two Years On
:has() lets a card style itself based on what it contains.
Patterns we use
Our rule of thumb: if we cannot explain a choice in one sentence to a client, we probably should not ship it.
- Cards without images get a taller title
- Forms highlight the field with an error
- Lists change layout when they hold one item
Borders do a lot of quiet work. They separate content, show what can be clicked and give the eye somewhere to rest.
We waited fifteen years for a parent selector and it was worth it.
Performance was not the goal, but it came along anyway. Fewer styles, fewer scripts and fewer images add up quickly.
The first version looked plain. The second version looked busy. The third version, with half the details removed, is the one we kept.
We asked a few readers to try it with a keyboard only. Two of them found problems in under a minute, which is exactly why we asked.
8 thoughts on “Has Selector, Two Years On”
The list in the middle is worth the whole post.
Good question. We cover that in a follow-up post soon.
Finally someone says it plainly. Thank you.
Printed this out and pinned it above my desk.
Yes! Especially on phones.
This is exactly the kind of post that keeps me reading this blog.
This is exactly the kind of post that keeps me reading this blog.
Tried it in Safari and it works perfectly.