Dan's Tools spritegen.website-performance.org

CSS Sprite Generator

    Join Login
  • Development
    • HTML/JS/CSS Playground
    • HTML Color Codes
    • CSS Fonts
    • Online Diff Tool
    • .htaccess Generator
    • Javascript Error Logger
    • RegEx Testing
    • RGB to HEX Color Converter
    • TimeStamp Converter
    • Website Speed Test
  • Encode/Decoders
    • Base64 Decode
    • Base64 Encode
    • MD5 Hash Generator
    • SHA-1 Hash Generator
    • SHA-256 Hash Generator
    • SHA-512 Hash Generator
    • URL Encode/Decode
  • Formatters
    • CSS Formatter
    • GO Formatter
    • HTML Beautifier & Formatter
    • Javascript Formatter
    • Javascript Obfuscate
    • JSON Formatter & Beautifier
    • JSON Editor
    • JSON Validator
    • Perl Formatter
    • PHP Formatter
    • Python Formatter
    • Ruby Formatter
    • SQL Formatter
    • XML Formatter & Beautifier
  • Images
    • Favicon.ico & App Icon Generator
    • Online Image Editor
    • CSS Sprite Generator
  • Internet
    • Color Palette Explorer
    • Email Validator
    • Explain Linux Commands
    • Is It Up Or Down
    • Default Router Settings
    • User Manuals
    • What is my IP
  • Minifiers
    • CSS Minify
    • Javascript Minify
    • JSON Minify
  • SEO
    • Adblock Monitor & Notification
    • Keyword Tool
  • Conversion
    • CSV To HTML Converter
    • CSV To JSON Converter
    • CSV To TSV Converter
    • CSV To XML Converter
    • JSON To CSV Converter
    • JSON To HTML Converter
    • JSON To TSV Converter
    • JSON To XML Converter
    • XML To CSV Converter
    • XML To HTML Converter
    • XML To JSON Converter
    • XML To TSV Converter
    • Convert Files
  • Numbers
    • Binary Converter
    • Binary To Decimal Converter
    • Binary To Hex Converter
    • Binary To Octal Converter
    • Unit Converter
    • Decimal To Binary Converter
    • Decimal To Hex Converter
    • Decimal To Octal Converter
    • Hex To Binary Converter
    • Hex To Decimal Converter
    • Hex To Octal Converter
    • Data Size Converter
    • Octal To Binary Converter
    • Octal To Decimal Converter
    • Octal To Hex Converter
  • Strings
    • Binary To String Converter
    • Hex To String Converter
    • HTML Entities Escape
    • HTML Entities Unescape
    • String To Binary Converter
    • String To Hex Converter
    • Strip and Remove HTML Tags
    • Strip and Remove XML Tags
    • Word Counter
    • XML Entities Escape
    • XML Entities Unescape
  1. Ask a Question
  2. Related:
  3. HTML Color Codes
  4. CSS Fonts
  5. Donate!


What are CSS Sprites

CSS sprites are a way to reduce the number of HTTP requests made for image resources referenced by your site. Images are combined into one larger image at defined X and Y coorindates. Having assigned this generated image to relevant page elements the background-position CSS property can then be used to shift the visible area to the required component image.

This technique can be very effective for improving site performance, particularly in situations where many small images, such as menu icons, are used. The Yahoo! home page, for example, employs the technique for exactly this.

Gotchas

There are a couple of really annoying browser bugs to watch out for when creating CSS sprites.

Opera

Opera (at least as far as version 9.0) won't recognise a background position greater than 2042px or smaller than -2042px using that boundary value instead. The tool takes care of this by creating new columns within the image output each time the vertical limit is reached.

Safari

Safari has a problem with repeating background images. Fortuantely this can be easily solved by specifying a large enough horizontal offset value (configurable).

Further Reading

A List Apart published an article entitled CSS Sprites: Image Slicing's Kiss of Death which explains the concepts behind CSS sprites. If you're new to this technique we'd strongly suggest heading over to A List Apart and taking a look.

© Dan's Tools