SVG Tutorial
SVG stands for Scalable Vector Graphics.
SVG 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.
SVG graphics are scalable and resolution-independent, which means they can be enlarged or reduced without distortion.
SVG is widely used in web design, icon creation, data visualization, and other graphics-related fields.
Main features of SVG
- **Vector graphics:** SVG uses path-based vector graphics, meaning graphics can be enlarged infinitely without distortion.
- **Scalability:** SVG files stay sharp at different resolutions, suitable for responsive design.
- **Interactivity:** SVG can be combined with JavaScript to achieve animations and interactive effects.
- **Integration:** SVG can be embedded directly into HTML5 without using external files.
- **Compatibility:** Most modern browsers support SVG.
Application scenarios of SVG
- **Web icons:** Thanks to SVG's scalability, it is very suitable for making web icons.
- **Data visualization:** SVG is often used to create charts and graphics, such as bar charts and pie charts.
- **Animation:** SVG can be combined with CSS and JavaScript to create complex animation effects.
- **Game development:** In some cases, SVG is also used to create simple game graphics.
- **Design prototypes:** Designers can use SVG to create interactive design prototypes.
A simple example
We created a simple red circle with a black border:
SVG Examples
<
html
<
body
<
h1
My first SVG
h1
<
svg
xmlns
=
"
http://www.w3.org/2000/svg
"
version
=
"
1.1
"
<
circle
cx
=
"
100
"
cy
=
"
50
"
r
=
"
40
"
stroke
=
"
black
"
stroke-width
=
"
2
"
fill
=
"
red
"
/>
svg
body
html
Try it »
Click the "Try it" button to see the running result.
SVG Examples
We can edit SVG examples online and view the running results online!
SVG Reference Manual
In the Runoob Tutorial, we provide you with a complete SVG reference manual, which lists all SVG elements in the W3C recommended standard (SVG Version 1.1).