Is using the logo tag in sprites good or bad?
Asked Answered
F

14

24

When building web pages, one of my colleagues displays any logo using the CSS background-image property, rather than embedding the image using an HTML <img> tag. The colleague reported it was to reduce the number of HTTP requests. He also showed me an image sprite and said that Google displays its logo with sprite images.

I don't agree with his approach and showed him that the main Google.com page loads their logo in an <img> tag.

Which is a better practice?

EDIT: Facebook also do the same thing on their homepage, loading the logo in an img tag while on their profile pages they display their logo using a CSS sprite.

From this my conclusion was that perhaps you should load your main logo in an img tag while for the other logos such as in a footer or subpage you might want to load them in the background using CSS sprites.

UPDATED: I am routinely loading logos with img tags and also know why we might use sprites. My main question is: if you have three or more logos on a page, what is the better way to load them?

Fogged answered 3/11, 2011 at 13:15 Comment(3)
www.google.com logo is a img tag... but in the brazilian google page www.google.com.br, its a backgroundAshleaashlee
What's with the formatting? What is LOGO?Piffle
LOGO is "a corporate logo (image)". The OP seems to be struggling with English.Crimpy
B
11

A logo is part of the content of your site, therefore it should be in an img tag, not as a background image. It will help to increase SEO (adding a title and alt attribute will too) and the reason companies like Google, Facebook, et al put their image in a sprite is for load times - not SEO enhancement.

Does your company have the same SE rank as Google or Facebook? No. Until then, keep putting the logo in an img tag where it belongs. When your site is consistently the most viewed site on the internet, then you can start thinking about performance more than SEO.

Also, as an aside, if the logo ever had a tweak (size, color, etc), the sprite would have to be recreated as well as the CSS. If it was just an img tag, this hassle is nonexistent.

Biochemistry answered 9/11, 2011 at 13:58 Comment(2)
Where exactly does Google rank in Google searches? And how about Bing searches?Bandaranaike
As @Rohan Patil points out in his answer, Google uses site speed information to help determine a page's ranking in its index. Therefore, performance is SEO, not subservient to it. It's impossible to know how much weight Google gives page speed, therefore it's tough to determine where the speed benefit of spriting the logo would trump the perceived SEO benefit of using an img tag, but I think this answer fails to fully resolve the question.Quod
B
28

When an image has semantical meaning, so it is considered to be content, use an IMG tag, without sprites, and a correctly set up ALT.

When an image is just decoration, like the background of a box, background of a button, background of a menu option, etc., it has no semantical meaning, so you can just use it as a background of a SPAN, DIV, etc. from CSS. You can use sprites in this case.

The reason Image Sprite is a best practice is because of how the HTTP protocol works, and because we want to minimize the time a webpage takes to load (there are many reasons why you should want to make your site load faster, one of them is because Google incorporated a while ago site speed in it’s ranking algorithm) HTTP is a non-connection based protocol, this means that for every request the browser does a new connection has to be done and the route to the server has to be recalculated. So, if every image was in the same file, the browser saves multiple requests.

Every request the browser does is divided in steps: DNS lookup, connecting, sending, waiting, receiving. We can use firebug to see all of the requests done during the loading of a webpage.

enter image description here

I took a WordPress theme and measured the time taken for every image resource at each step (ok, Firebug did that, not me) and calculated that 38.8% of the time corresponds to latency (in this case latency = DNS lookup + connecting + sending), while only 14.4% corresponds to downloading data (the 46.7% remaining corresponds to waiting for the server to respond). Latency time should be minimized, since it’s not time invested in actually downloading the resources the browser needs to show.

Steps DNS lookup, connecting and sending are redundant for every static image request on the same server. So, how can we cut them off? Guess what? Using image sprites! Every image request will be grouped in only one, resulting in only one set of latency time for all the image kilobytes the browser is going to download.

Benedix answered 11/11, 2011 at 11:14 Comment(1)
This answer truly deserves merit. Well said.Plasty
C
14

A logo is content and should therefore be represented by an <img> element (despite the trend to optimise performance at the cost of semantics).

Cairngorm answered 3/11, 2011 at 13:26 Comment(4)
Yes i agree with you & i also give LOGO in IMG but why some big websites define there LOGO in background . For example: stackoverflow.Fogged
Because there is a trend to optimise performance at the code of semantics. StackOverflow is not a good example of how to write correct HTML.Cairngorm
I generally prefer defining logos in an IMG tag. A simple, practical advantage is that if someone prints your page, the logo will show up, if the logo was set as a background sprite, it would not. I find viewing a site with CSS disabled to be helpful when making decisions like this.Malena
@ChadvonNau; please give it's as an answer. So, i will accept it thanksFogged
B
11

