---
title: "CSS4 Selectors"
url: https://deallocatedobjects.com/posts/css4-selectors
author: Jake Marsh
published: 2011-10-27
updated: 2013-11-16
link: http://dstorey.tumblr.com/post/10865123182/selectors4
topics: ["Web"]
description: "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 CSS CSS There’s tons more and David Storey does a great job of explaining stuff in his blog post."
---

# CSS4 Selectors

By Jake Marsh, October 27, 2011. HTML: https://deallocatedobjects.com/posts/css4-selectors

This is a link post about http://dstorey.tumblr.com/post/10865123182/selectors4

Looks like the [CSS Working Group](http://www.w3.org/Style/CSS/members) has published their [first working draft](http://www.w3.org/News/2011#entry-9219) 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](http://about.me/dstorey) does a great job of explaining stuff in [his blog post](http://dstorey.tumblr.com/post/10865123182/selectors4).
