I want state-based pseudo-classes for media elements #47
Replies: 6 comments 1 reply
-
FWIW in case someone want a base for a draft: (and some open issues) |
Beta Was this translation helpful? Give feedback.
-
From twitter:
Ref: https://twitter.com/gregwhitworth/status/1254817734367404033?s=21 |
Beta Was this translation helpful? Give feedback.
-
Additionally, :error and :loading could work for all embedded content (iframe, object). A simple use case would be to hide these on error, something that required javascript currently. |
Beta Was this translation helpful? Give feedback.
-
Some of these are addressed in CSS Selectors 4 |
Beta Was this translation helpful? Give feedback.
-
This is possible to some extent using WebVTT https://stackoverflow.com/a/39563620, https://stackoverflow.com/a/48201698. |
Beta Was this translation helpful? Give feedback.
-
Yes. There is only so much styling a video element can have. We could go so far as to use Web Components Custom Elements. It is already possible to style video elements to some extent using pseudo elements |
Beta Was this translation helpful? Give feedback.
-
Sometimes you want to style video elements differently depending on if they're playing or not. For example, in the paused state we want to show a play button on top of the
video
element, and hide that when the video starts playing. For that, it would be great if you could use CSS pseudo-classes to target the video state:That would make styling more straightforward. Currently, we have to listen to JavaScript events and conditionally set classes on the element that we can only then target with CSS.
This could further be expended with
:loading
,:stopped
and:error
pseudo-classes. The:error
class could also apply toimg
andpicture
elements if the source returns an error code or can't be found.Mozilla Firefox has some precedent here, with the
:moz-broken
and:moz-loading
pseudo-classes.https://webwewant.fyi/wants/5ea6f92ad3873ee397985e54/
Beta Was this translation helpful? Give feedback.
All reactions