The Mystery Of CSS Sprites: Techniques, Tools And Tutorials

Advertisement

CSS Sprites are not new. In fact, they are a rather well-established technique and have managed to become common practice in Web development. Of course, CSS sprites are not always necessary, but in some situation they can bring significant advantages and improvements – particularly if you want to reduce your server load. And if you haven’t heard of CSS sprites before, now is probably a good time to learn what they are, how they work and what tools can help you create and use the technique in your projects.

What Are CSS Sprites? Link

The term “sprite” (similar to “spirit,” “goblin,” or “elf”) has its origins in computer graphics, in which it described a graphic object blended with a 2-D or 3-D scene through graphics hardware. Because the complexity of video games has continually increased, there was a need for smart techniques that could deal with detailed graphic objects while keeping game-play flowing. One of the techniques developed saw sprites being plugged into a master grid (see the image below), then later pulled out as needed by code that mapped the position of each individual graphic and selectively painted it on the screen.

Sprites were displayed over a static or dynamic background image, and the positioning of the sprite was controlled simply by the hardware controllers. The term was coined because the sprites seemed to “haunt” the display and didn’t really exist in the graphic memory.

Screenshot1
The Pokemon Sprite Sheet, consisting of over 1000 graphic objects. Found here2. You can click on the image for the larger version (thanks, Ryan!).

Time passed, and at the beginning of the 2000s, when progressive Web designers started to seek alternatives to JavaScript-based rollover menus (with onMouseOver and onMouseOut effects), sprites saw a renaissance in Web development. With CSS, the simple implementation of sprites was possible, and it was much easier and clearer than its JavaScript-based predecessor.

In 2004, Dave Shea suggested3 a simple CSS-based approach to CSS sprites based on the practice established by those legendary video games. In this case, multiple images used throughout a website would be combined into the so-called “master image.” To display a single image from the master image, one would use the background-position property in CSS, defining the exact position of the image to be displayed. Any hover, active or focus effects would be implemented using the simple definition of the background-position property for the displayed element.

When the page is loaded, it would not load single images one by one (nor hover-state images per request), but would rather load the whole master image at once. It may not sound like a significant improvement, but it actually was: the main disadvantage of the onMouse effects is that JavaScript-based hover effects require two HTTP requests for each image, which takes time and creates that unpleasant “flickering” of images. Because the master image is loaded with the whole page only once with CSS sprites, no additional HTTP requests are needed for hover, active or focus effects (because the image is already loaded), and no “flickering” effect occurs.

Consequence: CSS sprites reduce HTTP requests and the loading time of pages. This is the main reason why CSS sprites are often used on websites with heavy traffic, where millions of page impressions would need “only” a tiny fraction of what could otherwise be 30,000,000. Hence, CSS sprites are commonly used, particularly for navigation (such as for hover effects), icons and buttons.

Where Are CSS Sprites Used? Link

CSS sprites can be used in various settings. Large websites can combine multiple single images in a meaningful manner, creating clearly separated “chunks” of the master images – the purpose being to keep the design maintainable and easy to update. The large empty space between the images is often used to make sure that the text resizing in browser doesn’t cause side effects such the display of multiple images in the background. In fact, sprites usually work well in a pixel-based design, but they are hard to use in elastic (em-based) designs due to the restricted background-position-property. Essentially, the structure that sprites take depends on the trade-off between maintainability and reduced server load; thus, it varies depending on the project you are working on.

Here are some inspiring (and not so inspiring) examples:

Xing4
Xing uses various icons and buttons, as well as its logo, in the sprite.

Screenshot

Amazon5
Large, shiny and compact CSS sprites on Amazon.

Screenshot6

Apple7
Apple uses CSS sprites for various states of its main navigation menu.

Screenshot8

YouTube9
YouTube takes a vertical approach to its buttons and icons. The whole sprite is 2800 pixels in height!

Screenshot10

CNN11
CNN uses a modest CSS sprite with its social icons.

Screenshot12

Digg13
Digg has quite an esoteric sprite, with small arrows and brackets. The large empty space between the images is used to make sure that text resizing doesn’t display multiple images as the background image. You can explicitely define width and height in pixels, so that this problem does not occur – however, in this case the resized text will never break out of the defined box, thus possibly making the text unreadable. Consequently, you must be cautious when using spriting for buttons with variable text labels. For those buttons, you should define font size in pixels also. Or just use the large empty space in the sprite (thanks, daftie!).

