This post is from 2011, about 15 years ago. Some of it may be out of date.

▸ CSS4 Selectors

1 min readWeb

Jake Marsh

Looks like the CSS Working Group has published their first working draft of how they’d like CSS4 selectors to work.

Here are some of the highlights:

JavaScript
    var el = document.querySelector("#foo"); // returns first element with ID of foo
    var bar = document.querySelector(":scope > p", el); // returns equivalent of "#foo > p"
CSS
li a:matches(:link, :hover, :visited)
CSS
a:local-link /* Matches anything that links to the current page */
a:local-link(0) /* Matches any link that is the same domain */

There’s tons more and David Storey does a great job of explaining stuff in his blog post.

Link: dstorey.tumblr.com/post/10865123182/selectors4