-
Notifications
You must be signed in to change notification settings - Fork 756
Closed
Description
To style a <progress> element based on its value, it's possible to use a selector like this (demo on CodePen):
progress[value="50"] { /* ✅ Works */
accent-color: lime;
}For <select> elements that's not possible, though:
select[value="1"] { /* ❌ Doesn't work */
…
}We can work around this using :has() (demo on CodePen, use Safari TP):
select:has(option[value="1"]:checked) { /* ✅ Works */
…
}Would be nice if select[value="…"] worked as well, as it's easier to use. It's also a less specific selector of (0,1,1) (vs (0,2,2) using :has()).
I know that value is not an attribute of <select>, but perhaps this could be exposed similar to how JavaScript makes document.querySelector('select').value work?
lukewarlow, argyleink and teacherbuknoy
Metadata
Metadata
Assignees
Labels
No labels