Code Snippet

Home » Code Snippets » HTML » Base64 Encode of 1x1px Transparent GIF

Base64 Encode of 1x1px Transparent GIF

Just in case you need one. You can stretch it out to fill space as needed.

<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7">

Or a black one:

<img src="data:image/gif;base64,R0lGODlhAQABAIAAAAUEBAAAACwAAAAAAQABAAACAkQBADs=">

Subscribe to The Thread

  1. zsitro

    where should i use it?

  2. I use a transparent icon as cursor for one of my Narrowcasting solutions. That way, when you focus the browser window, the mouse disappears. Very neat trick. Set the cursor to none with a fallback to a transparant image. Works cross platform, cross browser.

    • Adam Parkes

      the purpose of hiding the cursor is?

    • Felix Kiunke

      THe purpose could be HTML5 Videos (cursor hiding like on youtube)

  3. Maybe will be useful write also where we can use this code.
    Can i use it with an href link to retrieve clicks statistics?

  4. wow thanks, i use it in combination with lazyload jQ plugin

  5. Viswanathan

    Good one… But IE7 will not support data URI, is there any alternative for that?

  6. Thanks but I donĀ“t understand the aplication of this code. Icons of 1×1?

  7. Pawel

    I think 2×1 would far more useful.

    • Julian Cizmic

      Yes, the point being to create a small file size. Anyway, you can always expand the file using the height and width attributes. However, this would only be useful in HTML e-mails, as using spacer GIFs on webpages isn’t very good web design.

  8. Muthu

    Give a demo. Plz.

  9. ApplePi

    Sounds like lots of n00bs around who weren’t around to remember the necessity ofthe venerable 1px x 1px transparent gif hack.

    Brings back memories. Mostly painful ones. :-)

Speak, my friend

At this moment, you have an awesome opportunity* to be the person your mother always wanted you to be: kind, helpful, and smart. Do that, and we'll give you a big ol' gold star for the day (literally).

Posting tips:
  • You can use basic HTML
  • When posting code, please turn all
    < characters into &lt;
  • If the code is multi-line, use
    <pre><code></code></pre>
Thank you,
~ The Management ~