You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The :active pseudo-class applies while an element is being activated by the user. For example, between the times the user presses the mouse button and releases it.
The :active pseudo-class is useful for providing immediate feedback about the expected click behavior of an element.
There is a keyboard limitation to the :active pseudo-class that many sources do not mention. Between the time a user presses the spacebar and releases it, the :active pseudo-class is only ever applied to a <button> element. Some resources may even suggest that the pointer-triggered :active and the keyboard-triggered :active should always work the same.
It is my belief that :active state is equally valuable to style for both keyboard and the pointer interactions.
Should the :active pseudo-class apply to any active element between the times the user presses the spacebar and releases it?
I think opening this behavior up to all elements should be considered, or perhaps alongside some other mechanism like :focusable.
I do not know for certain why :active does not behave this way already, but I suspect it is related to the early WWW distinctions between hyperlinks and buttons, similar to how a spacebar press-and-release does not “click” a hyperlink. This is a problematic guess, tho, since the :active state applies to non-clickable elements when used with a pointer.
I was confused by a note in the specification that reads “there may be document-language or implementation-specific limits on which elements can become :active.” This note links to the HTML5 specification which defines a list of activatable elements. However, the HTML5 specification does not list any special criteria for spacebar interaction, and the criteria for :active — which includes “if the element is focusable” — suggests to me that it could apply to any element activated.
The text was updated successfully, but these errors were encountered:
From the Selectors Level 4 specification
The
:active
pseudo-class is useful for providing immediate feedback about the expected click behavior of an element.Its usage is well documented, in sources from Adobe, Google, Salesforce, Tailwind, and CSS Tricks.
The
:active
pseudo-class is versatile for pointers, in that it is not limited to specific elements.Example from MDN:
There is a keyboard limitation to the
:active
pseudo-class that many sources do not mention. Between the time a user presses the spacebar and releases it, the:active
pseudo-class is only ever applied to a<button>
element. Some resources may even suggest that the pointer-triggered:active
and the keyboard-triggered:active
should always work the same.It is my belief that
:active
state is equally valuable to style for both keyboard and the pointer interactions.Should the
:active
pseudo-class apply to any active element between the times the user presses the spacebar and releases it?I think opening this behavior up to all elements should be considered, or perhaps alongside some other mechanism like
:focusable
.I do not know for certain why
:active
does not behave this way already, but I suspect it is related to the early WWW distinctions between hyperlinks and buttons, similar to how a spacebar press-and-release does not “click” a hyperlink. This is a problematic guess, tho, since the:active
state applies to non-clickable elements when used with a pointer.I was confused by a note in the specification that reads “there may be document-language or implementation-specific limits on which elements can become
:active
.” This note links to the HTML5 specification which defines a list of activatable elements. However, the HTML5 specification does not list any special criteria for spacebar interaction, and the criteria for:active
— which includes “if the element is focusable” — suggests to me that it could apply to any element activated.The text was updated successfully, but these errors were encountered: