An example of a simple SVG graphic:
Here is the SVG file (SVG files are saved with the .svg extension):
SVG code explanation:
The first line contains the XML declaration. Notice the standalone attribute, which specifies whether the SVG file "stands alone", or contains a reference to an external file. standalone="no" means that the SVG document has a reference to an external file - in this case, the DTD.
The second and the third line refer to the SVG DTD. This DTD resides at w3.org, and contains all allowable SVG elements.
The SVG code begins with the <svg> element. This is the root element. The xmlns attribute defines the SVG namespace and the version attribute defines the SVG version to be used.
The <circle> element is used to draw a circle. The cx and cy attributes define the x and y coordinates of the center of the circle. If cx and cy are omitted, the circle's center is set to (0, 0). The r attribute defines the radius of the circle.
The stroke and stroke-width attributes control how the outline of a shape appears. We set the outline of the circle to a 2px wide, black "border".
The fill attribute refers to the color inside the circle. We set the fill color to red.
The closing </svg> tag closes the root element and the document.
Note: Since SVG is written in XML, all elements must be properly closed!
The perfect solution for professionals who need to balance work, family, and career building.
More than 10 000 certificates already issued!
The HTML Certificate documents your knowledge of HTML.
The HTML5 Certificate documents your knowledge of advanced HTML5.
The CSS Certificate documents your knowledge of advanced CSS.
The JavaScript Certificate documents your knowledge of JavaScript and HTML DOM.
The jQuery Certificate documents your knowledge of jQuery.
The XML Certificate documents your knowledge of XML, XML DOM and XSLT.
The ASP Certificate documents your knowledge of ASP, SQL, and ADO.
The PHP Certificate documents your knowledge of PHP and SQL (MySQL).
Your message has been sent to W3Schools.