Supported SVG and CSS features¶
Librsvg tries to be a mostly complete renderer for SVG1.1 and SVG2.
In terms of processing external references, librsvg is a bit more strict than SVG’s “static mode” and a bit more lenient than “secure static mode”. See “Security and locations of referenced files” in the reference documentation for details.
Animation, interactivity, and scripting are not supported.
The SVG1.2 specification never made it past draft status in the W3C’s process, and librsvg does not support it. Note that SVG2 removed some of the features proposed for SVG1.2.
Generally, librsvg tries to keep up with features in the SVG2 Candidate Recommendation spec. It ignores features in the SVG2 drafts that are not finalized yet.
Alternative versions of SVG (SVG Tiny, SVG Basic, SVG Native) are not explicitly supported. Their features which are a subset of SVG1.1 or SVG2 are supported if they are equivalent to the ones listed below.
SVG2 offloads many of its features to the family of CSS3 specifications. Librsvg does not try to support them exhaustively (there are too many features in CSS!). Instead, we try to prioritize new features based on the needs which people express in librsvg’s bug tracker. Do you want a feature? File an issue!
Supported raster image formats¶
The image
and feImage
elements allow including an external
file as raster data. Librsvg supports loading JPEG, PNG, GIF, and
WEBP. Librsvg can optionally be compiled with support for AVIF, too;
see the “Compile-time options” section in Detailed compilation instructions for details.
Attributes supported by all elements¶
Attribute |
Notes |
---|---|
class |
|
id |
|
requiredExtensions |
Used in children of the
|
requiredFeatures |
Used in children of the
|
systemLanguage |
Used in children of the
|
style |
|
transform |
The |
xml:lang |
|
xml:space |
Elements and their specific attributes¶
Element |
Attributes |
Notes |
---|---|---|
a |
||
xlink:href |
Needs xlink namespace |
|
href |
SVG2 |
|
circle |
||
cx |
||
cy |
||
r |
||
clipPath |
||
clipPathUnits |
||
defs |
||
ellipse |
||
cx |
||
cy |
||
rx |
||
ry |
||
feBlend |
See Filter effects |
|
in |
||
in2 |
||
mode |
||
feColorMatrix |
See Filter effects |
|
in |
||
type |
||
values |
||
feComponentTransfer |
See Filter effects |
|
in |
||
feComposite |
See Filter effects |
|
in |
||
in2 |
||
operator |
||
k1 |
||
k2 |
||
k3 |
||
k4 |
||
feConvolveMatrix |
See Filter effects |
|
in |
||
order |
||
divisor |
||
bias |
||
targetX |
||
targetY |
||
edgeMode |
||
kernelMatrix |
||
kernelUnitLength |
||
preserveAlpha |
||
feDiffuseLighting |
See Filter effects |
|
in |
||
surfaceScale |
||
kernelUnitLength |
||
diffuseConstant |
||
feDisplacementMap |
See Filter effects |
|
in |
||
in2 |
||
scale |
||
xChannelSelector |
||
yChannelSelector |
||
feDistantLight |
||
azimuth |
||
elevation |
||
feDropShadow |
See Filter effects Also takes the flood-color and flood-opacity properties. |
|
in |
||
dx |
||
dy |
||
stdDeviation |
||
feFuncA |
||
feFuncB |
||
feFuncG |
||
feFuncR |
||
feFlood |
See Filter effects |
|
Parameters come from the flood-color and flood-opacity properties. |
||
feGaussianBlur |
See Filter effects |
|
in |
||
stdDeviation |
||
feImage |
See Filter effects |
|
xlink:href |
Needs xlink namespace |
|
href |
SVG2 |
|
path |
Non-standard; used by old Adobe Illustrator versions. |
|
preserveAspectRatio |
||
feMerge |
See Filter effects |
|
feMergeNode |
||
in |
||
feMorphology |
See Filter effects |
|
in |
||
operator |
||
radius |
||
feOffset |
See Filter effects |
|
in |
||
dx |
||
dy |
||
fePointLight |
||
x |
||
y |
||
z |
||
feSpecularLighting |
See Filter effects |
|
in |
||
surfaceScale |
||
kernelUnitLength |
||
specularConstant |
||
specularExponent |
||
feSpotLight |
||
x |
||
y |
||
z |
||
pointsAtX |
||
pointsAtY |
||
pointsAtZ |
||
specularExponent |
||
limitingConeAngle |
||
feTile |
See Filter effects |
|
in |
||
feTurbulence |
See Filter effects |
|
baseFrequency |
||
numOctaves |
||
seed |
||
stitchTiles |
||
type |
||
filter |
||
filterUnits |
||
primitiveUnits |
||
x |
||
y |
||
width |
||
height |
||
g |
||
image |
||
xlink:href |
Needs xlink namespace |
|
href |
SVG2 |
|
path |
Non-standard; used by old Adobe Illustrator versions. |
|
x |
||
y |
||
width |
||
height |
||
preserveAspectRatio |
||
line |
||
x1 |
||
y1 |
||
x2 |
||
y2 |
||
linearGradient |
||
gradientUnits |
||
gradientTransform |
||
spreadMethod |
||
x1 |
||
y1 |
||
x2 |
||
y2 |
||
marker |
||
markerUnits |
||
refX |
||
refY |
||
markerWidth |
||
markerHeight |
||
orient |
||
preserveAspectRatio |
||
viewBox |
||
mask |
||
x |
||
y |
||
width |
||
height |
||
maskUnits |
||
maskContentUnits |
||
path |
||
d |
||
pattern |
||
xlink:href |
Needs xlink namespace |
|
href |
SVG2 |
|
patternUnits |
||
patternContentUnits |
||
patternTransform |
||
preserveAspectRatio |
||
viewBox |
||
x |
||
y |
||
width |
||
height |
||
polygon |
||
points |
||
polyline |
||
points |
||
radialGradient |
||
gradientUnits |
||
gradientTransform |
||
spreadMethod |
||
cx |
||
cy |
||
r |
||
fx |
||
fx |
||
fr |
||
rect |
||
x |
||
y |
||
width |
||
height |
||
rx |
||
ry |
||
stop |
||
offset |
||
style |
||
type |
||
svg |
||
x |
||
y |
||
width |
||
height |
||
viewBox |
||
preserveAspectRatio |
||
switch |
||
symbol |
||
preserveAspectRatio |
||
viewBox |
||
text |
||
x |
||
y |
||
dx |
||
dy |
||
tref |
||
xlink:href |
Needs xlink namespace |
|
tspan |
||
x |
||
y |
||
dx |
||
dy |
||
use |
||
xlink:href |
Needs xlink namespace |
|
href |
SVG2 |
|
x |
||
y |
||
width |
||
height |
CSS properties¶
The following are shorthand properties. They are not available as
presentation attributes, only as style properties, so for example you
have to use <path style="marker: url(#foo);"/>
, since there is no
marker
attribute.
Property |
Notes |
---|---|
font |
|
glyph-orientation-vertical |
Supports only CSS Writing Modes 3 values: auto, 0, 90, 0deg, 90deg |
marker |
The following are longhand properties. Most of them are available as
presentation attributes, e.g. you can use <rect fill="blue"/>
as
well as <rect style="fill: blue;"/>
. The Notes column indicates
which properties are not available as presentation attributes.
Property |
Notes |
---|---|
baseline-shift |
|
clip-path |
|
clip-rule |
|
color |
|
color- interpolation-filters |
|
direction |
|
display |
|
enable-background |
|
fill |
|
fill-opacity |
|
fill-rule |
|
filter |
|
flood-color |
|
flood-opacity |
|
font-family |
|
font-size |
|
font-stretch |
|
font-style |
|
font-variant |
|
font-weight |
|
image-rendering |
|
isolation |
Not available as a presentation attribute. |
letter-spacing |
|
lighting-color |
|
line-height |
Not available as a presentation attribute. |
marker-end |
|
marker-mid |
|
marker-start |
|
mask |
|
mask-type |
|
mix-blend-mode |
Not available as a presentation attribute. |
opacity |
|
overflow |
|
paint-order |
|
shape-rendering |
|
stop-color |
|
stop-opacity |
|
stroke |
|
stroke-dasharray |
|
stroke-dashoffset |
|
stroke-linecap |
|
stroke-linejoin |
|
stroke-miterlimit |
|
stroke-opacity |
|
stroke-width |
|
text-anchor |
|
text-decoration |
|
text-orientation |
Not available as a presentation attribute. |
text-rendering |
|
transform |
SVG2; different syntax from the
|
unicode-bidi |
|
vector-effect |
Only |
visibility |
|
writing-mode |
Filter effects¶
The following elements are filter effects:
feBlend
feColorMatrix
feComponentTransfer
feComposite
feConvolveMatrix
feDiffuseLighting
feDisplacementMap
feDropShadow
feFlood
feGaussianBlur
feImage
feMerge
feMorphology
feOffset
feSpecularLighting
feTile
feTurbulence
All of those elements for filter effects support these attributes:
Attribute |
Notes |
---|---|
x |
|
y |
|
width |
|
height |
|
result |
Some filter effect elements take one input in the in
attribute, and
some others take two inputs in the in
, in2
attributes. See the
table of elements above for details.
Filter effect feComponentTransfer¶
The feComponentTransfer
element can contain children feFuncA
,
feFuncR
, feFuncG
, feFuncB
, and those all support these
attributes:
Attribute |
Notes |
---|---|
type |
|
tableValues |
|
slope |
|
intercept |
|
amplitude |
|
exponent |
|
offset |
CSS features¶
Pseudo-classes¶
Pseudo-class |
Notes |
---|---|
:link |
|
:visited |
Because librsvg does not maintain browser history, this is parsed, but never matches |
:lang() |
|
:not() |
|
:first-child |
|
:last-child |
|
:only-child |
|
:root |
|
:empty |
|
:nth-child() |
|
:nth-last-child() |
|
:nth-of-type() |
|
:nth-last-of-type() |
|
:first-of-type |
|
:last-of-type |
|
:only-of-type |
FIXME: which selectors, combinators, at-rules.
XML features¶
XInclude¶
Librsvg supports the following subset of XML Inclusions (XInclude).
A document or element may declare the namespace for
http://www.w3.org/2001/XInclude
, conventionally as an attribute
xmlns:xi="http://www.w3.org/2001/XInclude"
.
The following discussion assumes an xi:
shorthand; your namespace
declaration may use a different one, but xi:
is conventional for
XInclude.
The following are examples of valid inclusions:
<xi:include href="foo.xml" parse="xml"/>
<!-- If foo.xml cannot be read, parsing stops with an error -->
<xi:include href="foo.xml" parse="xml">
<xi:fallback>
<some_fallback_element/>
<another_fallback_element/>
</xi:fallback>
</xi:include>
<!-- If foo.xml cannot be read, the elements inside xi:fallback are used instead.
If foo.xml has a syntax error, parsing stops with an error. -->
<xi:include href="foo.txt" parse="text" encoding="utf-8">
<xi:fallback>
Text to be included if foo.txt cannot be read.
</xi:fallback>
</xi:include>
For the xi:include
element, the href
attribute is mandatory,
and parse
and encoding
are optional:
href
- mandatory for librsvg. This is different from the XInclude specification: the attribute is mandatory in librsvg, while the spec assumes that if it is not present, then anxpointer
orfragid
attributes are used instead. Librsvg does not support those. If there is nohref
attribute, librsvg will ignore the wholexi:include
element.parse
- optional; supported values arexml
andtext
; the default isxml
.encoding
- optional; only used for including text files withparse="text"
. The value should be a WHATWG label for an encoding, for example,utf-8
orkoi8-r
.
Inside <xi:include>
, there can be an <xi:fallback>
element to
specify what should be included if the href
cannot be read.
xml:lang
and xml:space
¶
Individual elements can specify an xml:lang attribute to specify their language.
This can be used in a <text>
element for the main language of its
content, or generally for the purposes of CSS selector matching. Note
that this is different from the use of systemLanguage
in children
of the <switch>
element, which is used to render different
elements depending on the system’s language.
Librsvg supports the xml:space attribute and its handling per SVG1.1. Note that this has been superseded in SVG2 with CSS whitespace handling; librsvg does not support this yet as of 2023/Feb/10.
Explicitly Unsupported features¶
flowRoot
element and its children - Inkscape, SVG 1.2 only.glyph-orientation-horizontal
property - SVG1.1 only, removed in SVG2The pseudo-classes
:is()
and:where()
are part of Selectors Level 4, which is still a working draft.