Scalable Vector Graphics (SVG) are part of the vector-based family of graphics. They are quite different from raster-based graphics that you may be accustomed to working with. The most common raster-based formats used on the web today are JPEG, GIF, and PNG. SVG has several advantages over raster-based formats.
For example, SVG graphics are created using mathematical formulas. This requires much less data to be processed since you do not have to store data for each individual pixel. In addition, vector images scale much better. Distortion of an image can occur when scaling raster-based graphics. SVG images can also be changed dynamically, making them especially suited for data-driven applications, such as charts.
Support for SVG
Most of the web browsers that are in use today have support for displaying SVG images. Internet Explorer 9, Firefox, Opera, Chrome, and Safari support SVG. For Internet Explorer earlier than version 9, users may have to install the Adobe SVG Viewer to be able to view SVG in the browser.
SVG viewBox
The SVG viewBox is used when creating SVG shapes. The view box is part of the canvas you want the viewer to see. Do not confuse the width and height of the view box with the width and height you set for the SVG document.
The width and height of the SVG element sets the size of the drawing canvas. The viewBox attributes uses four parameters: beginning x coordinate, beginning y coordinate, width of the view box, and height of the view box.
Basic Shapes
SVG images are generally created using an XML-based language. In HTML5, you can embed SVG elements directly into your HTML page. In this tutorial, we will show HTML of some basic shapes using the SVG and other related elements.
Circle
The
Ellipse
The
Rectangle
The
Line
The
Polyline
The
Polygon
The
Example
The following example of code will draw various lines to form an interesting image. We can use the