Brand New Css4 Specification

October 30, 2016 - 1 minute read

Brand New Css4 Specification

CSS 3 is still slowly making its way onto the web, but the World Wide Web Consortium (W3C), the governing body that oversees the development of web standards, is already plotting the future of CSS with CSS 4. The W3C recently released the first draft of CSS 4, adding dozens of new rules to make web developers’ lives easier.

CSS 4 allows one to make any compound selector the subject, by prepending a dollar sign. Example:

$ul li :hover { color : green; }

Here, if one hovers over a list element, the whole list will turn green. This is a great and dearly needed feature.

Pseudo-class: nth-match (). Lets you apply a rule to every n-th match for a given selector list.

: Nth-match (an+b of selector-list)

Previously, you could only access every n-th child. This selector gives you more flexibility.

UI states pseudo-classes allow you to style elements depending on their user interface state. Examples: disabled, checked (radio elements, checkbox elements, menu items, etc.), :in-range (for input elements with range limitations).

The matches-any Pseudo-class: matches () Example:

: Matches (section, article, aside) h1 { Font-size : 3em; }

The above selector is an abbreviation for

The contextual reference element pseudo-class ‘:scope’. When you use selectors to query for elements, you can start your search in a list of elements that is iterated over, one element at a time. :scope is a placeholder for the current element. Example:

document.querySelector (“: scope > ul > li???, elems)

Tags: , ,