Home > Web Front-end > CSS Tutorial > What\'s the Smallest Data URI for a 1x1 Transparent Image?

What\'s the Smallest Data URI for a 1x1 Transparent Image?

Mary-Kate Olsen
Release: 2024-12-03 12:30:11
Original
523 people have browsed it

What's the Smallest Data URI for a 1x1 Transparent Image?

Determining the Smallest Possible Data URI Image for a Transparent Image

Question:

Seeking to minimize HTTP requests, you aim to utilize a transparent 1x1 image with a background image. What is the most concise data URI string that can generate a transparent image?

Answer:

Transparent GIF (Slightly Longer but Stable - 78 bytes):

data:image/gif;base64,R0lGODlhAQABAIAAAAAAAP///yH5BAEAAAAALAAAAAABAAEAAAIBRAA7
Copy after login

Unstable Transparent GIF (Shorter - 74 bytes):

data:image/gif;base64,R0lGODlhAQABAAAAACH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==
Copy after login

Caution:

Despite being shorter, the unstable GIF may cause CSS glitches and prevent background images from displaying correctly in some browsers. Therefore, it is recommended to use the slightly longer but more stable version.

Additional Tip:

Never Omit the "image/gif" Type:

Contrary to some suggestions, omitting the "image/gif" type will cause errors in multiple browsers.

The above is the detailed content of What\'s the Smallest Data URI for a 1x1 Transparent Image?. For more information, please follow other related articles on the PHP Chinese website!

source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template