Upcoming CSS innovations

Original author: Peter Beverloo
  • Transfer
Tab Atkins, a member of the CSS working group and the Google Chrome team, posted slides to a presentation he made last Wednesday.

This presentation demonstrates four relatively new concepts:

Variables
Declaring a variable through the var construct , specifying its name, value, and anything from color to length, rotations and functions, it can be accessed for all CSS used on the page.

Support for local variables will also be present, through the local construct

@var paragraph-size length 12px;
@var paragraph-color color rgba(0,0,0,0);
p {
  color: var(paragraph-color);
  font-size: var(paragraph-size);
}


Impurities
Impurities provide an opportunity to expand the rule with the necessary properties with the ability to set default values.

@mixin error {
  background: #fdd;
  color: red;
  font-weight: bold;
}
div.error {
  border: thick solid red;
  padding: .5em;
  @mixin error;
}
span.error {
  text-decoration: underline;
  @mixin error;
}


Rule Attachments
Current CSS attachments, especially without the use of classes or id, are painful. The design of this is provided for this simplification. It will be applied to the descendants of the current rule, inheriting its name. Now we can make this structure clearer:

header {
  color: red;
  @this a {
    color: blue;
  }
}


Modules
No, the modules that make up the CSS 3. Modules - are common namespace for variables and impurities. Variables and contaminants can be identified by the name of the module to the top of propisanie own behalf or using design use .

@module foo {
  @var bar color red;
  @mixin baz { color: blue; }
}
.foo {
  color: var(bar); // Не работает
}
.bar {
  @use foo;
  color: var(bar); // Работает
}
.baz {
  @mixin foo|baz;  // Работает
}


Although the current code is only available on a few machines in Sydney, Google plans to publish an initial specification this quarter and implement innovations before the end of the year. Given that neither these variable plans nor the impurity plans were common in the www-style mail subscription , it will be interesting to see how the changes will be accepted by other browsers. Similar discussions, several years ago showed that these are rather controversial issues with very different opinions.

Presentation Slides

Also popular now: