Use data URI scheme to embed images in webpages

Source: Internet
Author: User

 

Data URI scheme allows us to include data in a webpage using inline-code, which can be used in Html, CSS, and Javascript.

 

Data URI scheme is often used to embed images into webpages. It is used as follows:

 

The data URI scheme format is as follows:

Data: [<MIME-type>] [; base64], <data>

 

The format is relatively simple. We can see that the above img is a jpg image encoded with base64.
Embed this img into this page, as shown below:

 

In addition to base64 encoding, you can also use hexadecimal URL encoding in the form of % xx, as shown below:

Generating image data

According to the above format, we can write a small program to generate, but we don't need to be so troublesome. Many websites provide this (free) service.

The following are some examples:

1. http://dataurl.sveinbjorn.org/dataurlmaker

Provides preview for convenient copying.

 

2. http://websemantics.co.uk/online_tools/image_to_data_uri_convertor/

Provides preview and generates the URI data of the corresponding CSS.

 

3. http://software.hixie.ch/utilities/cgi/data/data

Tip: generation is not limited to image data. You can use three methods (see steps 1, 2, and 3) to specify the encoding method, but the interface is unfriendly.

Used in group presentations

Click the insert/edit image button:

 

In the following window, use any of the above URLs to generate image data, copy and paste the data to the image address text box:

 

Click Insert. OK, for example:

View effects: http://space.cnblogs.com/group/topic/41938/

 

Data URI scheme allows us to include data in a webpage using inline-code, which can be used in Html, CSS, and Javascript.

 

Data URI scheme is often used to embed images into webpages. It is used as follows:

 

The data URI scheme format is as follows:

Data: [<MIME-type>] [; base64], <data>

 

The format is relatively simple. We can see that the above img is a jpg image encoded with base64.
Embed this img into this page, as shown below:

 

In addition to base64 encoding, you can also use hexadecimal URL encoding in the form of % xx, as shown below:

Generating image data

According to the above format, we can write a small program to generate, but we don't need to be so troublesome. Many websites provide this (free) service.

The following are some examples:

1. http://dataurl.sveinbjorn.org/dataurlmaker

Provides preview for convenient copying.

 

2. http://websemantics.co.uk/online_tools/image_to_data_uri_convertor/

Provides preview and generates the URI data of the corresponding CSS.

 

3. http://software.hixie.ch/utilities/cgi/data/data

Tip: generation is not limited to image data. You can use three methods (see steps 1, 2, and 3) to specify the encoding method, but the interface is unfriendly.

Used in group presentations

Click the insert/edit image button:

 

In the following window, use any of the above URLs to generate image data, copy and paste the data to the image address text box:

 

Click Insert. OK, for example:

View effects: http://space.cnblogs.com/group/topic/41938/

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.