I have the following HTML, dynamicaly generated by TIBCO Spotfire.
div#mod-container text {
font-family: "Segoe UI";
color: #000058;
font-size: 22px;
font-weight: 500;
}
<div id="mod-container">
<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 360 100">
<g id="backgroundLayer">
<text class="displayText" x="180" y="50" alignment-baseline="central">
15918
</text>
</g>
</svg>
</div>
I would like to change some of the style parameters from the inside the SVG, and I have did the following:
div#mod-container text {
font-family: "Segoe UI";
color: #000058;
font-size: 22px;
font-weight: 500;
}
and
text.displayText {
font-family: "Segoe UI";
color: #000058;
font-size: 22px;
font-weight: 500;
}
Unfortunately, none of the above approaches have worked. Any idea would be welcome.
Marcio
3
Answers
Only a limited css style rules are applicable in
<svg>
elements and its sub-elements.In your case, replace color, with fill. rest all properties should be working. And yes, both the ways you have used to style the element is correct. Better is to use the css class to style, rather than the ID.
Check https://css-tricks.com/svg-properties-and-css/ for detailed information of which CSS properties are supported in SVG elements and its sub-elements.
This code should work for you: