"Removing the background" of svg text without scripts can be done using svg filters.
For example:
<filter x="0" y="0" width="1" height="1" id="removebackground"> <feFlood flood-color="blue"/> <feComposite in="SourceGraphic"/> </filter>
What can be used in the text as follows:
<use xlink:href="#text1" fill="black" filter="url(#removebackground)"/>
This automatically adapts to the line width. If you need some addition, you can adjust the x, y, width, height attributes in the filter element.
Hmm, thinking about it again, this may not be what you exactly wanted. But you can adapt the above. Here is your file with this solution:
<svg version="1.1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="100%" height="100%" viewBox="0 0 620 1100" preserveAspectRatio="xMidYMid meet"> <defs> <text id="text1" x="90" y="100" style="text-anchor:start;font-size:30px;">THIS IS MY HEADER</text> <text id="text2" x="525" y="1010" style="text-anchor:end;font-size:30px;">MY TEXT HERE</text> <filter x="0" y="0" width="1" height="1" id="removebackground"> <feFlood flood-color="black"/> </filter> <mask id="Mask1"> <rect x="0" y="0" width="620" height="1100" style="fill:white;" /> <use xlink:href="#text1" filter="url(#removebackground)"/> <use xlink:href="#text2" filter="url(#removebackground)"/> </mask> </defs> <rect x="0" y="0" width="620" height="1100" style="fill:#f0ffb6"/> <rect x="100" y="100" rx="20" ry="20" width="420" height="900" mask="url(#Mask1)" style="fill:none;stroke:green;stroke-width:5"/> <use xlink:href="#text1" fill="black" stroke="black" stroke-width="1" /> <use xlink:href="#text2" fill="black" stroke="black" stroke-width="1" /> <text x="200" y="200">This text goes into the border</text> </svg>
Erik DahlstrΓΆm Sep 04 2018-12-12T00: 00Z
source share