Types

SVG attribute types

This table details the type of each supported SVG attribute. If a constraint applies to an SVG attribute, the result of evaluating its expression will be converted to the type listed here.

Attribute name Element name Attribute type
accent-height Number
accumulate AccumulateValue
alignment-baseline AlignmentBaselineValue
alphabetic Number
amplitude Number
arabic-form String
ascent Number
attributeType String
azimuth Number
baseFrequency NumberOptionalNumber
baseProfile String
baseline-shift BaselineShiftValue
bbox String
bias Number
by String
calcMode CalcModeValue
cap-height Number
class ClassList
clip ClipValue
clip-path OptionalURI
clip-rule ClipFillRule
clipPathUnits UnitsValue
color Color
color-interpolation ColorInterpolationValue
color-interpolation-filters ColorInterpolationValue
color-profile String
color-rendering ColorImageRenderingValue
contentScriptType ContentType
contentStyleType ContentType
cursor CursorValue
cx Coordinate
cy Coordinate
d PathData
descent Number
diffuseConstant Number
direction DirectionValue
display DisplayValue
divisor Number
dominant-baseline DominantBaselineValue
dur String
dx altGlyph Lengths
dx feOffset Number
dx glyphRef Number
dx text Lengths
dx tref Lengths
dx tspan Lengths
dy altGlyph Lengths
dy feOffset Number
dy glyphRef Number
dy text Lengths
dy tref Lengths
dy tspan Lengths
edgeMode EdgeModeValue
elevation Number
enable-background EnableBackgroundValue
end String
exponent Number
externalResourcesRequired Boolean
fill animate FillValue
fill animateColor FillValue
fill animateMotion FillValue
fill animateTransform FillValue
fill set FillValue
fill Paint
fill-opacity OpacityValue
fill-rule ClipFillRule
filter OptionalURI
filterRes NumberOptionalNumber
filterUnits UnitsValue
flood-color SVGColor
flood-opacity OpacityValue
font-family font-face String
font-family FontFamilyValue
font-size font-face String
font-size FontSizeValue
font-size-adjust FontSizeAdjustValue
font-stretch font-face String
font-stretch FontStretchValue
font-style font-face String
font-style FontStyleValue
font-variant font-face String
font-variant FontVariantValue
font-weight font-face String
font-weight FontWeightValue
format String
from String
fx Coordinate
fy Coordinate
g1 String
g2 String
glyph-name String
glyph-orientation-horizontal GlyphOrientationHorizontalValue
glyph-orientation-vertical GlyphOrientationVerticalValue
glyphRef String
gradientTransform TransformList
gradientUnits UnitsValue
hanging Number
height Length
horiz-adv-x Number
horiz-origin-x Number
horiz-origin-y Number
ideographic Number
image-rendering ColorImageRenderingValue
in String
in2 String
intercept Number
k Number
k1 Number
k2 Number
k3 Number
k4 Number
kernelMatrix String
kernelUnitLength NumberOptionalNumber
kerning KerningValue
keyPoints String
keySplines String
keyTimes String
lang LanguageCodes
lengthAdjust LengthAdjustValue
letter-spacing SpacingValue
lighting-color SVGColor
limitingConeAngle Number
local String
marker-end OptionalURI
marker-mid OptionalURI
marker-start OptionalURI
markerHeight Length
markerUnits MarkerUnitsValue
markerWidth Length
mask OptionalURI
maskContentUnits UnitsValue
maskUnits UnitsValue
mathematical Number
max String
media MediaDesc
method MethodValue
min String
mode ModeValue
name String
numOctaves Integer
offset stop NumberOrPercentage
offset Number
onabort Script
onactivate Script
onbegin Script
onclick Script
onend Script
onerror Script
onfocusin Script
onfocusout Script
onload Script
onmousedown Script
onmousemove Script
onmouseout Script
onmouseover Script
onmouseup Script
onrepeat Script
onresize Script
onscroll Script
onunload Script
onzoom Script
opacity OpacityValue
operator feComposite CompositeOperatorValue
operator feMorphology MorphologyOperatorValue
order NumberOptionalNumber
orient String
orientation String
origin String
overflow OverflowValue
overline-position Number
overline-thickness Number
panose-1 String
path String
pathLength Number
patternContentUnits UnitsValue
patternTransform TransformList
patternUnits UnitsValue
pointer-events PointerEventsValue
points Points
pointsAtX Number
pointsAtY Number
pointsAtZ Number
preserveAlpha Boolean
preserveAspectRatio PreserveAspectRatioSpec
primitiveUnits UnitsValue
r Length
radius NumberOptionalNumber
refX Coordinate
refY Coordinate
rendering-intent RenderingIntentValue
repeatCount String
repeatDur String
requiredExtensions ExtensionList
restart RestartValue
result String
rotate animateMotion String
rotate Numbers
rx Length
ry Length
scale Number
seed Number
shape-rendering ShapeRenderingValue
slope Number
specularConstant Number
specularExponent Number
spreadMethod SpreadMethodValue
startOffset Length
stdDeviation NumberOptionalNumber
stemh Number
stemv Number
stitchTiles StitchTilesValue
stop-color SVGColor
stop-opacity OpacityValue
strikethrough-position Number
strikethrough-thickness Number
stroke Paint
stroke-dasharray StrokeDashArrayValue
stroke-dashoffset LengthOrInherit
stroke-linecap StrokeLinecapValue
stroke-linejoin StrokeLinejoinValue
stroke-miterlimit MiterLimitValue
stroke-opacity OpacityValue
stroke-width LengthOrInherit
surfaceScale Number
systemLanguage LanguageCodes
tableValues String
target LinkTarget
targetX Integer
targetY Integer
text-anchor TextAnchorValue
text-decoration TextDecorationValue
text-rendering TextRenderingValue
textLength Length
title String
to String
transform TransformList
type animateTransform AnimateTransform
type script ContentType
type style ContentType
type feTurbulence TurbulenceTypeValue
type ComponentTransferTypeValue
u1 String
u2 String
underline-position Number
underline-thickness Number
unicode String
unicode-bidi UnicodeBidiValue
unicode-range String
units-per-em Number
v-alphabetic Number
v-hanging Number
v-ideographic Number
v-mathematical Number
values String
version Number
vert-adv-y Number
vert-origin-x Number
vert-origin-y Number
viewBox ViewBoxSpec
viewTarget String
visibility VisibilityValue
width Length
widths String
word-spacing SpacingValue
writing-mode WritingModeValue
x altGlyph Coordinates
x fePointLight Number
x feSpotLight Number
x glyphRef Number
x text Coordinates
x tref Coordinates
x tspan Coordinates
x Coordinate
x1 Coordinate
x2 Coordinate
xChannelSelector ChannelSelectorValue
xlink:href URI
y altGlyph Coordinates
y fePointLight Number
y feSpotLight Number
y glyphRef Number
y text Coordinates
y tref Coordinates
y tspan Coordinates
y Coordinate
y1 Coordinate
y2 Coordinate
yChannelSelector ChannelSelectorValue
z Number
zoomAndPan ZoomAndPanValue

