Marker

The <marker> element defines the graphic that is to be used for drawing arrowheads or polymarkers on a given <path>, <line>, <polyline> or <polygon> element (MDN).

You attach markers to the shape using the marker-start, marker-mid, and marker-end attributes.

SVG attributes

marker-start

Defines the arrowhead or polymarker that will be drawn at the first vertex of the given shape.

marker-end

Defines the arrowhead or polymarker that will be drawn at the last vertex of the given shape.

marker-mid

Defines the arrowhead or polymarker that will be drawn at all interior vertices of the given shape.

| LIVE PREVIEW

SVG elements

<marker>

Defines a shape for drawing arrowheads or polymarkers.

  • markerWidth width of the marker
  • markerHeight height of the marker
  • markerUnits defines the coordinate system for markerWidth, markerHeight, and children of the <marker>; specify userSpaceOnUse (use absolute coordinate) or strokeWidth (default)
  • orient defines the orientation of the marker relative to the shape it is attached to:
    • auto: orient the marker such that its positive x-axis is pointing to the direction relative to the path
    • auto-start-reverse: like auto, but if the marker is specified as marker-start, then rotate it by 180° (makes the same marker points at opposite direction when specified as marker-start and marker-end)
    • an angle: e.g. 0 (this is the default)
  • refX defines the x coordinate for the reference point of the marker (think of it as an offset); specify left, center, right, or a coordinate/length (default is 0)
  • refY defines the y coordinate for the reference point of the marker (think of it as an offset); specify top, center, bottom, or a coordinate/length (default is 0)
  • viewBox bounds of the SVG viewport, e.g. 0 0 80 20 (see View Box)
  • preserveAspectRatio defines how to fit the viewport if aspect ratio of the viewBox does not match the given markerWidth and markerHeight, e.g. xMidYMid meet (see preserveAspectRatio)
| LIVE PREVIEW

References