I'm trying to use the following CSS to automatically set the style for <g>
Elements.
<style type="text/css">
g[inkscape|label="Site"] {
fill: blue;
stroke: red;
stroke-width: 3
}
g[inkscape|label="Building"] {
fill: black;
stroke: red;
stroke-width: 3
}
</style>
However the elements remain without fill or stroke settings set.
Selecting another attribute without a namespace works fine.
Thank you.
Small addition to @alohci’s answer: The attribute names used in CSS must be all lowercase in some browsers. See the following example where the line is orange but not 10 px wide in Firefox 33 and IE 11. Google Chrome 39 does paint it 10 px wide.
This depends what the context of the question is. Is the SVG a stand-alone file, embedded in an xhtml file (i.e. served as
application/xhtml+xml
) or embedded in an html file (i.e. served astext/html
)If it's standalone SVG, you can do
See http://alohci.net/static/svg_ns.svg
If it's in an XHTML file, you can do
See http://alohci.net/static/svg_ns.xhtml
If it's in an html file, it's a little different because the html parser doesn't support custom namespaces. Instead you have to treat the attribute's name as if it was just a normal name with a colon in it. So you'd do
See http://alohci.net/static/svg_ns.html