A logo is part of the content of your site, therefore it should be in an img tag, not as a background image. It will help to increase SEO (adding a title and alt attribute will too) and the reason companies like Google, Facebook, et al put their image in a sprite is for load times - not SEO enhancement.

Does your company have the same SE rank as Google or Facebook? No. Until then, keep putting the logo in an img tag where it belongs. When your site is consistently the most viewed site on the internet, then you can start thinking about performance more than SEO.

Also, as an aside, if the logo ever had a tweak (size, color, etc), the sprite would have to be recreated as well as the CSS. If it was just an img tag, this hassle is nonexistent.

Biochemistry answered 9/11, 2011 at 13:58 Comment(2)
Where exactly does Google rank in Google searches? And how about Bing searches?Bandaranaike
As @Rohan Patil points out in his answer, Google uses site speed information to help determine a page's ranking in its index. Therefore, performance is SEO, not subservient to it. It's impossible to know how much weight Google gives page speed, therefore it's tough to determine where the speed benefit of spriting the logo would trump the perceived SEO benefit of using an img tag, but I think this answer fails to fully resolve the question.Quod
O
5

A logo is content - that is correct. And you would probably happy when a search bot grabs it.

But some websites like to apply a :hover style on their logos. Now, you're trapped.

But you can do the following, which is semantically correct. If you want to learn more about that you can read a great article about this issue by Harry Roberts.

HTML

<body>
    <div id="head">
        <a id="header-logo" href="http://www.example.com/" title="Example Inc. - Your slogan">
            <img src="/img/assets/header-logo.png" alt="Example Inc. - Your slogan"/>
        </a>
        <h1>Welcome to Example Inc.</h1>
    </div>
</body>

CSS

body > #head a#header-logo {
    background-image: url(/img/assets/logo-header-sprite.png);
    background-position: left top;
}
body > #head a#header-logo:hover {
    background-position: left -50%;
}
body > #head a#header-logo img {
    visibility: hidden;
}
Orndorff answered 3/11, 2011 at 13:53 Comment(6)
It isn't semantically correct … the alt attribute should contain a textual replacement for an image, not a description of it. The information that a logo is normally used to convey is the name of the entity it represents, not the fact it is a logo.Cairngorm
You're perfectly right - My fault. I didn't double check my code. I even forgot the closing double quotes.Orndorff
@silvinci; i already bookmark that article & may be your markup is totally wrong because we never give HEAD inside BODY.Fogged
@Fogged - I think he meant to use the <header> tag.Religion
@Fogged - head is the CSS ID selector here and not the element selectorSane
If an img tag is styled with visibility:hidden is the src image still downloaded? I think it might be, and if so, you've just nullified any performance benefit of spriting :/Quod
C
2

I'd hazard a guess, though this is just a guess, that if your site's logo image is contained within a heading element, such as h1, then it seems likely that a semantic relationship would be made between that image and the site's identity. Also, typically, the logo would be considered meaningful content for the purposes of the brand, being the company's, or the brand's, visual identity.

Using a sprite for this purpose would seem to diminish the importance of that branding, since it would, in effect, be no more, or less, important than any other image included in that site (as, effectively all images are the same image).

If bandwidth is so important then I'd suggest putting all other images together into a sprite, but to maintain the independence/identity of the logo.

Chagall answered 3/11, 2011 at 13:29 Comment(1)
Yes i agree with you & i also give LOGO in IMG but why some big websites define there LOGO in background . For example: stackoverflow.Fogged
C
2

There is no reason not to use sprites for optimization, even if the image logo is semantic information. The overall meaning (sēmantikós) of the page is not lost if the use of sprites is done adeptly, namely by use of the image within a properly identified container. There is no universally agreed upon semantic web – semantics is a philosophical art, and open to heavy interpretation.

Perhaps arguably, more appropriate than an image for a logo is a heading (h1, by its very definition) set as a block element with visibility hidden. The text becomes searchable, carries semantic meaning for the page (allowing a proper replacement of content in text-based browsers and screen readers), and the background of the h1 set to the positioning of the sprite as necessary.

There are arguments for both sides, at least from the SEO point of view – each image is a searchable object, and an opportunity for inbound traffic; but each http request takes up bandwidth and slows the load time of the page, making it less optimized and thus lower-ranking.

edit:

When you have 3 or more logos, the point of http requests is moot; subsequent logos would presumably be the same image, even if resized. If not, reconsider why you're using the logo thusly.