Screenshot14

Yahoo15
Yahoo has nice icons in its sprite, spread out equidistant from each other.

Screenshot16

Google17
Google sticks to its minimalist design principle with its minimalist CSS sprite.

Screenshot18

Dragon Interactive19
A design agency with a colorful, vivid CSS sprite for the navigation menu.

Screenshot20

TV1.rtp.pt21
A huge colorful and qute chaotic CSS sprite on a site of a Portugiese TV-channel (thank you, António Manuel Cardoso!).

Screenshot22

CSS Sprites are used to combine many frequently used graphic elements, such as navigation elements, logos, lines, RSS icons, buttons, etc. Conversely, they are not used for any kind content that is likely to change frequently upon release.

Articles About CSS Sprites Link

CSS Sprites: Image Slicing’s Kiss of Death23
The legendary introductory article about CSS sprites on A List Apart.

Screenshot24

CSS Sprites: What They Are, Why They’re Cool And How To Use Them25
An illustrated article about CSS sprites by Smashing Magazine author Chris Coyier and a blogger from Turkey, Volkan Görgülü.

Screenshot26

How Yahoo.com and AOL.com Improve Web Performance With CSS Sprites27
Some of the busiest websites on the Web use CSS sprites to save on HTTP requests. This article shows how Yahoo! and AOL use sprites to improve performance. Note: some devices (the iPhone being the most notable) apply sprites in a memory-intensive way, which slows the device to a crawl.

What Are CSS Sprites?28
An introduction by Jason Cranford Teague.

Screenshot29

Sprite Optimization30
Dave Shea ponders whether it actually makes sense to create large CSS sprites, combining all elements into a single image and then displaying them with the background-position property in CSS. Answer: No, do not over-complicate things. Instead, find a good compromise between quick loading time and maintainability.

CSS Sprites31

Creating Easy and Useful CSS Sprites32
A detailed introduction to CSS Sprites by Ignacio Ricci. All files can be downloaded as well.

Screenshot33

Fast Rollovers Without Preload34
A practical example of implementing fast rollovers.

Screenshot35

CSS Sprites + Rounded corners36
Another example from practice, this one explaining how to display rounded corners using CSS Sprites.

Screenshot37

CSS Image Sprites38
An extensive tutorial with examples, tips, suggestions and best practices.

Optimize Your Website Using CSS Image Sprites39
This very detailed tutorial by Andrew Johnson explains what CSS sprites are, why they are important, how they work and how to implement them.

Screenshot40

Animated GIF For CSS Sprites41
This article discusses one of the more bizarre uses of CSS sprites: as an animated GIF.

Screenshot4243

Image Sprite Navigation With CSS44
Learn how to create a simple menu with the hover effect.

Screenshot45

Advanced CSS Menu46
Implement the hover effect with CSS sprites.

Screenshot47

Creating and Using CSS Sprites48
A very basic tutorial about CSS sprites by David Walsh.

CSS Sprites Screenshot49

Screencasts about CSS Sprites Link

How to Use CSS Sprites50
David Perel explains the basics of CSS sprites and how to use them in your website design. 10 minutes.

Creating Rounded Buttons With CSS Sprites51
Continuing the above sprites tutorial, David shows how to create dynamic rounded-corner buttons with CSS.

Exactly How to Use CSS Sprites52
In this screencast, Andres Fernandez shows how to use CSS sprites to improve loading time and decrease HTTP requests.

How To Use CSS Sprites53
This screencast, Smashing Magazine author Chris Coyier shows how to use CSS sprites in practice, by taking what would have been eight different images and combining them into one. As an added bonus, he then expands on the idea with jQuery by building a little accordion widget.

Faster Page Loads With Image Concatenation54
For complex web apps, the quantity and resulting latency of icons and images used can greatly affect page load times. And developers usually try to reduce, rather than increase, page load times for their sweet Web apps.

CSS Image Sprites In 10 Minutes55
Another screencast that explains how to use CSS sprites for a navigation menu.

CSS: Using Percentages in Background-Image56
This article explains the background-position property, which is essential to implementing CSS sprites.

CSS Image Maps With CSS Sprites Link

With CSS Sprites, the hover effect doesn’t have to be applied to the whole element. Using a negative background-position value, you can create pure CSS-based image maps. Below, you’ll find some techniques in which CSS sprites are used for this purpose.

