W3C home > Mailing lists > Public > www-style@w3.org > August 2009

[CSS3] Some thoughts about functions, notation and gradient().

From: Andrew Fedoniouk <news@terrainformatica.com>
Date: Tue, 18 Aug 2009 23:28:36 -0700
Message-ID: <4A8B9B94.2070406@terrainformatica.com>
To: www-style <www-style@w3.org>
Am I alone who failed to decipher these records (taken from Tab's URL 
[1] with GUID the Ultimate):

background: linear-gradient(top / yellow, blue);
background: linear-gradient(top to bottom / yellow, blue);
background: linear-gradient(-90deg / yellow, blue);
background: linear-gradient(top left to bottom left / yellow, blue);
background: linear-gradient(top / yellow 0%, blue 100%);
background: linear-gradient(top left / yellow, blue);
background: linear-gradient(top left to bottom right / yellow, blue);
background: linear-gradient(0 0 to 100% 100% / yellow, blue);
background: linear-gradient(-45deg inside/ yellow, blue);


I'd like to rise the question/discussion about function notation in CSS.
It seems that CSS development is at the phase when we see the demand of 
extended functionality using forms similar to the linear-gradient feature.

It is clear so far that such function notation has to be:

1) human readable as much as possible;
2) should allow decomposition and so parts of the function to be 
accessible independently by scripts and modules like CSS Animation & Co.
3) Should be compatible with the rest of CSS.

As an initial idea I propose to use function notation with
[named] arguments:

   <name> '(' [<argument>] [ ',' <argument> ]* ')'

   <name> is a name token standard for the CSS;

   <argument> is single value or pair of values:

       <value>  [ ':' <value> ]?

   <value> here is either
         a) some name-token/keyword like: top ;
         b) or value like: 12px, 90deg, etc;
         c) or function including the calc();
         d) or whitespace separated list of items above.

Therefore parameters can be named or not. There is no
requirement for uniqueness of names of parameters in single function
"call". E.g. (color-stop: 0% red, color-stop: 100% blue).

Here is real life example that I would like to harmonize using such 
notation. In my engine I have following attribute that accepts various 

img:hover {
used to highlight the image on hover. The notation is not so pretty -
not extendable.

By using proposed function notation I will be able to define this as:

              color-filter(contrast:0.75, gamma:1.2 );

   foreground-image-transformation: color-filter(tint-of:red);

And here is an example of how the linear-gradient could be defined:

  background-color: linear-gradient(
                       start:0% 0%,
                       stop: 100% 100%,
                       color-stop: 0% white,
                       color-stop: 50% red ,
                       color-stop: 100% blue );

In JS components of such function alike declaration can be accessed as:

el.style.backgroundColor["linear-gradient"]["start"] = ...
el.style.backgroundColor["linear-gradient"]["stop"] = ...
el.style.backgroundColor["linear-gradient"]["color-stop"][0] = ...;

In CSS Animation:

@keyframes 'color-in-gradient'
     from {
       background-color.linear-gradient.color-stop[0]: 0% white;
     to {
       background-color.linear-gradient.color-stop[0]: 50% red;
(in fact the Animation itself can be re-thought in terms of functions)

All above is not perfect of course but at least we should (IMO) start
moving in that direction as soon as possible. Before it will not be too 


Andrew Fedoniouk.

Received on Wednesday, 19 August 2009 06:29:05 UTC

This archive was generated by hypermail 2.3.1 : Monday, 2 May 2016 14:38:28 UTC