All of the SVG DOM interfaces that correspond directly to elements in the SVG language derive from the SVGElement
interface.
SVGElement.dataset
Read only
DOMStringMap
object which provides a list of key/value pairs of named data attributes which correspond to custom data attributes attached to the element. These can also be defined in SVG using attributes of the form data-*
, where *
is the key name for the pair. This works just like HTML's HTMLElement.dataset
property and HTML's data-*
global attribute.SVGElement.id
Read only
DOMString
representing the value of the id
attribute on the given element, or the empty string if id
is not present.SVGElement.xmlbase
Read only
DOMString
corresponding to the xml:base
attribute on the given element.SVGElement.ownerSVGElement
Read only
SVGSVGElement
referring to the nearest ancestor <svg>
element. null
if the given element is the outermost <svg>
element.SVGElement.viewportElement
Read only
SVGElement
, which established the current viewport. Often, the nearest ancestor <svg>
element. null
if the given element is the outermost <svg>
element.The SVGElement
interface doesn't provide any additional methods, but inherits methods from its parent, Element
.
Specification | Status | Comment |
---|---|---|
Scalable Vector Graphics (SVG) 2 The definition of 'SVGElement' in that specification. | Candidate Recommendation | Adds the dataset property. |
Scalable Vector Graphics (SVG) 1.1 (Second Edition) The definition of 'SVGElement' in that specification. | Recommendation | Initial definition |
Desktop | ||||||
---|---|---|---|---|---|---|
Chrome | Edge | Firefox | Internet Explorer | Opera | Safari | |
Basic support | Yes | Yes | Yes | 9 | Yes | Yes |
dataset |
55 | 17 | 51 | No | 41 | 10 |
offsetHeight
|
? — 50 | No | No | No | ? — 37 | No |
offsetLeft
|
? — 50 | No | No | No | ? — 37 | No |
offsetParent
|
? — 50 | No | No | No | ? — 37 | No |
offsetTop
|
? — 50 | No | No | No | ? — 37 | No |
offsetWidth
|
? — 50 | No | No | No | ? — 37 | No |
Mobile | |||||||
---|---|---|---|---|---|---|---|
Android webview | Chrome for Android | Edge Mobile | Firefox for Android | Opera for Android | iOS Safari | Samsung Internet | |
Basic support | Yes | Yes | Yes | Yes | Yes | Yes | ? |
dataset |
55 | 55 | 17 | 51 | 41 | 10 | ? |
offsetHeight
|
? — 50 | ? — 50 | No | No | ? — 37 | No | ? |
offsetLeft
|
? — 50 | ? — 50 | No | No | ? — 37 | No | ? |
offsetParent
|
? — 50 | ? — 50 | No | No | ? — 37 | No | ? |
offsetTop
|
? — 50 | ? — 50 | No | No | ? — 37 | No | ? |
offsetWidth
|
? — 50 | ? — 50 | No | No | ? — 37 | No | ? |
data-*
attributedata-*
attribute
© 2005–2018 Mozilla Developer Network and individual contributors.
Licensed under the Creative Commons Attribution-ShareAlike License v2.5 or later.
https://developer.mozilla.org/en-US/docs/Web/API/SVGElement