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
In a project, you often need to use environment v...
Table of contents 1 A brief introduction to syste...
What is my.ini? my.ini is the configuration file ...
Table of contents Install Configuration Common Mi...
Table of contents 1. Developer Platform Configura...
This article mainly focuses on the installation a...
This article shares the specific code of vue+vide...
To connect Node-red to the database (mysql), you ...
1. Demand We have three tables. We need to classi...
In this section, the author describes the special...
Understanding of polling In fact, the focus of po...
EXPLAIN shows how MySQL uses indexes to process s...
Table of contents Preliminary Notes Problem Repro...
1. Create a sequence table CREATE TABLE `sequence...
1. Use basic text elements to mark up content Fir...