CSS Image Maps Using Sprites57
A basic example of a CSS-based image map with a negative background-position value. Try hovering over the image. Compare this with the classic example without CSS sprites58.

Screenshot59

City Guide Map Using Sprites60
Another example, with horizontally positioned hover areas.

Screenshot61

Advanced Map Using Sprites62
A more advanced technique by Frank Manno.

Screenshot63

CSS Sprites Techniques Link

CSS Sprites 264
Dave Shea expands on the classic CSS sprites technique with jQuery. His technique allows for animation between link states, while still being fully degradable for visitors who do not have JavaScript enabled.

CSS Sprites2 Refactored: Building an Unobtrusive jQuery Plug-In65
Joel Sutherland describes his jQuery plug-in, which cleans up Dave Shea’s function and allows for more control over the animation with less initial configuration.

CSS Sprites Screenshot66

Background Repeat and CSS Sprites67
CSS sprites are a great way to improve the loading speed of your pages. One of the problems you might face with sprites is how to deal with cases where the background repeats. The rule is pretty simple: if you want the background to repeat vertically (top to bottom), place the images in the sprite horizontally (left to right) and make sure the individual images in the sprite have the same height. For the opposite case, when you want to repeat horizontally, sprite vertically.

CSS Sprite: Photoshop Script Combines Two Images for CSS Hover68
This article presents a simple JSX Photoshop script for creating image sprites, and you can also assign a keyboard shortcut to it.

CSS Sprites Screenshot69

Extending CSS Spriting70
Jennifer Semtner extends the classic CSS sprites technique to non-background images and discusses what to consider when using CSS Sprites for the design.

Sliding Doors Meets CSS Sprites71
Combining the ideas behind Dave Shea’s CSS sprites and Douglas Bowman’s sliding doors technique, this post assumes you have a good understanding of Bowman’s article “Sliding Doors of CSS72.”

How to Preload Images When You Can’t Use CSS Sprites73
This article addresses the problem that occurs with CSS sprites when the user resizes text. The idea is to combine the images into two images, rather than one. Then you place the image being shown on hover as the background image of another element (preferably a containing element), positioned just off screen.

JavaScript Sprite Animation Using jQuery74
Alex Walker combines visual jQuery effects with CSS sprites to achieve the “page turn” effect.

CSS Sprites Screenshot75

IE6, CSS Sprites and Alpha Transparency76
Julien Lecomte shows how to combine CSS sprites, PNG transparency and Internet Explorer 6 compatibility using the AlphaImageLoader hack.

CSS Sprite Generators Link

Data URI Sprites77
DURIS (Data URI [CSS] Sprites) is a new method to manage website’s background images. It’s aimed to replace classical CSS Sprites. The new technique allows you to apply any corrections to your make-up, allows you to minimize number of requests for design-related data that is used on the webpage and uses text (non graphic) format of image data presentation. It also solves all problems with scaling for background images and combines images of different types and axes of repetition.

Screenshot78

Spritr79
This simple tool lets you upload multiple images and generates CSS code for the sprite.

Sprite Creator 1.080
This tool allows you to upload an image and create the CSS code for selected areas of the sprite.

CSS Sprite Generator81
A Drupal module for building CSS sprites.

CSS Sprites Generator82
This tool allows you to upload multiple files and generate a sprite out of them. It also gives you the CSS code (the background-position value) for each image in the sprite.

Projekt Fondue CSS Sprite Generator83
This generator lets you ignore duplicate images, resize source images, define horizontal and vertical offset, define background and transparency color, assign CSS class prefixes and various other things. It also supports many languages. The source code is available for downloading and is covered by a BSD license. Want to run a local copy? Well, you can do that, too.

Screenshot84

SmartSprites85
A Java-based desktop application that parses special directives that you can insert into your original CSS to mark individual images to be turned into sprites. It then builds sprite images from the collected images and automatically inserts the required CSS properties into your style sheet, so that the sprites are used instead of the individual images.

You can work with your CSS and original images as usual and have SmartSprites automatically transform them to the sprite-powered version when necessary. A PHP version86 is available as well. Open-source. Check also Chris Brainard’s Sprite Creator 1.087.

Bonus: How Does The background-position Property Work? Link

The background-position property, together with CSS specificity88 and CSS floats89, is probably one of the most confusing and counter-intuitive of CSS properties.

According to CSS specifications, the background-position takes two (optional) arguments: horizontal position and vertical position. For example:

