Notes:svg (1)

Source: Internet
Author: User

SVG, the "Scalable Vector graphics" Scalable vector graphic, based on Extensible Markup Language, is used to describe a graphic format for two-dimensional vector graphics.

SVG is purely XML and can be inserted into HTML using the following methods:

    • Using <iframe> elements to embed SVG images
    • Using elements to embed SVG images
    • Embed an SVG image as a background image
    • Using <svg> elements directly
    • Using <embed> elements to embed SVG images
    • Using <object> elements to embed SVG images

Suppose you have an SVG file, named Test.svg, as shown below.

<?XML version= "1.0" encoding= "UTF-8"?><!DOCTYPE svg public '-//w3c//dtd svg 1.1//en ' http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd '><svgwidth= "$"Height= "$"xmlns= "Http://www.w3.org/2000/svg">//Here xmlns is necessary<rectwidth= "100%"Height= "100%"style= "Fill:cornflowerblue" /></svg>

The xmlns declaration space for SVG must be specified, otherwise it will not be parsed as an SVG tag.

Write an HTML file that reads as follows

<!DOCTYPE HTML><HTMLLang= "en"><Head>    <MetaCharSet= "UTF-8">    <title>Document</title></Head><Body>    <imgsrc= "Test.svg"></Body></HTML>

The results are as follows

You can also use SVG tags directly in the HTML5 document, as shown below

<!DOCTYPE HTML><HTMLLang= "en"><Head>    <MetaCharSet= "UTF-8">    <title>Document</title></Head><Body>    <svgwidth= "$"Height= "$">        <CircleCX= "+"Cy= "+"R= " the"style= "Fill:url (#orange_red)" />        <defs>            <lineargradientID= "Orange_red"X1= "0%"Y1= "0%"X2= "100%"y2= "0%">                <StopOffset= "20%"style= "Stop-color:rgb (255,255,0); Stop-opacity:1 "/>                <StopOffset= "80%"style= "Stop-color:rgb (255,0,0); Stop-opacity:1 "/>            </lineargradient>        </defs>    </svg></Body></HTML>

The performance is shown below

Notes:svg (1)

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.