When I specify background-size: 100% 100%
on a BODY
element style attribute, WebKit rewrites it to background-size: 100%
. According to the spec that would be equivalent to 100% auto
.
Why does this happen?
According to MDN:
[2] WebKit-based browsers originally implemented an older draft of CSS3 background-size in which an omitted second value is treated as duplicating the first value; this draft does not include the
contain
orcover
keywords.
The following minimal test case outputs "100% 100%" in all other browsers, including versions of Chrome that use Blink, and outputs "100%" in Safari:
data:text/html,<!DOCTYPE html><body style="background-size: 100% 100%"><script>document.write(document.body.style.backgroundSize);</script>
Modifying it to use the -webkit-
prefix outputs "100%" in all versions of Chrome, including those that use Blink, which suggests that Chrome has left its experimental implementation of -webkit-background-size
, which dates back by more than a decade, intact:
data:text/html,<!DOCTYPE html><body style="-webkit-background-size: 100% 100%"><script>document.write(document.body.style.webkitBackgroundSize);</script>
However, rendering tells a different story: Chrome renders according to the latest spec regardless of whether the prefix is used, and I haven't managed to figure out what exactly Safari is doing yet...