.introduction {
		background-image: url(bg.gif);
		background-position: [horizontal position] [vertical position];
		}

Using this property, you can define the exact position of the background image for the block-level element (list item li). You can use either % or px units (or mix both) to define the starting position (i.e. the upper-left corner) of the displayed part of the master image. Alternatively, you could use the following keywords: top left, top center, top right, center left, center center, center right, bottom left, bottom center, bottom right.

Hence, in background-position: x% y%, the first value is the horizontal position, and the second value is the vertical position. The top-left corner is 0% 0%. The bottom-right corner is 100% 100%. If you specify only one value, the other value will be 50%.

For instance, if you use,

ul li {
		background-image: url(bg.gif);
		background-position: 19px 85px;
		},

… then the background-image will be positioned 19 pixels from the left and 85 pixels from the top of the list item element.

As SitePoint’s reference article explains90: “a background-image with background-position values of 50% 50% will place the point of the image that’s located at 50% of the image’s width and 50% of the image’s height at a corresponding position within the element that contains the image. In the above case, this causes the image to be perfectly centered. This is an important point to grasp — using background-position isn’t the same as placing an element with absolute position using percentages where the top-left corner of the element is placed at the position specified.”

You can find a detailed explanation of the property in the article “background-position (CSS property)91” on SitePoint.

You may want to take a look at the following related posts:

(al)

