Why do some websites use the background-image: url('')
CSS rule for their logo that is in the fixed header instead of the <img>
tag?
I was going through the code for the music websites: Shazam and Deezer and realized something that amazed me but that also worried me...
Example 1: (This is the code from Shazam's website)
<a class="header-logo" href="https://www.shazam.com/" data-shz-beacon="providerdesc=home-logo" style="background-image: url("/resources/a935eea48a74b098f4b697dccd8c5322e30f48cc/logos/logo.png");"></a>
^In this case, they added an <a>
tag and then added an inline-style with the background-image: url(''
) CSS rule, instead of adding an <img>
tag.
Example 2: (This is the code from Deezer's website)
HTML
<h1>
<span class="index-header-logo logo logo-deezer-hp"></span>
<span class="sr-only" lang="en">Deezer</span>
</h1>
CSS
.logo-deezer-hp {
background-image: url(/cache/images/common/logos/deezer_hp.51c8087603572ee440e73719f69ff50d.png);
height: 40px;
width: 185px;}
^In this case they added a <span>
tag inside a <h1>
tag, gave a class to the first span tag and then through CSS they added the background-image: url('')
CSS rule.
So i asked myself:
1- Why did Shazam and Deezer not use the <img>
tag to add their logo?
2- Why did Shazam not use the <img>
tag inside the <a>
tag?
3- Why did Deezer use the <h1>
and <span>
tag to add their logo?
I researched a lot about this but still can't understand why they did not use the <img>
tag for their logo...
My question is...
"I use the <img>
tag to put my logo inside the fixed header for my website, why did Shazam and Deezer not use that tag? How/Why did they decide to use the background-image: url('')
CSS rule instead?
Every other website uses the <img>
tag, why did they not?!?!
I really need to know why both of these websites decided that it was better to use background-image: url('')
...