Open In App

SVG <script> Element

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

The SVG <script> element allows adding scripts to an SVG document.



Syntax:

<script>
    // Script Here 
</script>

Attributes:



Example 1: 




<!DOCTYPE html>
<html>
 
<body>
    <svg width="400" height="200"
        xmlns="http://www.w3.org/2000/svg">
        <script type="text/javascript">
            alert("GeeksforGeeks");
        </script>   
    </svg>
</body>
 
</html>

Output:

 

Example 2: 




<!DOCTYPE html>
<html>
 
<body>
    <svg width="400" height="200"
        xmlns="http://www.w3.org/2000/svg">
        <script>
            console.log(
"GeeksforGeeks: Computer Science Portal for Geeks");
        </script>   
    </svg>
</body>
 
</html>

Output:

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


Article Tags :