I'm really struggling to understand this puzzle:
When the page loads, will mypic.jpg
be downloaded by the browser?
#test1 {
display: none;
}
#test2 {
background-image: url('http://www.dumpaday.com/wp-content/uploads/2017/01/random-pictures-116.jpg');
visibility: hidden;
}
<div id="test1">
<span id="test2"></span>
</div>
The answer is no. But why? When I try the above code, the image doesn't load. Yet, it does load when I switch to display: block;
Could this be related to preserving space for an element using hidden visibility?
I'm also puzzled because a previous question claims that using display: none
does load the background image if there are no hidden descendants, while this discussion suggests browsers may prevent such loads. So, what's the truth here?