Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

SVG Introduction

SVG Introduction


SVG, Scalable Vector Graphics, is an XML markup language for describing two-dimensional graphics.

Unlike bitmap images, SVG images are stored as text and can be scaled to any size without distortion, because they are based on mathematical descriptions rather than pixels.


Basic knowledge you should have before learning:

Before continuing, you should have a basic understanding of the following:

If you want to learn these first, please visit theHomeand select the corresponding tutorial.


What is SVG?


SVG is a W3C Recommendation

SVG became a W3C Recommendation on January 14, 2003.

For more information about W3C's SVG activities, please visit our W3C Tutorial.


History and Advantages of SVG

** SVG History:**

SVG was initiated by the W3C SVG Working Group established in 1998, emerging from six standards proposals submitted to W3C that year:

** SVG Advantages:**


View SVG File

SVG is widely supported in modern web browsers, including Chrome, Firefox, Safari, and more.

SVG images can be embedded into HTML documents via inline SVG code or external SVG files.


Create an SVG file

The following are the basic steps to create an SVG file:

  1. Open a text editor: Use your favorite text editor, such as Visual Studio Code, see the VScode Tutorial.

  2. Write SVG code: Write SVG code in the text editor. SVG code consists of XML tags describing graphic elements, attributes, and styles.

  3. Save file: Save the written SVG code as a file ending with the .svg extension, such as example.svg.

  4. Preview the SVG file: Open the SVG file in a web browser, or embed the SVG file into an HTML document, and preview the SVG image in the browser.

The following is a simple SVG file example, creating an SVG image containing one circle:



  



This code describes an SVG canvas with a width of 200 units and a height of 200 units. A circle is drawn on the canvas with center coordinates at (100, 100), a radius of 80 units, and a blue fill color.