files/en-us/web/api/svgmarkerelement/index.md
{{APIRef("SVG")}}
The SVGMarkerElement interface provides access to the properties of {{SVGElement("marker")}} elements, as well as methods to manipulate them. The {{SVGElement("marker")}} element defines the graphics used for drawing marks on a shape.
{{InheritanceDiagram}}
The following properties and methods all return, or act on the attributes of the {{SVGElement("marker")}} element represented by SVGMarkerElement.
This interface also inherits properties from its parent, {{domxref("SVGElement")}}.
{{domxref("SVGMarkerElement.markerUnits")}} {{ReadOnlyInline}}
SVG_MARKERUNITS_UNKNOWN which means that the {{SVGattr("markerUnits")}} attribute has a value other than the two predefined keywords.SVG_MARKERUNITS_USERSPACEONUSE which means that the {{SVGattr("markerUnits")}} attribute has the keyword value userSpaceOnUse.SVG_MARKERUNITS_STROKEWIDTH which means that the {{SVGattr("markerUnits")}} attribute has the keyword value strokeWidth.{{domxref("SVGMarkerElement.markerWidth")}} {{ReadOnlyInline}}
{{domxref("SVGMarkerElement.markerHeight")}} {{ReadOnlyInline}}
{{domxref("SVGMarkerElement.orientType")}} {{ReadOnlyInline}}
SVG_MARKER_ORIENT_UNKNOWN which means that the {{SVGattr("orient")}} attribute has a value other than the two predefined keywords.SVG_MARKERUNITS_ORIENT_AUTO which means that the {{SVGattr("orient")}} attribute has the keyword value auto.{{domxref("SVGMarkerElement.orient")}}
{{domxref("SVGMarkerElement.orientAngle")}} {{ReadOnlyInline}}
{{domxref("SVGMarkerElement.refX")}} {{ReadOnlyInline}}
{{domxref("SVGMarkerElement.refY")}} {{ReadOnlyInline}}
{{domxref("SVGMarkerElement.viewBox")}} {{ReadOnlyInline}}
{{domxref("SVGMarkerElement.preserveAspectRatio")}} {{ReadOnlyInline}}
This interface also inherits methods from its parent, {{domxref("SVGElement")}}.
auto.The following SVG will be referenced in the examples.
<svg id="svg" viewBox="0 0 100 100" xmlns="http://www.w3.org/2000/svg">
<defs>
<marker
id="arrow"
viewBox="0 0 10 10"
refX="5"
refY="5"
markerWidth="6"
markerHeight="6"
orient="90">
<path d="M 0 0 L 10 5 L 0 10 z" />
</marker>
</defs>
</svg>
The markerWidth property returns an {{domxref("SVGAnimatedLength")}} which contains an {{domxref("SVGLength")}} with the value of the {{SVGattr("markerWidth")}} attribute.
let marker = document.getElementById("arrow");
console.log(marker.markerWidth.baseVal.value); // 6
In the following example the value of the orient attribute is updated using setOrientToAngle() using an {{domxref("SVGAngle")}} created using {{domxref("SVGSVGElement.createSVGAngle()")}}.
let svg = document.getElementById("svg");
let marker = document.getElementById("arrow");
console.log(marker.orientAngle.baseVal.value); // value in SVG above - 90
let angle = svg.createSVGAngle();
angle.value = "110";
marker.setOrientToAngle(angle);
console.log(marker.orientAngle.baseVal.value); // new value - 110
{{Specifications}}
{{Compat}}