I noticed in the Bootstrap CSS file:
input:focus:invalid:focus,
textarea:focus:invalid:focus,
select:focus:invalid:focus {
border-color: #e9322d;
-webkit-box-shadow: 0 0 6px #f8b9b7;
-moz-box-shadow: 0 0 6px #f8b9b7;
box-shadow: 0 0 6px #f8b9b7;
s}
It appears that :focus is specified twice for input, textarea, and select; does this have a particular function?
You can combine several CSS pseudo-elements for one element. However, you cannot use CSS ::after two times or ::before two times. In the example below, the first letter of <div> is green and has x-large font size.
Pseudo-classes are allowed anywhere in selectors while pseudo-elements may only be appended after the last simple selector of the selector. This means your syntax is correct according to CSS2. 1 and CSS3 as well, i.e. IE8 still sucks ;) Can I write element:hover:disable {} multiple pseudo-classes ?
What is a pseudo-class? A pseudo-class is a selector that selects elements that are in a specific state, e.g. they are the first element of their type, or they are being hovered over by the mouse pointer.
You can still chain pseudoselectors. For example, a:focus:hover works just fine to apply styles only if the element is focused AND hovered. See this link for a demonstration. It works fine (in Chrome, at least); click in the demo area, press tab to focus the link, then hover it to see it become bolded.
This increases the css selector's specificity.
Here is the relevant quote in the css
specs:
Note: Repeated occurrences of the same simple selector are allowed and do increase specificity.
So, in this particular case, input:focus:invalid:focus
will have precedence over input:focus:invalid
.
Here is a simpler example demonstrating the increase in css
specificity with repeated occurences:
css
span.color.color {
color: green;
}
span.color {
color: yellow;
}
html
<span class="color">This will be green.</span>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With