:active
Quick Summary for :active
The :active CSS pseudo-class represents an element (such as a button) that is being activated by the user. When using a mouse, "activation" typically starts when the user presses down the primary mouse button.
Code Usage for :active
/* Selects any <a> that is being activated */ a:active {   color: red; } 
More Details for :active

:active

The :active CSS pseudo-class represents an element (such as a button) that is being activated by the user. When using a mouse, "activation" typically starts when the user presses down the primary mouse button.

/* Selects any <a> that is being activated */ a:active {   color: red; } 

The :active pseudo-class is commonly used on <a> and <button> elements. Other common targets of this pseudo-class include elements that are contained in an activated element, and form elements that are being activated through their associated <label>.

Styles defined by the :active pseudo-class will be overridden by any subsequent link-related pseudo-class (:link, :hover, or :visited) that has at least equal specificity. To style links appropriately, put the :active rule after all other link-related rules, as defined by the LVHA-order: :link:visited:hover:active.

Note: On systems with multi-button mice, CSS3 specifies that the :active pseudo-class must only apply to the primary button; on right-handed mice, this is typically the leftmost button.

Syntax

:active

Examples

HTML
<p>This paragraph contains a link:   <a href="#">This link will turn red while you click on it.</a>   The paragraph will get a gray background while you click on it or the link. </p> 
CSS
a:link { color: blue; }          /* Unvisited links */ a:visited { color: purple; }     /* Visited links */ a:hover { background: yellow; }  /* Hovered links */ a:active { color: red; }         /* Active links */  p:active { background: #eee; }   /* Active paragraphs */ 
Result

Active form elements

HTML
<form>   <label for="my-button">My button: </label>   <button id="my-button" type="button">Try Clicking Me or My Label!</button> </form> 
CSS
form :active {   color: red; }  form button {   background: white; } 
Result

Specifications

Specification
HTML Standard # selector-active
Selectors Level 4 # the-active-pseudo

See also

Link-related pseudo-classes: :link, :visited, and :hover Select your preferred language English (US)DeutschEspañolFrançais日本語한국어PolskiPortuguês (do Brasil)Русский中文 (简体) Change language

No Items Found.

Add Comment
Type in a Nick Name here
 
Other Categories in CSS
css
Search CSS
Search CSS by entering your search text above.
Welcome

This is my test area for webdev. I keep a collection of code here, mostly for my reference. Also if i find a good link, i usually add it here and then forget about it. more...

You could also follow me on twitter. I have a couple of youtube channels if you want to see some video related content. RuneScape 3, Minecraft and also a coding channel here Web Dev.

If you found something useful or like my work, you can buy me a coffee here. Mmm Coffee. ☕

❤️👩‍💻🎮

🪦 2000 - 16 Oct 2022 - Boots
Random Quote
Why did Odeo fail? Lack of Focus
Evan Williams, co-founder of Twitter and Blogger, failed with his first startup, Odeo. What went wrong with Odeo? Williams' first startup was a podcasting company that failed due to a lack of focus. He learned that it's important to stay focused and adapt to changes in the market.
Odeo
Random CSS Property

inherit

The inherit CSS keyword causes the element for which it is specified to take the computed value of the property from its parent element. It can be applied to any CSS property, including the CSS shorthand all.
inherit css reference