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
I recently took over a small program project, and...
Table of contents 1. Prerequisites 1.1 Supported ...
The default operating mode of MySQL is autocommit...
= Only when setting and updating does it have the...
tomcat server configuration When everyone is lear...
This may be an issue that is easily overlooked. F...
The Docker daemon uses HTTP_PROXY , HTTPS_PROXY ,...
Installation environment: CentOS7 64-bit MINI ver...
Table of contents Preface Idea startup speed Tomc...
This article shares the specific code for JavaScr...
Because the Raspberry Pi is based on ARM architec...
1. Methods for implementing components:組件名稱首字母必須大...
<br /> Focusing on the three aspects of text...
This article example shares the specific code for...
● I was planning to buy some cloud data to provid...