SVG

Presentation properties for SVG content: how shapes are filled and stroked, where markers go, the geometry of circles, ellipses, rectangles and paths, the colours used by gradients and filter primitives, and a few rendering hints. Most of them also work as SVG attributes (<circle fill="red">), but a CSS declaration wins over the attribute, so you can restyle inline SVG from a stylesheet. filter, clip-path and mask, which apply to HTML as well, are under Filters, effects & masking; color and opacity are under Color & backgrounds.

Fill

fill

Paints the interior of a shape or the glyphs of SVG text. A <paint> is none, a colour, context-fill or context-stroke, or a url() reference to a gradient or pattern with an optional fallback colour.

Syntax<paint>
Initialblack
Applies toShapes and text content elements
InheritedYes
AnimationBy computed value
SupportChrome 1 · Firefox 3 · Safari 4
SpecSVG 2
.icon { fill: currentColor; }
An inline SVG icon that takes the text colour of whatever it sits in.

fill-opacity

The opacity of the fill alone, from 0 to 1 or as a percentage. The stroke is not affected.

Syntax<'opacity'>
Initial1
Applies toText and SVG shapes
InheritedYes
AnimationBy computed value
SupportChrome 1 · Firefox 1 · Safari 4
Specfill-stroke-3

fill-rule

Decides which parts of a self-intersecting or nested path count as inside. nonzero fills every region the path winds around; evenodd alternates, so a shape drawn inside another becomes a hole.

Syntaxnonzero | evenodd
Initialnonzero
Applies toSVG shapes
InheritedYes
AnimationDiscrete
SupportChrome 1 · Firefox 3 · Safari 4
Specfill-stroke-3

Stroke

stroke

Paints the outline of a shape or of SVG text. It takes the same <paint> values as fill. The stroke is centred on the geometry, so half its width falls outside the shape.

Syntax<paint>
Initialnone
Applies toShapes and text content elements
InheritedYes
AnimationBy computed value
SupportChrome 1 · Firefox 1.5 · Safari 4
SpecSVG 2

stroke-color

Sets the stroke to a colour. Unlike stroke, it takes only a colour, not a gradient or pattern reference. Only Safari ships it, so use stroke for anything that must work everywhere.

Syntax<color>#
Initialtransparent
Applies toText and SVG shapes
InheritedYes
AnimationBy computed value
SupportChrome no · Firefox no · Safari 11.1
Specfill-stroke-3

stroke-width

The thickness of the stroke. A plain number is in SVG user units, the same as a px length at the default scale.

Syntax[ <length-percentage> | <line-width> | <number> ]#
Initial1px
Applies toText and SVG shapes
InheritedYes
PercentagesRelative to the scaled viewport size
AnimationBy computed value
SupportChrome 1 · Firefox 1.5 · Safari 4
Specfill-stroke-3

The stroke scales with the SVG. To keep it the same on-screen width however the graphic is scaled, add vector-effect: non-scaling-stroke.

stroke-opacity

The opacity of the stroke alone, from 0 to 1 or as a percentage. Where a translucent stroke overlaps the fill, the fill shows through.

Syntax<'opacity'>
Initial1
Applies toText and SVG shapes
InheritedYes
AnimationBy computed value
SupportChrome 1 · Firefox 1.5 · Safari 4
Specfill-stroke-3

stroke-dasharray

Turns the stroke into dashes. The values alternate dash length and gap length; an odd number of values is repeated to make an even list, so 5 means 5 on, 5 off.

Syntaxnone | [<length-percentage> | <number>]+#
Initialnone
Applies toText and SVG shapes
InheritedYes
PercentagesRelative to the scaled viewport size
AnimationRepeatable list
SupportChrome 1 · Firefox 1.5 · Safari 4
Specfill-stroke-3

stroke-dashoffset

Shifts where the dash pattern starts along the path. Animating it moves the dashes along the line.

Syntax<length-percentage> | <number>
Initial0
Applies toText and SVG shapes
InheritedYes
PercentagesRelative to the scaled viewport size
AnimationRepeatable list
SupportChrome 1 · Firefox 1.5 · Safari 4
Specfill-stroke-3
path {
  stroke-dasharray: 1000;
  stroke-dashoffset: 1000;
  animation: draw 2s forwards;
}
@keyframes draw { to { stroke-dashoffset: 0; } }
The line-drawing effect: one dash as long as the path, slid into view.

stroke-linecap

The shape at the open ends of a stroke and of each dash. butt stops flat at the end point; round and square extend past it by half the stroke width.

Syntaxbutt | round | square
Initialbutt
Applies toText and SVG shapes
InheritedYes
AnimationDiscrete
SupportChrome 1 · Firefox 1.5 · Safari 4
Specfill-stroke-3

