css selectors - Confused by CSS pseudo-class :active -
i looking here @ css :active selector.
the :active selector styles links active pages
that got me thinking, heck 'active page' in html/css terminology...
at point went w3docs section : 5.11.3 dynamic pseudo-classes: :hover, :active, , :focus.
the :active pseudo-class applies while element being activated user. example, between times user presses mouse button , releases it.
so used 1 of w3shools try pages , hack example, substituting following code, can cut & paste , try.
<html> <head> <style type="text/css"> :focus,:active { outline-offset: 10px; outline: solid; } </style> </head> <body> <p>click links see background color become yellow:</p> <a href="http://www.w3schools.com">w3schools.com</a> <a href="http://www.wikipedia.org">wikipedia.org</a> <button type="button">click me!</button> <form> <input type="text"/> </form> </body> </html>
the form field works :focus. button or links don't work :active.
why that? there 'active page' i'm not understanding w3schools talked about.
i saw nice tip when googling it, don't think it's related.
there no concept of "active page" in css. in fact, sitepoint reference debunks saying:
the pseudo-class not signify link active, or current, page—that’s common misconception among css beginners.
what spec says right: :active
styles elements activated, e.g. clicked (as in example given) or in other way triggered such browser starts navigating link's target.
note doesn't apply <a>
elements; may apply non-form-input element that's clicked. instance, can this:
p:active { color: red; }
and paragraph click flash text red.
note exact definition , implementation left browser, in general, can rely on <a>
elements having activated state.
Comments
Post a Comment