MDN’s new design is in Beta! A sneak peek: https://blog.mozilla.org/opendesign/mdns-new-design-beta/

Hubo un error de script en esta página. Mientras los editores del sitio lo solucionan, puedes ver una parte del contenido más abajo.

Esta traducción está incompleta. Por favor, ayuda a traducir este artículo del inglés.

The svg element can be used to embed an SVG fragment inside the current document (for example, an HTML document). This SVG fragment has its own viewport and coordinate system.

Usage context

{{svginfo}}

Example

Consider the following SVG image (representing the national flag of Italy):

<svg xmlns="http://www.w3.org/2000/svg" 
     width="150" height="100" viewBox="0 0 3 2">

  <rect width="1" height="2" x="0" fill="#008d46" />
  <rect width="1" height="2" x="1" fill="#ffffff" />
  <rect width="1" height="2" x="2" fill="#d2232c" />
</svg>

It could be included in an HTML5 document as follows:

<!DOCTYPE html>
<html>
<head>
  <meta charset="UTF-8" />
  <title>HTML/SVG Example</title>
</head>

<body>

  <svg width="150" height="100" viewBox="0 0 3 2">
    <rect width="1" height="2" x="0" fill="#008d46" />
    <rect width="1" height="2" x="1" fill="#ffffff" />
    <rect width="1" height="2" x="2" fill="#d2232c" />
  </svg>

</body>
</html>

Attributes

Global attributes

Specific attributes

  • {{SVGAttr("version")}}
  • {{SVGAttr("baseProfile")}}
  • {{SVGAttr("x")}}
  • {{SVGAttr("y")}}
  • {{SVGAttr("width")}}
  • {{SVGAttr("height")}}
  • {{SVGAttr("preserveAspectRatio")}}
  • {{SVGAttr("contentScriptType")}}
  • {{SVGAttr("contentStyleType")}}
  • {{SVGAttr("viewBox")}}

DOM Interface

This element implements the SVGSVGElement interface.

Specifications

Specification Status Comment
{{SpecName('SVG2', 'struct.html#NewDocument', '<svg>')}} {{Spec2('SVG2')}}  
{{SpecName('SVG1.1', 'struct.html#NewDocument', '<svg>')}} {{Spec2('SVG1.1')}} Initial definition

Browser compatibility

{{Compatibility Table}}

Feature Chrome Edge Firefox (Gecko) IE Opera Safari
Basic support {{CompatChrome("1.0")}} {{CompatVersionUnknown}} {{CompatGeckoDesktop('1.8')}} {{CompatIE('9.0')}} {{CompatOpera('8.0')}} {{CompatSafari('3.0.4')}}
Feature Android Edge Firefox Mobile (Gecko) IE Phone Opera Mobile Safari Mobile
Basic support {{CompatAndroid('3.0')}} {{CompatVersionUnknown}} {{CompatGeckoMobile('1.8')}} {{CompatNo}} {{CompatVersionUnknown}} {{CompatSafari('3.0.4')}}

The chart is based on these sources.

{{SVGRef}}

Etiquetas y colaboradores del documento

 Colaboradores en esta página: mbenitez01
 Última actualización por: mbenitez01,