CSS marker-start Property
The CSS marker-start property specifies an SVG marker graphic to display at the starting vertex of a supported SVG shape or path subpath.
It is commonly used to add arrowheads, circles, and other symbols to the beginning of lines and paths. The marker graphic is defined using an SVG <marker> element and referenced through the CSS url() function.
marker-start Syntax
The marker-start property accepts none or a URL reference to an SVG marker definition. CSS-wide keywords are also supported.
Basic Syntax
selector {
marker-start: url(#marker-id);
}
Arrow Marker
line {
marker-start: url(#arrow);
}
Circle Marker
path {
marker-start: url(#circle-marker);
}
Remove the Starting Marker
path {
marker-start: none;
}
CSS-Wide Keywords
path {
marker-start: initial;
}
path {
marker-start: inherit;
}
path {
marker-start: unset;
}
path {
marker-start: revert;
}
path {
marker-start: revert-layer;
}
The initial value of marker-start is none.
Property Values
| Value | Description |
|---|---|
none |
Displays no marker at the starting vertex. |
url() |
References an SVG <marker> definition to display at the starting 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 | Starting vertex of each applicable path subpath |
| Common use | SVG arrows, connectors, and path endpoint decorations |
How It Works
The marker-start property attaches a reusable SVG graphic to the first vertex of a supported shape. The browser positions the marker using the shape's geometry and the reference point defined in the SVG marker.
Unlike the marker shorthand, marker-start affects only the starting position. It does not automatically add markers to intermediate or ending vertices.
HTML Example
<svg viewBox="0 0 300 100" xmlns="http://www.w3.org/2000/svg">
<defs>
<marker id="start-circle" viewBox="0 0 10 10" refX="5" refY="5" markerWidth="12" markerHeight="12" markerUnits="userSpaceOnUse">
<circle cx="5" cy="5" r="4" fill="#f97316" />
</marker>
</defs>
<line class="marked-line" x1="30" y1="50" x2="270" y2="50" stroke="#2563eb" stroke-width="3" />
</svg>
CSS Example
.marked-line {
marker-start: url(#start-circle);
}
The orange circle appears at the line's starting point, defined by x1 and y1. The ending point remains unmarked.
Important Consideration
The starting vertex is determined by the SVG geometry, not by the leftmost or topmost position of the shape.
Defining Start Markers
SVG markers are defined with the <marker> element, usually inside an SVG <defs> container. Each marker has an id that can be referenced from CSS.
Circle Marker Definition
<svg xmlns="http://www.w3.org/2000/svg">
<defs>
<marker id="start-point" viewBox="0 0 10 10" refX="5" refY="5" markerWidth="12" markerHeight="12" markerUnits="userSpaceOnUse">
<circle cx="5" cy="5" r="4" fill="#f97316" />
</marker>
</defs>
</svg>
Reference the Circle Marker
line {
marker-start: url(#start-point);
}
Arrow Marker Definition
<marker id="start-arrow" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="12" markerHeight="12" markerUnits="userSpaceOnUse" orient="auto-start-reverse">
<path d="M 0 0 L 10 5 L 0 10 z" fill="#2563eb" />
</marker>
Reference the Arrow Marker
path {
marker-start: url(#start-arrow);
}
The auto-start-reverse orientation is useful for arrowheads at the beginning of a path because it reverses their direction relative to the path's starting tangent.
Common Marker Attributes
| Attribute | Description |
|---|---|
id |
Identifies the marker for CSS URL references. |
viewBox |
Defines the marker's internal coordinate system. |
refX |
Sets the horizontal reference point aligned with the starting vertex. |
refY |
Sets the vertical reference point aligned with the starting vertex. |
markerWidth |
Defines the marker viewport width. |
markerHeight |
Defines the marker viewport height. |
markerUnits |
Controls how marker dimensions are measured. |
orient |
Controls marker rotation at the starting vertex. |
Important Consideration
The marker definition must be accessible to the SVG element referencing it. An incorrect ID or invalid reference prevents the intended graphic from appearing.
Marker Placement
The marker-start property places markers at the starting vertices of supported SVG shapes. Their positions depend on the shape's coordinates and path commands.
Line
<line x1="20" y1="50" x2="220" y2="50" />
The marker appears at 20,50, the coordinate defined by x1 and y1.
Polyline
<polyline points="20,80 80,20 140,80 200,20" />
The marker appears at the first coordinate pair, 20,80. The remaining vertices do not receive markers from marker-start.
Polygon
<polygon points="100,10 180,80 20,80" />
A polygon is closed. Its starting marker appears at the first vertex, which is also where the closing segment returns.
Path
<path d="M 20 80 L 100 20 L 180 80" />
The marker appears at the point established by the initial M command.
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 starting vertex, so marker-start can display a marker at both starting points.
Curved Paths
<path d="M 20 90 Q 100 10 180 90" />
The starting marker appears at 20,90, where the curved path begins. The control point does not receive a starting marker.
Important Consideration
Reversing the coordinate order of a line or path changes which point is considered its starting vertex.
Marker Orientation
The SVG orient attribute determines how a marker rotates at the starting vertex. This is especially important when using directional arrowheads.
Automatic Orientation
<marker id="auto-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>
With orient="auto", the marker follows the direction of the path at its starting vertex. A right-pointing arrow graphic therefore points along a left-to-right line.
Automatic Start-Reverse Orientation
<marker id="reverse-arrow" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="12" markerHeight="12" markerUnits="userSpaceOnUse" orient="auto-start-reverse">
<path d="M 0 0 L 10 5 L 0 10 z" fill="#2563eb" />
</marker>
The auto-start-reverse value rotates the starting marker 180 degrees from its automatic orientation. This allows an arrowhead at the beginning of a line to point outward, away from the line.
Fixed Orientation
<marker id="fixed-arrow" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="12" markerHeight="12" markerUnits="userSpaceOnUse" orient="45">
<path d="M 0 0 L 10 5 L 0 10 z" fill="#2563eb" />
</marker>
The marker uses a fixed 45-degree rotation rather than aligning automatically with the path direction.
Important Consideration
The auto-start-reverse value is particularly useful when the same marker definition is used for both starting and ending arrowheads.
Marker Sizing
Marker size is controlled through SVG attributes such as markerWidth, markerHeight, viewBox, and markerUnits.
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-start-reverse">
<path d="M 0 0 L 10 5 L 0 10 z" fill="#2563eb" />
</marker>
With markerUnits="strokeWidth", marker dimensions scale according to the stroke width of the referencing SVG element.
User-Space Units
<marker id="fixed-arrow" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="12" markerHeight="12" markerUnits="userSpaceOnUse" orient="auto-start-reverse">
<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 Stroke Width
.marked-line {
stroke-width: 5;
marker-start: url(#scaled-arrow);
}
When the marker uses stroke-width units, increasing the line's stroke width also increases the marker's displayed size.
Important Consideration
The marker-start property selects the marker graphic. Its size is configured separately in the SVG marker definition.
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 same marker to all applicable marker positions.
Starting Marker Only
path {
marker-start: url(#circle-marker);
marker-mid: none;
marker-end: none;
}
Only the starting vertex receives a marker.
Override the Shorthand
path {
marker: url(#circle-marker);
marker-start: url(#arrow-marker);
}
The starting position uses the arrow marker, while the intermediate and ending positions use circle markers.
Shorthand Reset
path {
marker-start: url(#arrow-marker);
marker: none;
}
The later shorthand resets all three marker positions to none, removing the starting marker.
Removing Starting Markers
Set marker-start to none to remove only the starting marker without changing the intermediate or ending marker properties.
Remove the Starting Marker
path {
marker-start: none;
}
Keep Other Markers
path {
marker-start: none;
marker-mid: url(#circle-marker);
marker-end: url(#arrow-marker);
}
The intermediate and ending markers remain assigned, while the starting marker is removed.
Remove All Markers
path {
marker: none;
}
Use the shorthand when all marker positions should be cleared.
marker-start Example
This example demonstrates how marker-start adds orange circles to the beginning of SVG lines and a polyline. Only the starting vertices receive markers.
HTML Example
<svg class="marker-start-demo" viewBox="0 0 340 220" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="Three SVG shapes with orange circles at their starting points">
<defs>
<marker id="demo-start-circle" viewBox="0 0 10 10" refX="5" refY="5" markerWidth="12" markerHeight="12" markerUnits="userSpaceOnUse">
<circle cx="5" cy="5" r="4" fill="#f97316" />
</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" />
</svg>
CSS Example
.marker-start-demo {
display: block;
width: 100%;
max-width: 480px;
height: auto;
}
.marker-start-demo .demo-line {
fill: none;
stroke: #2563eb;
stroke-width: 3;
marker-start: url(#demo-start-circle);
}
The first circle appears on the left, the second appears on the right, and the third appears at the beginning of the polyline. This demonstrates that marker-start follows the SVG coordinate order rather than a fixed physical direction.
Remove the Starting Markers
.marker-start-demo .demo-line {
marker-start: none;
}
Use Arrowheads Instead
Define an arrow marker inside the SVG <defs> element:
<marker id="demo-start-arrow" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="12" markerHeight="12" markerUnits="userSpaceOnUse" orient="auto-start-reverse">
<path d="M 0 0 L 10 5 L 0 10 z" fill="#2563eb" />
</marker>
Then update the CSS:
.marker-start-demo .demo-line {
marker-start: url(#demo-start-arrow);
}
Each starting vertex displays an arrowhead pointing outward from the beginning of its shape.
Add Markers to Both Ends
.marker-start-demo .demo-line {
marker-start: url(#demo-start-arrow);
marker-end: url(#demo-start-arrow);
}
With orient="auto-start-reverse", the starting arrow points outward from the beginning and the ending arrow points outward from the end.
Apply Markers to Every Vertex
.marker-start-demo .demo-line {
marker: url(#demo-start-circle);
}
The shorthand assigns the circle marker to all applicable starting, intermediate, and ending vertices.
Common Mistakes
Assuming the Starting Point Is Always on the Left
The starting vertex is determined by SVG coordinates. A line drawn from right to left has its starting point on the right.
Confusing marker-start with HTML List Markers
The marker-start property applies to SVG graphics. It does not control bullets or numbering in ordinary HTML lists.
Using an Undefined Marker ID
line {
marker-start: url(#missing-marker);
}
If the referenced marker does not exist or cannot be accessed, the intended graphic will not appear.
Using the Wrong Arrow Orientation
An arrow marker with orient="auto" points along the path's starting direction. Use auto-start-reverse when the arrow should point outward from the starting vertex.
Ignoring Marker Reference Coordinates
Incorrect refX and refY values can make the marker appear offset from the starting point.
Expecting Markers at Intermediate Vertices
The marker-start property affects starting vertices only. Use marker-mid for intermediate vertices.
Expecting a Marker at the Ending Vertex
Use marker-end to place a marker at the endpoint of a line or path.
Overwriting the Property with the Shorthand
path {
marker-start: url(#arrow);
marker: none;
}
The later shorthand removes the starting marker.
Expecting the Property to Work on Ordinary HTML Elements
The property is intended for supported SVG graphics, not for adding markers to regular HTML boxes.
Important Considerations
Keep the following points in mind when using marker-start:
- The property displays an SVG marker at a starting 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. - Marker placement depends on the SVG shape's geometry.
- The starting vertex is not necessarily the leftmost or topmost point.
- Reversing a line's coordinates changes its starting vertex.
- Paths containing multiple subpaths can have multiple starting 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 starting path direction. - The
auto-start-reversevalue reverses starting marker orientation. - 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-start. - Setting
marker-start: noneremoves only the starting marker. - Use
marker-midfor intermediate vertices. - Use
marker-endfor ending vertices. - Use the
markershorthand when the same marker is needed at all positions.
Browser Support
The CSS marker-start 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 may vary. Test marker placement, orientation, and sizing in the browsers your project supports.
For current compatibility information, visit Can I Use? and search for SVG markers.
Specifications
The marker-start 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-start
These specifications describe how starting markers are referenced, positioned, and rendered on supported SVG graphics.
For additional documentation and examples, consult MDN Web Docs.