Type conversion

Any type can be converted to a string, and a string can be converted to any type. Converting a string to another type does require the value to have the right format, however. Some types are strict supersets of other types. In these cases, the subtype can be converted to the supertype. The table below details the type conversions that are allowed.

From type To type
Integer Number
Length
GlyphOrientationHorizontalValue
NumberOrPercentage
NumberOptionalNumber
BaselineShiftValue
OpacityValue
FontSizeValue
FontSizeAdjustValue
GlyphOrientationVerticalValue
KerningValue
SpacingValue
LengthOrInherit
StrokeMiterLimitValue
Length FontSizeValue
KerningValue
SpacingValue
LengthOrInherit
Number Length
GlyphOrientationHorizontalValue
NumberOrPercentage
NumberOptionalNumber
BaselineShiftValue
OpacityValue
FontSizeValue
FontSizeAdjustValue
GlyphOrientationVerticalValue
KerningValue
SpacingValue
LengthOrInherit
StrokeMiterLimitValue
NumberOrPercentage BaselineShiftValue
FontSizeValue
URI OptionalURI
CursorValue

Operators

Some of the XPath operators have been overloaded for a few SVG types. The behaviour of these operators is listed in the table below. If an operator is applied to objects of types not present in the table, the normal XPath operator behaviour will apply.

Left operand type Operator Right operand type Behaviour
Point + Point Performs an element-wise addition of the two Point objects.
Point - Point Performs an element-wise subtraction of the second Point object from the first.
Point * Number Performs a scalar multiplication of the Number by the Point object.
Number * Point Performs a scalar multiplication of the Number by the Point object.
Point div Number Performs a scalar division of the Point object by the Number.
Point = Point Returns true if the Points are equal, false otherwise.
Point != Point Returns true if the Points are unequal, false otherwise.
Length + Length Converts both Length objects into user units and adds the two Lengths together.
Length + Number Converts the Length object into user units and adds the Length to the Number.
Number + Length Converts the Length object into user units and adds the Length to the Number.
Length - Length Converts both Length objects into user units and subtracts the second Length from the first.
Length - Number Converts the Length object into user units and subtracts the Number from the Length.
Number - Length Converts the Length object into user units and subtracts the Length from the Number.
Length * Number Converts the Length object into user units and multiplies it by the Number.
Number * Length Converts the Length object into user units and multiplies it by the Number.
Length div Number Converts the Length object into user units and divides it by the Number.
Length = Length Returns true if the Lengths are equal, false otherwise.
Length != Length Returns true if the Lengths are unequal, false otherwise.
Rect + Rect Performs an element-wise addition of the two Rects.
Rect - Rect Performs an element-wise subtraction of the second Rect from the first.
Rect * Number Performs an element-wise multiplication of the Rect by the Number.
Rect * Number Performs a scalar multiplication of the Rect by the Number.
Number * Rect Performs a scalar multiplication of the Rect by the Number.
Rect div Number Performs a scalar division of the Rect by the Number.
Rect = Rect Returns true if the two Rects are equal, false otherwise.
Rect != Rect Returns true if the two Rects are unequal, false otherwise.
Matrix * Matrix Multiplies the first Matrix by the second Matrix, in effect concatenating the second transformation to the first.
Matrix * Point Multiplies the Matrix by the Point, in effect transforming the Point by the transformation represented by the Matrix.
Matrix = Matrix Returns true if the two Matrices are equal, false otherwise.
Matrix != Matrix Returns true if the two Matrices are unequal, false otherwise.

Last updated: 12th February, 2004
HTTP/1.1 200 OK Date: Thu, 18 Apr 2024 11:12:07 GMT Server: Apache/2.4.6 (Red Hat Enterprise Linux) Content-Length: 0 Connection: close Content-Type: application/x-perl