| Discover What’s New in CSS 4 |
|
Discover What’s New in CSS 4
The CSS 4 spec is brand new and no web browser actually supports any of these rules yet, but if you’re curious what the next few years will mean for CSS, the first draft offers a sneak peek at what’s in store for web developers. The biggest news in the current draft of CSS 4 is support for the much-requested parent or “subject” selector. In CSS, rules are typically applied to the innermost selected element. That is, given the chain CSS 4 includes a means of controlling which element in the selection chain is actually being styled. The easiest way to understand the “subject” selector is by example. Say you want to style a list ( With the subject selector it’s simple:
The “$” means that the rule is applied to the ul, rather than the li.clicked as it normally would. The dollar sign may not end up being the subject indicator and the exact syntax will likely change before the spec is finalized. But regardless of the way it ends up being implemented, the subject selector opens up a whole new realm of CSS possibilities. Other highlights in CSS 4 include some new pseudo selectors like the
The . The number refers to the amount of the local URL path to match. For example, if the current address is http://www.mysite.com/some/post/, CSS 4 offers some handy pseudo-classes for styling user interface elements based on state, including For more info on what’s coming in CSS 4, check out the W3C spec (fear not, it’s surprisingly readable as specs go). Also worth a read is W3C WG member David Storey’s blog where he did a nice write-up on CSS 4, including a few things not covered here, like the awesome-sounding “time-dimensional pseudo-classes.” |

