Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SVG: Set <text> content with CSS

Tags:

css

svg

Can I

<svg>
  <text></text>
</svg>

svg text {
  content: 'a';
  font-family: 'Glyphicon Halflings';
}

?

It seems :before and :after pseudo-elements are not available, but I would be very happy to have my content set by css. Can I?

like image 593
Augustin Riedinger Avatar asked Jul 24 '15 10:07

Augustin Riedinger


1 Answers

Not possible using pure CSS. Need to use simple JS:

function changeMyText()
{
    document.getElementById('MyText').textContent = "new text";
}

and create ID for your SVG text:

<svg>
    <text id="MyText"></text>
</svg>
like image 80
G3ck Avatar answered Oct 28 '22 18:10

G3ck