If they are 3 different logos for the same company, they are no longer semantic, and no longer affect the meaning of the page. This is akin to saying a page about ABC Company is also about their DBA (Registered business name, "Doing Business As") XYZ Corporation, which is poor practice. Having a page for the company, and then another for the DBA is best practice in this situation. Either the page is for the main company, or for its subsidiary LLC. Even when you're saying "ABC Company is:" then list each DBA with their respective logos, the page's meaning is the description of ABC Company, which should have the h1 or h2 carrying the ABC Company logo, with lower level headings carrying the other logos; at this point, reducing the load time is priority, and not granting meaning to the other logos. Creating searchable content for the DBAs should be relegated to h3 and lower headings.

Chapnick answered 11/11, 2011 at 18:32 Comment(3)
Definitely agree. <h1> with text that describes the intention of the logo (e.g. "Google.com"), which is hidden for any browser that can display the logo as a background image instead. Great way to go.Ergograph
Unfortunately I don't have a screen reader (or emulator) installed, but I do wonder if the background image version would be better for the blind person. They want to hear the content (website name), not that there's a logo there.Butanone
It's unfortunate more don't agree; semantics aren't agreed upon generally, and are widely open to interpretation. This however offers the best UX for all viewers, and, if you name your sprite sheet something like abc-company-logo-sprites.jpg you're incorporating an SEO component as well. I fail to see how you can better have the best of all worlds.Chapnick
E
2

I want people to be able to download/link my logo. Therefor I will not include it in the sprite map.

Exodus answered 11/1, 2012 at 7:42 Comment(0)
M
1

I generally prefer defining logos in an IMG tag. A simple, practical advantage is that if someone prints your page, the logo will show up, if the logo was set as a background sprite, it would not.

Viewing a site with CSS disabled is helpful when making decisions like this. It gives you a good idea about the lowest common denominator viewing experience of your site. If your site make sense under those circumstances, it's like having your house built on rock.

Malena answered 12/11, 2011 at 21:4 Comment(0)
B
1

I think you should stick with the <img> tag until Google invents "Background Image Search" -- a service that searches background images, breaks sprites into individual images and intelligently distinguishes between decorative and meaningful images by analyzing CSS.

Edit: Ask yourself this question: is your logo something you want to emphasize upon; or is it just another decoration. Answer and implement accordingly.

Bine answered 31/1, 2012 at 14:59 Comment(0)
G
0

Situation: your company decides to update/change logo, but wait your logo in sprite. So you have recreate sprite again. My suggestion, keep logo in img tag.

Glorification answered 3/11, 2011 at 13:43 Comment(1)
it is much more likely that everything else is going to changeIndictable
P
0

When in rome, do what the romans do.

About logo in IMG tag, official words from Google.. http://www.youtube.com/watch?v=fBLvn_WkDJ4

Reason for keeping in tag: To have good search engine visibility, and when someone google's for ur company name, logo should come up in image results.

Reason for keeping in css-sprites [background image]: Faster load time

Big Brands: All big brands have a media section on their website, also a press section where they keep all their logos in downloadable format.

Penetralia answered 7/11, 2011 at 3:57 Comment(0)
K
0

Sprites allow you to reduce the number of requests. This will only work however if it's all in one stylesheet.

Ex: the first tag that requires the sprite is called as a background image, and then is called again in a different tag in the same stylesheet. If they are in separate stylesheets, they will be requested more than once.

Little article: http://webmasterformat.com/blog/css-sprites

Kimberly answered 8/11, 2011 at 21:18 Comment(2)
i know why we use sprites check this article css-tricks.com/158-css-spritesFogged
The sprite might be requested more than once, but it will already be cached in the local browser's cache if it is requested a second time, so you still get a major performance boost using a sprite in the situation you outline.Ergograph
S
0

you can use a sprite in an img element via the css clip: property. using sprites correctly is always a good thing for optimization. sometimes it's not practical. that is a judgement call you have to make for each different circumstance (site) that you come across.

Sherrilsherrill answered 9/11, 2011 at 20:42 Comment(3)
May be using sprite within IMG tag it's a worst thing :)Fogged
My question is 'Is using the logo tag in sprites good or bad?'Fogged
and i said using sprites is always a good thing. are you asking if using sprites with or without image replacement is a good thing? i understand what you are implying by logo tag, but maybe i'm confusedSherrilsherrill
S
0

I would recommend using the IMG tag for the logo with an alt text and combining all other images as a spritesheet. I believe using spritesheets is only truly useful when you have more than 3 images. Read Rohan Patil's answer above for why thats the case.

My main question is if you have 3 or more logos like LOGO in footer, subpage etc. So, what is a better way?

In that case, yes, add the main logo with an IMG tag and use sprites for the rest.

Shorten answered 13/11, 2011 at 2:40 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.