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> |
|---|---|
| Initial | black |
| Applies to | Shapes and text content elements |
| Inherited | Yes |
| Animation | By computed value |
| Support | Chrome 1 · Firefox 3 · Safari 4 |
| Spec | SVG 2 |
.icon { fill: currentColor; }
fill-opacity
The opacity of the fill alone, from 0 to 1 or as a percentage. The stroke is not affected.
| Syntax | <'opacity'> |
|---|---|
| Initial | 1 |
| Applies to | Text and SVG shapes |
| Inherited | Yes |
| Animation | By computed value |
| Support | Chrome 1 · Firefox 1 · Safari 4 |
| Spec | fill-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.
| Syntax | nonzero | evenodd |
|---|---|
| Initial | nonzero |
| Applies to | SVG shapes |
| Inherited | Yes |
| Animation | Discrete |
| Support | Chrome 1 · Firefox 3 · Safari 4 |
| Spec | fill-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> |
|---|---|
| Initial | none |
| Applies to | Shapes and text content elements |
| Inherited | Yes |
| Animation | By computed value |
| Support | Chrome 1 · Firefox 1.5 · Safari 4 |
| Spec | SVG 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># |
|---|---|
| Initial | transparent |
| Applies to | Text and SVG shapes |
| Inherited | Yes |
| Animation | By computed value |
| Support | Chrome no · Firefox no · Safari 11.1 |
| Spec | fill-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> ]# |
|---|---|
| Initial | 1px |
| Applies to | Text and SVG shapes |
| Inherited | Yes |
| Percentages | Relative to the scaled viewport size |
| Animation | By computed value |
| Support | Chrome 1 · Firefox 1.5 · Safari 4 |
| Spec | fill-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'> |
|---|---|
| Initial | 1 |
| Applies to | Text and SVG shapes |
| Inherited | Yes |
| Animation | By computed value |
| Support | Chrome 1 · Firefox 1.5 · Safari 4 |
| Spec | fill-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.
| Syntax | none | [<length-percentage> | <number>]+# |
|---|---|
| Initial | none |
| Applies to | Text and SVG shapes |
| Inherited | Yes |
| Percentages | Relative to the scaled viewport size |
| Animation | Repeatable list |
| Support | Chrome 1 · Firefox 1.5 · Safari 4 |
| Spec | fill-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> |
|---|---|
| Initial | 0 |
| Applies to | Text and SVG shapes |
| Inherited | Yes |
| Percentages | Relative to the scaled viewport size |
| Animation | Repeatable list |
| Support | Chrome 1 · Firefox 1.5 · Safari 4 |
| Spec | fill-stroke-3 |
path {
stroke-dasharray: 1000;
stroke-dashoffset: 1000;
animation: draw 2s forwards;
}
@keyframes draw { to { stroke-dashoffset: 0; } }
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.
| Syntax | butt | round | square |
|---|---|
| Initial | butt |
| Applies to | Text and SVG shapes |
| Inherited | Yes |
| Animation | Discrete |
| Support | Chrome 1 · Firefox 1.5 · Safari 4 |
| Spec | fill-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 ] |
|---|---|
| Initial | miter |
| Applies to | Text and SVG shapes |
| Inherited | Yes |
| Animation | Discrete |
| Support | Chrome 1 · Firefox 1.5 · Safari 4 |
| Spec | fill-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> |
|---|---|
| Initial | 4 |
| Applies to | Text and SVG shapes |
| Inherited | Yes |
| Animation | Discrete |
| Support | Chrome 1 · Firefox 1.5 · Safari 4 |
| Spec | fill-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.
| Syntax | none | <marker-ref> |
|---|---|
| Initial | See individual properties |
| Applies to | Shapes |
| Inherited | Yes |
| Animation | Discrete |
| Support | Chrome 1 · Firefox 3 · Safari 4 |
| Spec | SVG 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.
| Syntax | none | <marker-ref> |
|---|---|
| Initial | none |
| Applies to | Shapes |
| Inherited | Yes |
| Animation | Discrete |
| Support | Chrome 1 · Firefox 3 · Safari 4 |
| Spec | SVG 2 |
.arrow { marker-end: url(#arrowhead); }
<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.
| Syntax | normal | [ fill || stroke || markers ] |
|---|---|
| Initial | normal |
| Applies to | Shapes and text content elements |
| Inherited | Yes |
| Animation | Discrete |
| Support | Chrome 123 · Firefox 60 · Safari 11 |
| Spec | SVG 2 |
text { stroke: white; stroke-width: 4; paint-order: stroke; }
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.
| Syntax | none | <string> |
|---|---|
| Initial | none |
| Applies to | <path> elements |
| Inherited | No |
| Animation | See prose in the spec: paths with matching commands interpolate, others are discrete |
| Support | Chrome 52 · Firefox 97 · Safari no |
| Spec | SVG 2 |
path:hover { d: path("M 0 10 L 20 0 L 40 10"); }
cx, cy
The x and y coordinates of the centre of a circle or ellipse.
| Syntax | <length-percentage> |
|---|---|
| Initial | 0 |
| Applies to | <circle> and <ellipse> elements |
| Inherited | No |
| Percentages | Refer to the width (for cx) or height (for cy) of the current SVG viewport |
| Animation | By computed value |
| Support | Chrome 43 · Firefox 69 · Safari 9 |
| Spec | SVG 2 |
r
The radius of a circle.
| Syntax | <length-percentage> |
|---|---|
| Initial | 0 |
| Applies to | <circle> elements |
| Inherited | No |
| Percentages | Refer to the normalised diagonal of the current SVG viewport |
| Animation | By computed value |
| Support | Chrome 43 · Firefox 69 · Safari 9 |
| Spec | SVG 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 |
|---|---|
| Initial | auto |
| Applies to | <ellipse> and <rect> elements |
| Inherited | No |
| Percentages | Refer to the width (for rx) or height (for ry) of the current SVG viewport |
| Animation | By computed value |
| Support | Chrome 43 · Firefox 69 · Safari 17.4 |
| Spec | SVG 2 |
x, y
The position of the top-left corner of a rectangle, image, nested <svg> or <foreignObject>.
| Syntax | <length-percentage> |
|---|---|
| Initial | 0 |
| Applies to | <svg>, <rect>, <image> and <foreignObject> elements |
| Inherited | No |
| Percentages | Refer to the width (for x) or height (for y) of the current SVG viewport |
| Animation | By computed value |
| Support | Chrome 42 · Firefox 69 · Safari 9 |
| Spec | SVG 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'> |
|---|---|
| Initial | black |
| Applies to | <stop> elements |
| Inherited | No |
| Animation | By computed value |
| Support | Chrome 1 · Firefox 3 · Safari 4 |
| Spec | SVG 2 |
stop-opacity
The opacity of a gradient <stop>, multiplied with any alpha in its stop-color.
| Syntax | <'opacity'> |
|---|---|
| Initial | 1 |
| Applies to | <stop> elements |
| Inherited | No |
| Animation | By computed value |
| Support | Chrome 1 · Firefox 3 · Safari 4 |
| Spec | SVG 2 |
flood-color
The colour an <feFlood> filter primitive fills its region with, and the shadow colour of <feDropShadow>.
| Syntax | <color> |
|---|---|
| Initial | black |
| Applies to | <feFlood> and <feDropShadow> elements |
| Inherited | No |
| Animation | By computed value |
| Support | Chrome 5 · Firefox 3 · Safari 6 |
| Spec | filter-effects-1 |
flood-opacity
The opacity of the flood-color in <feFlood> and <feDropShadow>.
| Syntax | <'opacity'> |
|---|---|
| Initial | 1 |
| Applies to | <feFlood> and <feDropShadow> elements |
| Inherited | No |
| Animation | By computed value |
| Support | Chrome 5 · Firefox 3 · Safari 6 |
| Spec | filter-effects-1 |
lighting-color
The colour of the light source in the <feDiffuseLighting> and <feSpecularLighting> filter primitives.
| Syntax | <color> |
|---|---|
| Initial | white |
| Applies to | <feDiffuseLighting> and <feSpecularLighting> elements |
| Inherited | No |
| Animation | By computed value |
| Support | Chrome 5 · Firefox 3 · Safari 6 |
| Spec | filter-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.
| Syntax | auto | sRGB | linearRGB |
|---|---|
| Initial | sRGB |
| Applies to | Container elements, graphics elements, gradient elements, <use> and <animate> |
| Inherited | Yes |
| Animation | Discrete |
| Support | Chrome 1 · Firefox 3 · Safari 4 |
| Spec | SVG 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.
| Syntax | auto | sRGB | linearRGB |
|---|---|
| Initial | linearRGB |
| Applies to | All filter primitives |
| Inherited | Yes |
| Animation | Discrete |
| Support | Chrome 1 · Firefox 3 · Safari 3 |
| Spec | filter-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.
| Syntax | auto | optimizeSpeed | crispEdges | geometricPrecision |
|---|---|
| Initial | auto |
| Applies to | Shapes |
| Inherited | Yes |
| Animation | Discrete |
| Support | Chrome 1 · Firefox 3 · Safari 4 |
| Spec | SVG 2 |
text-rendering
A hint about what to favour when drawing text: speed, legibility or geometric precision. Browsers also apply it to HTML text.
| Syntax | auto | optimizeSpeed | optimizeLegibility | geometricPrecision |
|---|---|
| Initial | auto |
| Applies to | <text> elements |
| Inherited | Yes |
| Animation | Discrete |
| Support | Chrome 4 · Firefox 1 · Safari 5 |
| Spec | SVG 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.
| Syntax | none | non-scaling-stroke | non-scaling-size | non-rotation | fixed-position |
|---|---|
| Initial | none |
| Applies to | Graphics elements and <use> |
| Inherited | No |
| Animation | Discrete |
| Support | Chrome 6 · Firefox 15 · Safari 5.1 |
| Spec | SVG 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.
| Syntax | start | middle | end |
|---|---|
| Initial | start |
| Applies to | Text content elements |
| Inherited | Yes |
| Animation | Discrete |
| Support | Chrome 1 · Firefox 3 · Safari 4 |
| Spec | SVG 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.
| Syntax | nonzero | evenodd |
|---|---|
| Initial | nonzero |
| Applies to | SVG graphics elements |
| Inherited | Yes |
| Animation | Discrete |
| Support | Chrome ≤15 · Firefox 3.5 · Safari ≤5 |
| Spec | css-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.
| Syntax | luminance | alpha |
|---|---|
| Initial | luminance |
| Applies to | <mask> elements |
| Inherited | No |
| Animation | Discrete |
| Support | Chrome 24 · Firefox 35 · Safari 7 |
| Spec | css-masking-1 |