Embedded Content

Inline SVG in HTML

The svg element starts an SVG subtree in an HTML document. The HTML parser assigns SVG elements to the SVG namespace; they are not ordinary HTML elements. Use viewBox for a scalable coordinate system and supply an accessible name for meaningful graphics. Decorative graphics may be hidden from assistive technology. SVG has its own vocabulary and conformance rules.

Formal Syntax & Structure

html syntaxhtml
<svg viewBox="0 0 20 20">…</svg>

Parameters & Attributes

NameTypeDescription
viewBoxfour numbersMinimum x and y, followed by width and height of the user-space rectangle.

Return Value

SVGSVGElement

Root of an SVG subtree; SVG content rules apply.

Working Example

Example Snippethtml
<svg viewBox="0 0 20 20" width="40" height="40" role="img" aria-label="Blue circle">  <circle cx="10" cy="10" r="8" fill="navy"/></svg>
HTML Reference