What makes this selector even more useful is when we combine it with :notto identify external links:
You can even use it to add an icon to clearly indicate which links will direct the user to an external site. With CSS level 4, we can style the indeterminate state as well —
The pseudoclass can also be used to style the indeterminate state of progress element when no value attribute is included. CSS is becoming a kind of Swiss Army knife for the web. For example, if we want to apply the same link colour to the different states of an anchor, we can simply do:
This is a cleaner way of writing the same rule without :matches. So start experimenting! Times are changing. They are used for targeting timedimensional elements such as during speech rendering of a HTML document. We can already use a range of helpful selectors such as :nthchild, :nthoftype and :not() to target specific DOM elements. One thing to bear in mind is that only compound selectors are allowed as arguments, and you cannot use combinator selectors such as the sibling or descendant selectors. For example, if the address is w3c.org/standards and we have the following styles:
The link w3c.org will be red, and w3c.org/standards will be blue. At the time of writing, these selectors haven’t yet been implemented by any browsers and the specification is constantly changing – but fear not, you can use polyfills such as Sel to get a sneak peek of what these selectors are about. She loves talking to others about CSS, which has led her to co-found the meet-up group SydCSS. The good news is you can actually try out this out now – Mozilla has implemented -moz-any- which is the equivalent of :matches, and it’s been around since Firefox 4. Firstly, there’s the :matches pseudoclass. More power for developers
The ability to style form elements has become more powerful as well with the addition of the pseudoclass :indeterminate. With CSS level 4 selectors, there will be an extra layer of power. For example, we can use :currentto render text that is currently being rendered in HTML5 video subtitles:
If we want to target previously rendered element, we can use :past. It is used to identify internal links and you can pass in a number as a parameter to target the different levels of the URL.