Footnotes Link

  1. 1 http://img45.imageshack.us/img45/4259/buildingssheet7dv.png
  2. 2 http://gmc.yoyogames.com/lofiversion/index.php/t307986.html
  3. 3 http://www.alistapart.com/articles/sprites
  4. 4 http://www.xing.de
  5. 5 http://www.amazon.com
  6. 6 http://www.flickr.com/photos/mezzoblue/3217540317/
  7. 7 http://www.apple.com/
  8. 8 http://images.apple.com/global/nav/images/globalnavbg.png
  9. 9 http://www.youtube.com/
  10. 10 http://s.ytimg.com/yt/img/master-vfl89407.png
  11. 11 http://www.cnn.com/
  12. 12 http://i.cdn.turner.com/cnn/.element/img/2.0/global/icons/share_sprite.gif
  13. 13 http://www.digg.com/
  14. 14 http://digg.com//img/menu-current.gif
  15. 15 http://www.yahoo.com/
  16. 16 http://l.yimg.com/a/i/ca/sp/purple/fp_spt_icons_0.0.2.png
  17. 17 http://www.google.com/
  18. 18 http://www.google.ca/images/nav_logo3.png
  19. 19 http://dragoninteractive.com/
  20. 20 http://dragoninteractive.com/lib/i/navigation/sprite.jpg
  21. 21 http://tv1.rtp.pt/noticias/index.php
  22. 22 http://img.rtp.pt/noticias/images/ImgNoticias_n_repeat.jpg
  23. 23 http://www.alistapart.com/articles/sprites
  24. 24 http://www.alistapart.com/articles/sprites
  25. 25 http://css-tricks.com/css-sprites/
  26. 26 http://css-tricks.com/css-sprites/
  27. 27 http://www.websiteoptimization.com/speed/tweak/css-sprites/
  28. 28 http://www.peachpit.com/articles/article.aspx?p=447210
  29. 29 http://www.peachpit.com/articles/article.aspx?p=447210
  30. 30 http://mezzoblue.com/archives/2009/01/27/sprite_optim/
  31. 31 http://mezzoblue.com/archives/2009/01/27/sprite_optim/
  32. 32 http://cssglobe.com/post/3028/creating-easy-and-useful-css-sprites
  33. 33 http://cssglobe.com/post/3028/creating-easy-and-useful-css-sprites
  34. 34 http://wellstyled.com/css-nopreload-rollovers.html
  35. 35 http://wellstyled.com/css-nopreload-rollovers.html
  36. 36 http://cssglobe.com/post/3714/css-sprites-rounded-corners/
  37. 37 http://cssglobe.com/post/3714/css-sprites-rounded-corners/
  38. 38 http://websitetips.com/articles/css/sprites/
  39. 39 http://www.itnewb.com/archive/Optimize-Your-Web-Site-by-Using-CSS-Image-Sprites
  40. 40 http://www.itnewb.com/archive/Optimize-Your-Web-Site-by-Using-CSS-Image-Sprites
  41. 41 http://adamducker.com/blog/7/animated-gif-for-css-sprites/
  42. 42 http://adamducker.com/blog/7/animated-gif-for-css-sprites/
  43. 43 http://stylemeltdown.com/2007/10/22/image-sprite-navigation-with-css/
  44. 44 http://stylemeltdown.com/2007/10/22/image-sprite-navigation-with-css/
  45. 45 http://stylemeltdown.com/2007/10/22/image-sprite-navigation-with-css/
  46. 46 http://www.webdesignerwall.com/tutorials/advanced-css-menu/
  47. 47 http://www.webdesignerwall.com/tutorials/advanced-css-menu/
  48. 48 http://davidwalsh.name/css-sprites
  49. 49 http://davidwalsh.name/css-sprites
  50. 50 http://www.from-the-couch.com/post.cfm/title/how-to-use-css-sprites
  51. 51 http://www.from-the-couch.com/post.cfm/title/creating-rounded-buttons-with-css-sprites
  52. 52 http://nettuts.com/videos/screencasts/exactly-how-to-use-css-sprites/
  53. 53 http://css-tricks.com/video-screencasts/43-how-to-use-css-sprites/
  54. 54 http://borkweb.com/story/faster-page-loads-with-image-concatenation
  55. 55 http://www.csslessons.com/
  56. 56 http://www.sitepoint.com/blogs/2007/07/05/css-using-percentages-in-background-image/
  57. 57 http://lab.fatagnus.com/css-sprites/
  58. 58 http://www.cssplay.co.uk/menu/imap.html
  59. 59 http://lab.fatagnus.com/css-sprites/
  60. 60 http://www.alistapart.com/d/sprites/ala-image3.html
  61. 61 http://www.alistapart.com/d/sprites/ala-image3.html
  62. 62 http://www.frankmanno.com/ideas/css-imagemap/
  63. 63 http://www.frankmanno.com/ideas/css-imagemap/
  64. 64 http://alistapart.com/articles/sprites2
  65. 65 http://www.newmediacampaigns.com/page/css-sprites2-refactored-building-an-unobtrusive-jquery-plugin
  66. 66 http://www.newmediacampaigns.com/page/css-sprites2-refactored-building-an-unobtrusive-jquery-plugin
  67. 67 http://www.phpied.com/background-repeat-and-css-sprites/
  68. 68 http://www.interactivellama.com/blog/archives/photoshop-script-combine-two-images-css-hover-css-sprite/
  69. 69 http://www.interactivellama.com/blog/archives/photoshop-script-combine-two-images-css-hover-css-sprite/
  70. 70 http://www.jennifersemtner.com/css/101/extending-css-spriting/
  71. 71 http://www.fiftyfoureleven.com/weblog/web-development/css/doors-meet-sprites
  72. 72 http://www.alistapart.com/articles/slidingdoors/
  73. 73 http://trevordavis.net/blog/tutorial/how-to-preload-images-when-you-cant-use-css-sprites/
  74. 74 http://www.sitepoint.com/blogs/2007/07/20/javascript-sprite-animation-using-jquery/
  75. 75 http://www.sitepoint.com/blogs/2007/07/20/javascript-sprite-animation-using-jquery/
  76. 76 http://www.julienlecomte.net/blog/2007/07/4/
  77. 77 http://duris.ru/lang/en/
  78. 78 http://duris.ru/lang/en/
  79. 79 http://printf.ru/spritr/
  80. 80 http://www.floweringmind.com/sprite-creator/index.php
  81. 81 http://drupal.org/project/sprites
  82. 82 http://www.csssprites.com/
  83. 83 http://spritegen.website-performance.org/
  84. 84 http://spritegen.website-performance.org/
  85. 85 http://smartsprites.osinski.name/
  86. 86 http://www.tanila.de/smartsprite/index.php
  87. 87 http://tanila.de/smartsprite/index.php
  88. 88 http://www.smashingmagazine.com/2007/07/27/css-specificity-things-you-should-know/
  89. 89 http://www.smashingmagazine.com/2007/05/01/css-float-theory-things-you-should-know/
  90. 90 http://reference.sitepoint.com/css/background-position
  91. 91 http://reference.sitepoint.com/css/background-position
  92. 92 http://www.smashingmagazine.com/2007/01/19/53-css-techniques-you-couldnt-live-without/
  93. 93 http://www.smashingmagazine.com/2008/02/21/powerful-css-techniques-for-effective-coding/
  94. 94 http://www.smashingmagazine.com/2008/12/09/50-really-useful-css-tools/
  95. 95 http://www.smashingmagazine.com/2007/05/01/css-float-theory-things-you-should-know/
  96. 96 http://www.smashingmagazine.com/2007/07/27/css-specificity-things-you-should-know/

