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
The plugin is installed in the Firefox browser. T...
During the development activity, I encountered a ...
Table of contents Vue2 Writing Vue3 plugin versio...
This article shares the specific code of jQuery t...
MyISAM and InnoDB are the most common storage eng...
Vulnerability Introduction The SigRed vulnerabili...
When we write pages, we sometimes find that the C...
Preface I always thought that UTF-8 was a univers...
1. Problem There is a table as shown below, we ne...
Given a div with the following background image: ...
A. Installation of MySQL backup tool xtrabackup 1...
This article shares the specific code of vue3 enc...
Table of contents 1. Implementation of counter 2....
As shown below: name describe character varying(n...
Due to the limitation of CPU permissions, communi...