stroke-linejoin

The shape of the stroke where two segments meet at a corner: miter for a sharp point, round for a rounded corner, or bevel to cut the corner off.

Syntax[ crop | arcs | miter ] || [ bevel | round | fallback ]
Initialmiter
Applies toText and SVG shapes
InheritedYes
AnimationDiscrete
SupportChrome 1 · Firefox 1.5 · Safari 4
Specfill-stroke-3

stroke-miterlimit

How long a miter join may get, as a multiple of the stroke width, before it is drawn as a bevel instead. It stops very sharp corners from producing long spikes.

Syntax<number>
Initial4
Applies toText and SVG shapes
InheritedYes
AnimationDiscrete
SupportChrome 1 · Firefox 1.5 · Safari 4
Specfill-stroke-3

Markers & paint order

marker

Shorthand that sets marker-start, marker-mid and marker-end to the same value. A <marker-ref> is a url() pointing at an SVG <marker> element.

Syntaxnone | <marker-ref>
InitialSee individual properties
Applies toShapes
InheritedYes
AnimationDiscrete
SupportChrome 1 · Firefox 3 · Safari 4
SpecSVG 2

marker-start, marker-mid, marker-end

The marker drawn at the first vertex, at every vertex in between, or at the last vertex of a path, line, polyline or polygon. Arrowheads are the usual use.

