Description
When an SVG image's raw code (XML
) is embedded in a component or template, it becomes a special DOM element, whose objects are available for CSS styling via ID
or class
selector.
Selectors
ID
Inkscape V1.4 objects have an ID
property field in their Object Properties
panel.
Class
To add a class selector to an SVG object:
- Select SVG object
- Open
Object Properties
and select+
in bottom, left of panel (Add a new CSS Selector
). - Enter
.some-class-name
when prompted forCSS Selector
CSS Attributes
Common SVG attributes used to style SVGs include:
fill
andstroke
stroke-width
,stroke-linecap
andstroke-linejoin
opacity
,fill-opacity
andstroke-opacity
font-family
,font-size
andfont-weight
Data store
SVGs must be inlined in HTML ('.html', template, component etc.) in order to style its objects using its class
or id
selectors.