CSS marker-end Property
The CSS marker-end property specifies an SVG marker graphic to display at the ending vertex of a supported SVG shape or path subpath.
It is commonly used to add arrowheads to lines, connectors, and diagrams. The marker graphic is defined using an SVG <marker> element and referenced through the CSS url() function.
marker-end Syntax
The marker-end property accepts none or a URL reference to an SVG marker definition. CSS-wide keywords are also supported.
Basic Syntax
selector {
marker-end: url(#marker-id);
}
Arrow Marker
line {
marker-end: url(#arrow);
}
Circle Marker
path {
marker-end: url(#circle-marker);
}
Remove the End Marker
path {
marker-end: none;
}
CSS-Wide Keywords
path {
marker-end: initial;
}
path {
marker-end: inherit;
}
path {
marker-end: unset;
}
path {
marker-end: revert;
}
path {
marker-end: revert-layer;
}
The initial value of marker-end is none.
Property Values
| Value | Description |
|---|---|
none |
Displays no marker at the ending vertex. |
url() |
References an SVG <marker> definition to display at the ending vertex. |
initial |
Resets the property to its initial value of none. |
inherit |
Inherits the computed marker reference from the parent element. |
unset |
Behaves like inherit because the property is inherited. |
revert |
Reverts the property according to cascade origin rules. |
revert-layer |
Reverts the property according to cascade layer rules. |
Property Characteristics
| Characteristic | Value |
|---|---|
| Initial value | none |
| Inherited | Yes |
| Applies to | Supported SVG graphics elements, including paths, lines, polylines, and polygons |
| Computed value | Specified keyword or absolute URL reference |
| Animation type | Discrete |
| Shorthand property | marker |
| Marker position | Ending vertex of each applicable path subpath |
| Common use | Arrowheads, flowchart connectors, and SVG path endpoints |
How It Works
The marker-end property attaches a reusable SVG graphic to the final vertex of a supported shape. The browser positions the marker using the geometry of the shape and the reference point defined by the marker.
Unlike the marker shorthand, marker-end affects only the ending position. It does not automatically add markers to starting or intermediate vertices.
HTML Example
<svg viewBox="0 0 300 100" xmlns="http://www.w3.org/2000/svg">
<defs>
<marker id="arrow" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="auto">
<path d="M 0 0 L 10 5 L 0 10 z" fill="#2563eb" />
</marker>
</defs>
<line class="arrow-line" x1="30" y1="50" x2="270" y2="50" stroke="#2563eb" stroke-width="3" />
</svg>
CSS Example
.arrow-line {
marker-end: url(#arrow);
}
The arrowhead appears at the right endpoint because the line runs from left to right. If the line's coordinates are reversed, the marker appears at the new ending point.
Important Consideration
The ending vertex is determined by the SVG shape's geometry, not by the physical right or bottom side of the element.
Defining End Markers
An SVG marker is created using the <marker> element, commonly placed inside <defs>. The marker's id connects the definition to the CSS property.
Arrowhead Definition
<svg xmlns="http://www.w3.org/2000/svg">
<defs>
<marker id="end-arrow" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="auto">
<path d="M 0 0 L 10 5 L 0 10 z" fill="#2563eb" />
</marker>
</defs>
</svg>
Reference the Arrowhead
line {
marker-end: url(#end-arrow);
}
Circle Definition
<marker id="end-circle" viewBox="0 0 10 10" refX="5" refY="5" markerWidth="8" markerHeight="8" markerUnits="userSpaceOnUse">
<circle cx="5" cy="5" r="4" fill="#f97316" />
</marker>
Reference the Circle
path {
marker-end: url(#end-circle);
}
Common Marker Attributes
| Attribute | Description |
|---|---|
id |
Identifies the marker for CSS URL references. |
viewBox |
Defines the internal coordinate system of the marker graphic. |
refX |
Specifies the horizontal point aligned with the ending vertex. |
refY |
Specifies the vertical point aligned with the ending vertex. |
markerWidth |
Sets the marker viewport width. |
markerHeight |
Sets the marker viewport height. |
markerUnits |
Determines how marker dimensions are measured. |
orient |
Controls the rotation of the marker graphic. |
Important Consideration
The marker definition must be accessible to the referencing SVG element. An incorrect ID or an invalid marker reference prevents the intended graphic from appearing.
Marker Placement
The marker-end property places a marker at the ending vertex of each applicable path subpath. The location depends on how the SVG shape is defined.
Line
<line x1="20" y1="50" x2="220" y2="50" />
The marker appears at x2="220" and y2="50", which define the line's endpoint.
Polyline
<polyline points="20,80 80,20 140,80 200,20" />
The marker appears at the final coordinate pair, 200,20. The intermediate vertices do not receive markers from marker-end.
Polygon
<polygon points="100,10 180,80 20,80" />
A polygon is closed. Its ending marker is positioned at the closing vertex, which coincides with the starting vertex.
Path
<path d="M 20 80 L 100 20 L 180 80" />
The ending marker appears at the final point of the path.
Multiple Subpaths
<path d="M 20 30 L 120 30 M 20 80 L 120 80" />
This path contains two separate subpaths. Each subpath has its own ending vertex, so marker-end can display a marker at both endpoints.
Important Consideration
The marker is placed according to the final vertex of the geometry. It does not automatically appear at the visually rightmost or bottommost point.
Marker Orientation
The SVG orient attribute determines how the marker rotates at the ending vertex. This is especially important for arrowheads.
Automatic Orientation
<marker id="arrow-auto" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="auto">
<path d="M 0 0 L 10 5 L 0 10 z" fill="#2563eb" />
</marker>
With orient="auto", the marker rotates to follow the direction of the path at its endpoint.
Fixed Orientation
<marker id="arrow-fixed" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="45">
<path d="M 0 0 L 10 5 L 0 10 z" fill="#2563eb" />
</marker>
The marker uses a fixed rotation of 45 degrees rather than following the path direction.
Automatic Start-Reverse Orientation
<marker id="arrow-reverse" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" orient="auto-start-reverse">
<path d="M 0 0 L 10 5 L 0 10 z" fill="#2563eb" />
</marker>
The auto-start-reverse value behaves like auto for an ending marker. Its additional reversal applies to starting markers.
Important Consideration
Marker rotation is configured in the SVG marker definition, not through the marker-end property itself.
Marker Sizing
Marker dimensions are controlled by SVG marker attributes. The markerWidth, markerHeight, and markerUnits attributes determine how large the marker appears.
Scale with Stroke Width
<marker id="scaled-arrow" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" markerUnits="strokeWidth" orient="auto">
<path d="M 0 0 L 10 5 L 0 10 z" fill="#2563eb" />
</marker>
The strokeWidth value makes marker dimensions scale with the stroke width of the referencing element.
User-Space Units
<marker id="fixed-size-arrow" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="12" markerHeight="12" markerUnits="userSpaceOnUse" orient="auto">
<path d="M 0 0 L 10 5 L 0 10 z" fill="#2563eb" />
</marker>
The userSpaceOnUse value measures marker dimensions in the current user coordinate system rather than scaling directly with stroke width.
Change the Line Width
.arrow-line {
stroke-width: 5;
marker-end: url(#scaled-arrow);
}
When the marker uses markerUnits="strokeWidth", increasing the stroke width also increases the marker's displayed size.
Important Consideration
Marker sizing is separate from the marker-end reference. Change the SVG marker definition to control its dimensions.
marker Shorthand
The marker shorthand sets marker-start, marker-mid, and marker-end to the same value.
Shorthand Example
path {
marker: url(#circle-marker);
}
Equivalent Longhand Declarations
path {
marker-start: url(#circle-marker);
marker-mid: url(#circle-marker);
marker-end: url(#circle-marker);
}
Both examples assign the circle marker to all applicable marker positions.
Ending Marker Only
path {
marker-start: none;
marker-mid: none;
marker-end: url(#arrow);
}
Only the ending vertex receives the arrow marker.
Override the Shorthand
path {
marker: url(#circle-marker);
marker-end: url(#arrow);
}
The starting and intermediate positions use the circle marker, while the ending position uses the arrow marker.
Shorthand Reset
path {
marker-end: url(#arrow);
marker: none;
}
The later shorthand resets all three marker positions to none, removing the ending arrow.
Removing End Markers
Set marker-end to none to remove only the ending marker.
Remove the Ending Marker
path {
marker-end: none;
}
Keep Other Markers
path {
marker-start: url(#circle-marker);
marker-mid: url(#circle-marker);
marker-end: none;
}
The starting and intermediate markers remain assigned, while the ending marker is removed.
Remove All Markers
path {
marker: none;
}
Use the shorthand when all marker positions should be cleared.
marker-end Example
This example demonstrates how marker-end adds arrowheads to the endpoints of SVG lines and a polyline.
HTML Example
<svg class="marker-end-demo" viewBox="0 0 340 220" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="Three SVG lines with arrowheads at their endpoints">
<defs>
<marker id="demo-end-arrow" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="7" markerHeight="7" markerUnits="userSpaceOnUse" orient="auto">
<path d="M 0 0 L 10 5 L 0 10 z" fill="#2563eb" />
</marker>
</defs>
<line class="demo-line" x1="30" y1="40" x2="300" y2="40" />
<line class="demo-line" x1="300" y1="100" x2="30" y2="100" />
<polyline class="demo-line" points="30,190 110,140 190,190 300,150" fill="none" />
</svg>
CSS Example
.marker-end-demo {
display: block;
width: 100%;
max-width: 480px;
height: auto;
}
.marker-end-demo .demo-line {
fill: none;
stroke: #2563eb;
stroke-width: 3;
marker-end: url(#demo-end-arrow);
}
The first arrow points right, the second points left, and the third follows the direction of the polyline's final segment. Each marker appears at the ending vertex of its shape.
Remove the Arrowheads
.marker-end-demo .demo-line {
marker-end: none;
}
Use a Circle Instead
Define a circle marker and reference it using marker-end:
<marker id="demo-end-circle" viewBox="0 0 10 10" refX="5" refY="5" markerWidth="10" markerHeight="10" markerUnits="userSpaceOnUse">
<circle cx="5" cy="5" r="4" fill="#f97316" />
</marker>
.marker-end-demo .demo-line {
marker-end: url(#demo-end-circle);
}
Apply Markers to All Vertices
.marker-end-demo .demo-line {
marker: url(#demo-end-arrow);
}
Using the shorthand assigns the marker to the starting, intermediate, and ending positions instead of only the endpoint.
Common Mistakes
Confusing marker-end with HTML List Markers
The marker-end property applies SVG graphics to path endpoints. It does not control bullets or numbering in ordinary HTML lists.
Using an Undefined Marker ID
line {
marker-end: url(#missing-arrow);
}
The marker will not render as intended if the referenced SVG marker does not exist or cannot be accessed.
Expecting the Arrow to Always Point Right
Marker placement follows the SVG shape's ending vertex. With automatic orientation, the arrow follows the direction of the final segment.
Using Incorrect Reference Coordinates
Incorrect refX and refY values can make the marker appear offset from the endpoint.
Forgetting Automatic Orientation
An arrowhead may not follow the line direction unless its SVG marker definition uses an appropriate orient value.
Expecting Markers at Intermediate Vertices
The marker-end property affects ending vertices only. Use marker-mid for intermediate vertices.
Overwriting the Property with the Shorthand
path {
marker-end: url(#arrow);
marker: none;
}
The later shorthand removes the ending marker.
Expecting the Property to Work on Ordinary HTML Boxes
The property is designed for supported SVG graphics, not for adding arrowheads to regular HTML elements.
Important Considerations
Keep the following points in mind when using marker-end:
- The property displays an SVG marker at an ending vertex.
- The initial value is
none. - The property is inherited.
- It accepts a marker URL reference or
none. - Markers are defined using the SVG
<marker>element. - The marker definition is commonly placed inside
<defs>. - The marker's
idis used in the CSS URL reference. - The ending vertex depends on the SVG shape's geometry.
- Reversing a line's coordinates changes its ending vertex.
- Paths containing multiple subpaths can have multiple ending markers.
- Closed shapes can have coincident starting and ending marker positions.
- The property does not add markers to intermediate vertices.
- The
orientattribute controls marker rotation. - The
autovalue aligns the marker with the endpoint direction. - The
refXandrefYattributes control marker alignment. - The
markerWidthandmarkerHeightattributes control marker viewport dimensions. - The
markerUnitsattribute controls how marker dimensions are measured. - Markers can scale with the stroke width of the referencing element.
- The
markershorthand sets all three marker positions. - Later shorthand declarations can override
marker-end. - Setting
marker-end: noneremoves only the ending marker. - Use
marker-startfor starting vertices. - Use
marker-midfor intermediate vertices. - Use the
markershorthand when the same marker is needed at all positions. - SVG markers are different from HTML list markers.
Browser Support
The CSS marker-end property is widely supported in modern browsers for SVG graphics, including Chrome, Edge, Firefox, Safari, and Opera.
Support for external SVG references and certain marker features can vary. Test marker orientation, sizing, and references in the browsers your project supports.
For current compatibility information, visit Can I Use? and search for SVG markers.
Specifications
The marker-end property is defined in the SVG 2 specification and the CSS Fill and Stroke Module Level 3 specification.
CSS Fill and Stroke Module Level 3: marker-end
These specifications describe how ending markers are referenced, positioned, and rendered on supported SVG graphics.
For additional documentation and examples, consult MDN Web Docs.