Syntaxnone | <marker-ref>
Initialnone
Applies toShapes
InheritedYes
AnimationDiscrete
SupportChrome 1 · Firefox 3 · Safari 4
SpecSVG 2
.arrow { marker-end: url(#arrowhead); }
Draw the <marker id="arrowhead"> at the end of the line.

paint-order

The order in which the fill, stroke and markers are painted. By default the fill goes first and the stroke on top; paint-order: stroke paints the stroke first, so only its outer half shows around the fill. Keywords you leave out follow in their default order.

Syntaxnormal | [ fill || stroke || markers ]
Initialnormal
Applies toShapes and text content elements
InheritedYes
AnimationDiscrete
SupportChrome 123 · Firefox 60 · Safari 11
SpecSVG 2
text { stroke: white; stroke-width: 4; paint-order: stroke; }
An outline behind the letters that does not eat into their shapes.

Geometry

d

The path data of a <path> element. In CSS the value is written with the path() function, holding the same command string as the d attribute.

Syntaxnone | <string>
Initialnone
Applies to<path> elements
InheritedNo
AnimationSee prose in the spec: paths with matching commands interpolate, others are discrete
SupportChrome 52 · Firefox 97 · Safari no
SpecSVG 2
path:hover { d: path("M 0 10 L 20 0 L 40 10"); }
Change a path's shape from CSS; with a transition it morphs between the two.

cx, cy

The x and y coordinates of the centre of a circle or ellipse.

Syntax<length-percentage>
Initial0
Applies to<circle> and <ellipse> elements
InheritedNo
PercentagesRefer to the width (for cx) or height (for cy) of the current SVG viewport
AnimationBy computed value
SupportChrome 43 · Firefox 69 · Safari 9
SpecSVG 2

r

The radius of a circle.

Syntax<length-percentage>
Initial0
Applies to<circle> elements
InheritedNo
PercentagesRefer to the normalised diagonal of the current SVG viewport
AnimationBy computed value
SupportChrome 43 · Firefox 69 · Safari 9
SpecSVG 2

rx, ry

The horizontal and vertical radii of an ellipse, or of the rounded corners of a rectangle. On a <rect>, auto takes the value of the other radius, so setting only rx gives circular corners.

Syntax<length-percentage> | auto
Initialauto
Applies to<ellipse> and <rect> elements
InheritedNo
PercentagesRefer to the width (for rx) or height (for ry) of the current SVG viewport
AnimationBy computed value
SupportChrome 43 · Firefox 69 · Safari 17.4
SpecSVG 2

x, y

The position of the top-left corner of a rectangle, image, nested <svg> or <foreignObject>.

Syntax<length-percentage>
Initial0
Applies to<svg>, <rect>, <image> and <foreignObject> elements
InheritedNo
PercentagesRefer to the width (for x) or height (for y) of the current SVG viewport
AnimationBy computed value
SupportChrome 42 · Firefox 69 · Safari 9
SpecSVG 2

Gradients & filters

stop-color

The colour of a <stop> in an SVG <linearGradient> or <radialGradient>. Setting it from CSS lets one gradient definition follow a theme.

Syntax<'color'>
Initialblack
Applies to<stop> elements
InheritedNo
AnimationBy computed value
SupportChrome 1 · Firefox 3 · Safari 4
SpecSVG 2

stop-opacity

The opacity of a gradient <stop>, multiplied with any alpha in its stop-color.

Syntax<'opacity'>
Initial1
Applies to<stop> elements
InheritedNo
AnimationBy computed value
SupportChrome 1 · Firefox 3 · Safari 4
SpecSVG 2

flood-color

The colour an <feFlood> filter primitive fills its region with, and the shadow colour of <feDropShadow>.

Syntax<color>
Initialblack
Applies to<feFlood> and <feDropShadow> elements
InheritedNo
AnimationBy computed value
SupportChrome 5 · Firefox 3 · Safari 6
Specfilter-effects-1

flood-opacity

The opacity of the flood-color in <feFlood> and <feDropShadow>.

Syntax<'opacity'>
Initial1
Applies to<feFlood> and <feDropShadow> elements
InheritedNo
AnimationBy computed value
SupportChrome 5 · Firefox 3 · Safari 6
Specfilter-effects-1

lighting-color

The colour of the light source in the <feDiffuseLighting> and <feSpecularLighting> filter primitives.

Syntax<color>
Initialwhite
Applies to<feDiffuseLighting> and <feSpecularLighting> elements
InheritedNo
AnimationBy computed value
SupportChrome 5 · Firefox 3 · Safari 6
Specfilter-effects-1

color-interpolation

The colour space SVG works in when it interpolates colours for gradients and animations and when it composites. sRGB is the default; linearRGB works in linear light.

Syntaxauto | sRGB | linearRGB
InitialsRGB
Applies toContainer elements, graphics elements, gradient elements, <use> and <animate>
InheritedYes
AnimationDiscrete
SupportChrome 1 · Firefox 3 · Safari 4
SpecSVG 2

color-interpolation-filters

The colour space SVG filter primitives do their arithmetic in. The default is linearRGB, so blurs and colour matrices can give slightly different results from the same maths done in sRGB; set sRGB to match.

Syntaxauto | sRGB | linearRGB
InitiallinearRGB
Applies toAll filter primitives
InheritedYes
AnimationDiscrete
SupportChrome 1 · Firefox 3 · Safari 3
Specfilter-effects-1

Rendering hints

shape-rendering

A hint about what to favour when drawing shapes. crispEdges turns off anti-aliasing so horizontal and vertical lines land sharply on pixels; geometricPrecision favours accuracy; optimizeSpeed favours speed.

Syntaxauto | optimizeSpeed | crispEdges | geometricPrecision
Initialauto
Applies toShapes
InheritedYes
AnimationDiscrete
SupportChrome 1 · Firefox 3 · Safari 4
SpecSVG 2

text-rendering

A hint about what to favour when drawing text: speed, legibility or geometric precision. Browsers also apply it to HTML text.

Syntaxauto | optimizeSpeed | optimizeLegibility | geometricPrecision
Initialauto
Applies to<text> elements
InheritedYes
AnimationDiscrete
SupportChrome 4 · Firefox 1 · Safari 5
SpecSVG 2

vector-effect

Opts an element out of parts of its transform. non-scaling-stroke keeps the stroke the same width on screen however the SVG is scaled, which is what you want for diagrams and icons drawn with hairlines.

Syntaxnone | non-scaling-stroke | non-scaling-size | non-rotation | fixed-position
Initialnone
Applies toGraphics elements and <use>
InheritedNo
AnimationDiscrete
SupportChrome 6 · Firefox 15 · Safari 5.1
SpecSVG 2

Text

text-anchor

Aligns SVG text relative to its x position: the text starts there, is centred on it (middle) or ends there. start and end follow the text direction.

Syntaxstart | middle | end
Initialstart
Applies toText content elements
InheritedYes
AnimationDiscrete
SupportChrome 1 · Firefox 3 · Safari 4
SpecSVG 2

Clipping & masks

clip-rule

The fill rule used for shapes inside a <clipPath>, deciding which parts of a self-intersecting shape clip. It works like fill-rule.

Syntaxnonzero | evenodd
Initialnonzero
Applies toSVG graphics elements
InheritedYes
AnimationDiscrete
SupportChrome ≤15 · Firefox 3.5 · Safari ≤5
Speccss-masking-1

mask-type

Set on an SVG <mask> element: whether the mask uses the brightness (luminance) or the transparency (alpha) of its content. A mask-mode of match-source on the masked element follows this value.

Syntaxluminance | alpha
Initialluminance
Applies to<mask> elements
InheritedNo
AnimationDiscrete
SupportChrome 24 · Firefox 35 · Safari 7
Speccss-masking-1