↑ Back to top Tweet itShare on Facebook

Sven is the co-founder and former CEO of Smashing Magazine. He's now writing at his Conterest Blog, where he focuses on blogs, content strategy and publishing — all in German.

Advertisement
  1. 1

    Great post!!!
    Thanks!

    -1
  2. 2

    that’s great!

    -1
  3. 3

    Another great post, thanks!
    I heard about css sprites but rather ignored it up to now. Well, will keep it in mind for my next project.

    2
  4. 4

    I’ve played around with this, but doesn’t it become a major problem when dealing with different browsers that add or subject padding and margin and throw the whole thing off? Some off those icons are so small it could cause an entirely different image to be displayed.

    1
  5. 5

    Good post, really worthy… Thank you dude..

    -1
  6. 6

    good tutorial …!!!

    -1
  7. 7

    I have been using sprites for a number of years now, especially with my bigger clients (5,000+ unique visits a day) it makes sense to reduce the number of server-requests by using sprites.

    This is a wicked article with a load of information, thanks!

    0
  8. 8

    I’m not sure I’d call sliding bg techniques, “sprites,” which suggests a kind of animation created through image cycling in the same square. Similar but not really the same purpose with no JS to slow the speed of the switch from one image to the next which would be needed to create animation beyond one step.

    You can lump a bunch of stuff into background shorthand-style that’s useful. I rarely use background-image.

    Like so:

    background:#888 url(../images/someimg.gif) 2px 5px no-repeat;

    The color appears behind the image or is just transparent if you don’t select one. The px dimensions are left and top for the bg-image and no-repeat is a good one if you don’t want tiling in the event that your element gets larger than the image size. Note: padding needs to be corrected for in regards to the bg image. This can actually be a very useful behavior sometimes.

    I’m not sure if I got the order right on no-repeat vs. the x and y pixel settings but think I’ve seen it work either way. Sometimes the order matters on CSS shorthand, sometimes not in my experience.

    That is interesting that they’ve been using entire panels of icons like that. Some of them were poorly set up though. Even spacing in rows and colums with a set width would make sense. Then you could add new ones in new rows without messing up the appearance of the old sets.

    0
  9. 9

    Great tutorial…

    0
  10. 10

    Interesting…

    0
  11. 11

    One of the very best post here…

    0
  12. 12

    Awesome! I’ve used this on a few sites of mine. Great post!

    0
  13. 13

    Very good article, i honestly thought sprites were used only for menus and nothing else, i even felt guilty when i used a sprite almost for a whole test site once. Thanks guys.

    0
  14. 14

    I’ve always referred to this as a sliding image, or window affect, not Sprites. Any who, I’ve used this for a long while with menus, and sometimes for a whole site when there are few images. It helps keep everything organized, plus it tends to lower the bandwidth used because all the images in one file usually is smaller than all of them all separate.

    0
  15. 15

    Great post..
    Good job smashingmagazine.com..

    0
  16. 16

    Nice comprehensive overview, I have been doing this for a while but only as one sprite per nav item, think I might try it for all nav items in one image file next time.

    0
  17. 17

    There really is a lot packed into this article. Explanation, description, history and a wealth of very helpful resources. Great work, thank you!

    0
  18. 18

    Really like this Article much respect to the writer and sure to our hood smashingmagazine.com

    0
  19. 19

    very informative and extensive. it’s also nice how using sprites prevents flickering when using hover effects. looking forward to more css articles like this!

    0
  20. 20

    very good post. thanks i would say best post of the month thanks a lot dear

    1
  21. 21

    Great article for refreshing a technique that I use in almost every website. Refreshing basic techniques is always a good thing.

    0
  22. 22

    really worthy… Thank you Buddy..

    0
  23. 23

    Matthijn Dijkstra

    April 27, 2009 10:46 pm

    Great post, knew about sprites, but didn’t use them, but now I think there are some nifty things for it for usage.

    0
  24. 24

    Very useful post!
    Thanks!

    0
  25. 25

    Excellent post. Very useful and technically affordable. Thanks.
    I would add a brief description of the advantages over preloading.

    0
  26. 26

    I’ve never used this technique, but then again I don’t use that much graphics on my site. x3

    0
  27. 27

    In your tool list, you could add YASC (Yet Another Sprite Creator), a tool to easily generate the css rules for your sprite images : http://www.lecentre.net/fratoblog/yasc/

    0
  28. 28

    Very nice, thank you

    0
  29. 29

    An awsome post SM, very practical, altough I use sprites for some roll over states I see I can expand this much further to encompass more of my smaller global graphical elements..

    Many thanks

    Keep up the great work.

    Tim

    0
  30. 30

    thanks

    0
  31. 31

    The word “sprites” is just stupid. How about we call it “not being a moron w/ how you load images”…

    Geez.

    0
  32. 32

    Nice post. Comprehensive and well explained.

    0
  33. 33

    Very useful post!
    Thanks!

    0
  34. 34

    Great post, it’s very useful to semplify the hover effect!

    0
  35. 35

    “infamous technique”?!?? Why? Does SM not know what that word means?

    0
  36. 36

    Use and teach students this technique all the time, but this article has some useful snippets which I would like to explore – that photoshop plug-in looks like a good time saver for instance.

    Had a bit of a debate a while back about the term ‘Sprite’ and where the original videogame use derived from so thanks for clearing that one up!

    Personally I think it makes sense in a CSS context, but if you don’t like it, go and and take your grievances to Mr Shea, he’s the one that coined it.

    @Alan – use browser reset styles to prevent different browsers adding unwanted margins and padding, not that this would affect background-position anyways.

    0
  37. 37

    Great post for a front end designer who doesnt code at all. Didnt even know these things existed! Very interesting.

    0
  38. 38

    CSS Sprites were a great idea four or five years ago. They are very impractical now for one big reason. What if the user is running a browser that doesn’t have a built in zoom function such as Flock. When the user increases the text size the box size increases to accommodate the text. They then get to see images that were meant to be hidden, and the design looks hideous.

    Internet speed are growing all of the time. It doesn’t really matter how many HTTP requests are required. Also, If you are a clever designer you can greatly reduce the amount of images you use and rely on the CSS box model to style the majority of your page.

    0
  39. 39

    A great little ‘local’ tool for QUICKLY combining existing graphics into sprites by the boys at indyhall in philly – http://github.com/IndyHallLabs/css-sprite-generator/tree/master

    0
  40. 40

    Indeed, this article lacks one thing: good solid information about the disadvantages. Sprites work well in a pixeldesign, but are not made for em design (due to the restricted background-position).

    Good writeup for those who never heard of it I guess, but I’d preferred a more objective article.

    (SM) Good point, it was added to the article. Thank you.

    0
  41. 41

    had a chat with a friend about sprites yesterday.
    how did you guys know that? ;)

    0
  42. 42

    wow. i’ve found some tricks i didn’t know yet.
    great post as usual!

    thanks sm

    0
  43. 43

    Nice Post… Thanks…

    0
  44. 44

    Great post. Was literally looking into some buttons and navigation that use this technique. Thanks for the quick overview.

    0
  45. 45

    Interesting article, I do use this technique from time to time, but only really on image rollovers for menus etc – for quicker loading times. I’ve always used individual images and can’t say this is really worth the time or effort.

    0
  46. 46

    Here is a fantastic set of tiny icons (using the Silk Icon Set) converted to CSS Sprites. Turns 1+ megabytes of Silk CSS icons into a single 67KB png and then provides a very simple CSS structuring for calling any of those images…

    Silk Icon Set CSS Sprites

    0
  47. 47

    Very thorough post. I’ve been using CSS sprites for rollovers for a few months now, and it REALLY makes a difference in page loading time & coding/marking up.

    Thanks.

    0
  48. 48

    I thought this technique recently, but haven’t got a chance to play it. thanks for the great article.

    0
  49. 49

    Christopher Ross (thisismyurl.com)

    April 28, 2009 4:58 am

    This is very cool, I’ve only started using sprites as a basic stable of my design services and find that for larger volume websites it’s making a pretty big dent in load times.

    0
  50. 50

    Great article!
    Thanks!

    http://www.rockstarapps.com/joomla-1.5.8/documentation/resource-optimization/create-sprite.html – a useful article about Rockstarapps Web Optimizer, this tool offers automatic CSS Sprite generation.

    0

↑ Back to top