My question is as follows:
Is there any way to just select a css tag with css only when it is clicked / clicked.
My question is as follows:
Is there any way to just select a css tag with css only when it is clicked / clicked.
When you click on the input, it receives the status of :focus
:
input[type=submit]:focus {
color: red;
}
Editing: As reported in Hugo's response,
:active
occurs when button is clicked.:focus
may occur when the button is clicked, via TAB key or via script.
When the focus is removed it returns to the original state.
Example:
input[type=submit]:focus {
color: red;
}
<input type="submit">
I think I understood the question differently, I believe he wants to "fire" some property on the click. And in that case it would be with :active
Hereisthecodefortheimageabove:
[type="submit"]:active {
box-shadow: none;
transition: box-shadow 100ms;
}
[type="submit"]:active {
box-shadow: 0 0 20px red;
}
<input type="submit" value="Clique aqui">
OBS
Any element can receive a :active
The pseudo-classThe% pseudo-class is also typically matched when using the keyboard key tab. It is frequently used on
:active
and<a>
HTML elements, but may not be limited to just those
<button>
is also commonly used when using the keyboard tab key. It is often used in HTML elements :active
and <a>
, but may not be limited just them. "
Source: link