Data URI Data URI is a scheme defined by RFC 2397 for embedding small files directly into documents. The following syntax can be used to convert small files into specified encoding and embed them directly into the page: data:[<MIME-type>][;base64],<data>
The Data URI scheme was introduced in HTML4.01 in the last century. To date, all major browsers support it except IE6 and IE7. However, IE8 still has limited support for Data URI, and only supports object (only for pictures), img, input type=image, link, and URLs in CSS, and the data size cannot be greater than 32K. advantage:
shortcoming :
MHTML MHTML is the abbreviation of MIME HTML (Multipurpose Internet Mail Extension HTML), which is defined by RFC 2557 as a solution for saving all contents of a multimedia page into the same document. This solution was proposed by Microsoft and has been supported since IE5.0, and Opera9.0 also started to support it. Safari can save files in .mht (MHTML file suffix) format, but does not support displaying it. MHTML is quite similar to Data URI, but has more powerful functions and more complex syntax, and does not have the disadvantage of "cannot be reused" in Data URI. However, MHTML is not flexible and convenient to use. For example, the URL for resource reference in the mht file can be a relative address, otherwise it must be an absolute address. The reason hedger's solution for IE in "Cross Browser Base64 Encoded Images Embedded in HTML" uses relative paths is because the declaration of Content-type:message/rfc822 makes IE parse according to MHTML. If the Content-type is not modified, the MHTML protocol needs to be used. At this time, absolute paths must be used, such as "MHTML - when you need data: URIs in IE7 and under". application The combination of Data URI and MHTML can completely solve all mainstream browsers. Since they cannot be cached and reused, they are not suitable for direct use in web pages, but they have great advantages when used appropriately for images in CSS and JavaScript files:
To facilitate the implementation of Data URI and MHTML in CSS, I wrote a Data URI & MHTML generator. You can see how to use it to generate Data URI & MHTML application examples. When using MHTML in a CSS file, the URL must use an absolute path, which is very inflexible. So you can consider using CSS expression to solve this problem (DEMO), for example: /* |
<<: Detailed explanation and classic interview questions of Vue life cycle and hook functions
>>: Implementation of CSS3 3D cool cube transformation animation
Confluence is paid, but it can be cracked for use...
This article example shares the specific code of ...
What does text-fill-color mean? Just from the lit...
There is a project developed on Mac, and the pack...
Table of contents background Why error handling? ...
1. Introduction MySQL comes with a replication so...
If we introduce the nesting rules of basic HTML w...
1. Pull the image docker pull registry.cn-hangzho...
1. First, generate the public key and private key...
When programmers do TypeScript/JavaScript develop...
Preface I always thought that UTF-8 was a univers...
In most cases, MySQL does not support Chinese whe...
1. Install the database 1) yum -y install mysql-s...
Compared with Windows system, Linux system provid...
Table of contents Preface Rationale Procedure 1. ...