Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

How to include SVG code inside HTML file ?

  • Last Updated : 29 Sep, 2021

Introduction: SVG stands for Scalable Vector Graphics. It written in XML based format that is used to describe vector graphics. It is widely supported in browsers like Google Chrome, Firefox, Opera, etc. and many of them have the tendency to render SVG images. Designers also use SVG format for making the illustrations like logo, icons, etc. as they are pixel-perfect at any resolution.

In this article, we will insert a sample SVG code in the HTML file that will help you to include any SVG code that you want in your own HTML file.

<svg> Tag: In order to include SVG code, we have to use <svg> tag in the HTML code. It is a container which is used for SVG graphics. It is written inside the <body> section of the HTML file. It has both opening and closing tags. We also use width and height attributes with the <svg> tag. 

Now let’s see an example to understand it better.


<!DOCTYPE html>
    <title>Include SVG Code</title>
        <h2>Welcome To GFG</h2>
        <!-- SVG tag starts from here-->
        <svg width="600" height="150">
            <rect width="600" height="150" 
                fill="green" stroke="black" 
                stroke-width="6" />
        <!-- SVG tag ends here-->


Attention reader! Don’t stop learning now. Get hold of all the important HTML concepts with the Web Design for Beginners | HTML  course.

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!