CSS marker Property

The CSS marker property is a shorthand that applies an SVG marker to the starting, intermediate, and ending vertices of a supported SVG shape.

Markers are reusable graphics, such as arrowheads, circles, or other symbols, defined using the SVG <marker> element. The marker shorthand sets marker-start, marker-mid, and marker-end to the same value.

marker Syntax

The marker property accepts none or a URL reference to an SVG marker definition. CSS-wide keywords are also supported.

Basic Syntax

selector {
  marker: url(#marker-id);
}

Marker Reference

path {
  marker: url(#arrow);
}

Remove Markers

path {
  marker: none;
}

CSS-Wide Keywords

path {
  marker: initial;
}
path {
  marker: inherit;
}
path {
  marker: unset;
}
path {
  marker: revert;
}
path {
  marker: revert-layer;
}

The initial value of each longhand property controlled by marker is none.

Property Values

Value Description
none Displays no markers at the starting, intermediate, or ending vertices.
url() References an SVG <marker> definition to display at all applicable vertices.
initial Resets all three marker longhand properties to none.
inherit Inherits the computed marker values from the parent element.
unset Behaves like inherit because the marker longhand properties are inherited.
revert Reverts the marker longhand properties according to cascade origin rules.
revert-layer Reverts the marker longhand properties according to cascade layer rules.

Property Characteristics

Characteristic Value
Property type Shorthand
Initial value none for each longhand
Inherited Yes, through its longhand properties
Applies to SVG shapes and other supported SVG graphics elements
Computed value Determined by the individual longhand properties
Animation type Discrete for the longhand properties
Longhand properties marker-start, marker-mid, marker-end
Common use SVG arrows, diagrams, paths, and line decorations

How It Works

The marker property references a marker graphic defined in an SVG document. The browser places instances of that graphic at the applicable vertices of the selected SVG element.

Unlike a CSS background image, a marker is positioned using the geometry of the SVG shape. Its orientation and size can be controlled by attributes on the <marker> definition.

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="marked-line" x1="30" y1="50" x2="270" y2="50" stroke="#2563eb" stroke-width="3" />
</svg>

CSS Example

.marked-line {
  marker: url(#arrow);
}

The browser places the arrow marker at both ends of the line. The orient="auto" attribute aligns each arrow with the direction of the line at its vertex.

Important Consideration

The shorthand applies the same marker to all three marker positions. For an arrowhead only at the end of a line, use marker-end instead.

Defining SVG Markers

SVG markers are defined with the <marker> element, usually inside an SVG <defs> container.

Marker Definition

<svg xmlns="http://www.w3.org/2000/svg">
  <defs>
    <marker id="circle-marker" viewBox="0 0 10 10" refX="5" refY="5" markerWidth="6" markerHeight="6">
      <circle cx="5" cy="5" r="4" fill="#2563eb" />
    </marker>
  </defs>
</svg>

The id attribute identifies the marker. CSS can reference it using url(#circle-marker).

Reference the Marker

line {
  marker: url(#circle-marker);
}

Common Marker Attributes

Attribute Purpose
id Identifies the marker for URL references.
viewBox Defines the marker's internal coordinate system.
refX Sets the horizontal reference point aligned with the vertex.
refY Sets the vertical reference point aligned with the vertex.
markerWidth Defines the marker viewport width.
markerHeight Defines the marker viewport height.
markerUnits Controls whether marker dimensions scale with stroke width or use user-space units.
orient Controls marker rotation.

Important Consideration

The marker definition must be accessible to the SVG element using it. A missing or incorrect reference prevents the marker from rendering.

Shorthand Properties

The marker shorthand sets three individual CSS properties:

  • marker-start - applies a marker to the beginning of a supported SVG shape.
  • marker-mid - applies markers to applicable intermediate vertices.
  • marker-end - applies a marker to the end of a supported SVG shape.

Using the Shorthand

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 three positions.

Using Different Markers

path {
  marker-start: url(#start-marker);
  marker-mid: url(#middle-marker);
  marker-end: url(#end-marker);
}

Use the individual longhand properties when each position needs a different marker.

Shorthand Override

path {
  marker-end: url(#arrow);
  marker: none;
}

The later shorthand resets all three marker positions to none, including marker-end.

Override Only the Ending Marker

path {
  marker: url(#circle-marker);
  marker-end: url(#arrow);
}

The starting and intermediate vertices use the circle marker, while the ending vertex uses the arrow marker.

Marker Placement

The SVG element determines where markers can appear. The shorthand does not create additional vertices or divide a shape into new segments.

Line

<line x1="20" y1="40" x2="220" y2="40" />

A line has a starting point and an ending point, so marker-start and marker-end apply. There are no intermediate vertices for marker-mid.

Polyline

<polyline points="20,80 80,20 140,80 200,20" />

A polyline has multiple connected segments. The browser can place markers at the starting point, intermediate vertices, and ending point.

Polygon

<polygon points="100,10 180,80 20,80" />

A polygon is a closed shape. Its closing geometry affects marker placement, including how the start and end positions meet.

Path

<path d="M 20 80 L 100 20 L 180 80" />

Markers can appear at the beginning, intermediate vertices, and end of the path. Their placement follows the path's segments and subpaths.

Important Consideration

Marker placement depends on SVG path geometry, not the visual length of a line. For repeated decorations along a path at regular intervals, additional SVG techniques may be necessary.

Marker Orientation

The orient attribute controls how a marker rotates when placed at a vertex.

Automatic Orientation

<marker id="arrow" orient="auto" markerWidth="6" markerHeight="6">
  <path d="M 0 0 L 10 5 L 0 10 z" />
</marker>

The marker rotates to follow the direction of the path at each vertex.

Automatic Start-Reverse Orientation

<marker id="arrow" orient="auto-start-reverse" markerWidth="6" markerHeight="6">
  <path d="M 0 0 L 10 5 L 0 10 z" />
</marker>

The auto-start-reverse value reverses the marker orientation at the starting vertex. This is useful for creating outward-facing arrowheads at both ends of a line.

Fixed Orientation

<marker id="arrow" orient="45" markerWidth="6" markerHeight="6">
  <path d="M 0 0 L 10 5 L 0 10 z" />
</marker>

A fixed angle keeps the marker at the specified orientation rather than aligning it automatically with the path.

Important Consideration

Marker orientation is configured on the SVG marker definition, not through the CSS marker shorthand.

Marker Sizing

SVG marker dimensions can be controlled using markerWidth, markerHeight, viewBox, and markerUnits.

Marker Dimensions

<marker id="large-arrow" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="10" markerHeight="10" orient="auto">
  <path d="M 0 0 L 10 5 L 0 10 z" fill="#2563eb" />
</marker>

The marker viewport dimensions are set to 10 units in each direction.

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>

With markerUnits="strokeWidth", marker dimensions scale according to the stroke width of the element using the marker.

Use User-Space Units

<marker id="fixed-arrow" viewBox="0 0 10 10" refX="9" refY="5" markerWidth="6" markerHeight="6" markerUnits="userSpaceOnUse" orient="auto">
  <path d="M 0 0 L 10 5 L 0 10 z" fill="#2563eb" />
</marker>

With markerUnits="userSpaceOnUse", marker dimensions use the current user coordinate system rather than scaling directly with stroke width.

Important Consideration

Changing a line's stroke-width can change marker size when markerUnits="strokeWidth" is used.

Removing Markers

Set marker to none to remove all three marker positions from an SVG element.

Remove All Markers

path {
  marker: none;
}

Remove Only the Starting Marker

path {
  marker: url(#circle-marker);
  marker-start: none;
}

The intermediate and ending markers remain assigned, while the starting marker is removed.

Remove Only the Ending Marker

path {
  marker: url(#circle-marker);
  marker-end: none;
}

Use individual longhand properties when only one marker position needs to be changed.

marker Example

This example demonstrates how the marker shorthand places reusable SVG circle markers at the vertices of a polyline.

HTML Example

<svg class="marker-demo" viewBox="0 0 320 150" xmlns="http://www.w3.org/2000/svg" role="img" aria-label="A blue polyline with circular markers at each vertex">
  <defs>
    <marker id="demo-circle-marker" viewBox="0 0 10 10" refX="5" refY="5" markerWidth="6" markerHeight="6" markerUnits="userSpaceOnUse">
      <circle cx="5" cy="5" r="4" fill="#f97316" />
    </marker>
  </defs>
  <polyline class="demo-polyline" points="30,110 100,35 170,95 240,30 290,75" fill="none" stroke="#2563eb" stroke-width="3" />
</svg>

CSS Example

.marker-demo {
  display: block;
  width: 100%;
  max-width: 480px;
  height: auto;
}
.marker-demo .demo-polyline {
  marker: url(#demo-circle-marker);
}
Browser Result

The orange circle marker appears at the starting point, each intermediate vertex, and the ending point of the blue polyline.

Remove All Markers

.marker-demo .demo-polyline {
  marker: none;
}

Show Only the Ending Marker

.marker-demo .demo-polyline {
  marker: none;
  marker-end: url(#demo-circle-marker);
}

Show Only Intermediate Markers

.marker-demo .demo-polyline {
  marker: none;
  marker-mid: url(#demo-circle-marker);
}

Change the Marker Size

Update the SVG marker definition to increase its displayed dimensions:

<marker id="demo-circle-marker" 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>

The larger marker viewport produces larger circles while retaining the same internal coordinate system.

Common Mistakes

Confusing marker with list-style-type

The marker property is used for SVG marker graphics. It does not control the bullets or numbers of ordinary HTML lists. Use list-style-type or the ::marker pseudo-element for list markers.

Using an Undefined Marker ID

path {
  marker: url(#missing-marker);
}

If no accessible SVG marker has the ID missing-marker, the browser cannot display the intended marker.

Expecting Only an Ending Arrow

line {
  marker: url(#arrow);
}

The shorthand applies the arrow to both ends of a line. Use marker-end when only the ending arrow is required.

Expecting Markers at Regular Intervals

Markers are placed at applicable vertices, not automatically at equal distances along a path.

Ignoring Marker Orientation

Arrowheads may point in unexpected directions when the SVG marker's orient attribute is not configured appropriately.

Ignoring Marker Reference Points

Incorrect refX and refY values can make markers appear offset from their intended positions.

Overwriting Individual Marker Properties

path {
  marker-end: url(#arrow);
  marker: none;
}

The later shorthand removes the ending marker along with the other marker positions.

Expecting Markers on Ordinary HTML Elements

The property is intended for supported SVG graphics. It does not create decorative markers on regular HTML boxes.

Important Considerations

Keep the following points in mind when using marker:

  • The property is a shorthand for three SVG marker properties.
  • It sets marker-start, marker-mid, and marker-end.
  • The initial value of each longhand property is none.
  • The longhand properties are inherited.
  • The shorthand 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 id is used in the CSS URL reference.
  • The same marker is assigned to all applicable positions.
  • Individual longhand properties allow different markers at different positions.
  • Marker placement depends on the geometry of the SVG shape.
  • A line has starting and ending vertices but no intermediate vertices.
  • Polylines and paths can have intermediate marker positions.
  • Markers are not automatically repeated at equal intervals.
  • The orient attribute controls marker rotation.
  • The auto-start-reverse value can reverse starting arrowheads.
  • The refX and refY attributes control marker alignment.
  • The markerWidth and markerHeight attributes control marker viewport dimensions.
  • The markerUnits attribute controls how marker dimensions are measured.
  • Markers may scale with the stroke width of the referencing element.
  • Setting marker: none removes all three marker positions.
  • Later shorthand declarations can override earlier longhand declarations.
  • Marker graphics are different from HTML list markers.
  • Use list-style-type or ::marker for ordinary list markers.

Browser Support

The CSS marker property is supported in modern browsers for SVG graphics, including Chrome, Edge, Firefox, Safari, and Opera.

Support for individual SVG marker features and external references may vary. Test marker definitions, 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 property is defined in the CSS Fill and Stroke Module Level 3 specification.

CSS Fill and Stroke Module Level 3: Marker Shorthand

The specification describes how the shorthand assigns marker references to the starting, intermediate, and ending positions of supported SVG graphics.

For additional documentation and examples, consult MDN Web Docs.

MDN Web Docs: marker