Open In App

SVG <style> Element

SVG stands for Scalable Vector Graphic. It can be used to make graphics and animations like in HTML canvas.

The SVG <style> element allows style sheets to be embedded directly within the SVG content.



Syntax:

<style>
    Styling Content
</style>

Attribute:



Example 1: 




<!DOCTYPE html>
<html>
<body>
    <svg viewBox="0 0 20 20"
         xmlns="http://www.w3.org/2000/svg">
        <style>
            circle {
              fill: green;
            }
        </style>
        <circle cx="5" cy="5" r="4" />
    </svg>
</body>
 
</html>

Output:

 

Example 2: 




<!DOCTYPE html>
<html>
 
<body>
    <svg viewBox="0 0 20 20"
         xmlns="http://www.w3.org/2000/svg">
        <style>
            rect {
              fill: green;
              stroke: black;
              stroke-width: .1px;
            }
        </style>
        <rect height="5" width='5'/>
    </svg>
</body>
 
</html>

Output:

Browsers Supported: The following browsers are supported by this SVG element:


Article Tags :