Positioning HTML5 SVG in the center of screen


To center SVG, add the following CSS:

# svgelem {
   margin-left:auto;
   margin-right:auto;
   display:block;
}

The following is our SVG:

<svg id="svgelem" height="200" xmlns="http://www.w3.org/2000/svg">
   <circle id="redcircle" cx="50" cy="50" r="50" fill="red" />
</svg>

Updated on: 29-Jan-2020

196 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements