If I have:
background:#A2A2A2 url('./images/img.png') repeat-x left bottom;
and then I use:
background:#000000; /* not to confuse with 'background-color' */
Do background-image
,background-repeat
and background-position
are lost?
If I have:
background:#A2A2A2 url('./images/img.png') repeat-x left bottom;
and then I use:
background:#000000; /* not to confuse with 'background-color' */
Do background-image
,background-repeat
and background-position
are lost?
background-image
, background-repeat
and background-position
(among other things) will be implicitly set to their default values when you leave them out in the shorthand property. It's just how a shorthand property works (for the most part).
The computed background styles end up looking something like this:
background-color: #000000; /* Your specified value */
background-image: none; /* Default value */
background-repeat: repeat; /* Default value */
background-position: 0% 0%; /* Default value */
So yes, those values you set in the first shorthand declaration will be lost.
background-attachment
in CSS2, and a number of others in CSS3: w3.org/TR/css3-background/#the-background –
Lethe © 2022 - 2024 — McMap. All rights reserved.
background-color
, what is it setting? – Sairbackground-color
. The comment is cautioning the reader not to confuse the shorthandbackground
property with thebackground-color
property. – Lethebackground-color
so it doesn't overwrite the other properties? But I guess your question isn't asking how to solve that problem, just whether it overwrites them. – Sair