Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>The spec makes no mention of how browsers should implement parsing of properties, and in particular, shorthand properties. All there is to it is a <a href="http://www.w3.org/TR/CSS21/grammar.html" rel="nofollow">grammar</a>, and the grammar says nothing about its implementation. How a browser parses a shorthand declaration then, I suspect, is entirely implementation dependent and not easily answered (unless you have the source code, of course).</p> <p>In fact, the main reason why we have numerous CSS hacks specifically catered to IE is because of how differently (and often poorly) it understands CSS.</p> <blockquote> <p>Is there any reason not to simply use <code>background</code>?</p> </blockquote> <p>The answer lies in your previous sentence:</p> <blockquote> <p>Also, on a slightly related note, on <a href="http://css3please.com/" rel="nofollow">CSS3Please</a> I noticed that for linear-gradients they specified them using <code>background-image</code>.</p> </blockquote> <p>Indeed; CSS gradients are considered images for use with backgrounds, and are documented in the <a href="http://www.w3.org/TR/css3-images" rel="nofollow">Image Values module</a>. The individual background property they apply to is <code>background-image</code>.</p> <p>If you use the shorthand property to specify either only the color or only a gradient, <a href="http://www.w3.org/TR/CSS21/about.html#shorthand" rel="nofollow">it will use the initial value for the rest of the values</a>. If this difference in used styles matters, then the difference in performance becomes completely out of the question, because it's no longer a fair comparison.</p> <p>In this example, the second <code>background</code> shorthand declaration will completely override the first one, leaving you with a solid color and no gradient as the initial value of <code>background-image</code> is <code>none</code>:</p> <pre class="lang-css prettyprint-override"><code>background: radial-gradient(white, rgba(255, 255, 255, 0)) /* transparent */; background: /* none */ green; </code></pre> <p>The purpose of the shorthand notation is to specify values for multiple related properties in a single declaration, so in order for both the gradient and the color to apply, it should be rewritten as:</p> <pre class="lang-css prettyprint-override"><code>background: radial-gradient(black, transparent) green; </code></pre>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload