Search code examples
htmlinternet-explorersvgtooltip

Multiline in SVG <title> (Internet Explorer) | Linebreak, tabulations


I would like to add a multiline tooltip to my SVG path using the <title> tag.

It works perfectly in Chrome, but the linebreak characters I have tried result in a space in Internet Explorer.

Also in Internet Explorer, the multiline works in the title="" attribute.

The below code snippet has the same muliline tootltip on a svg and on a button. To be run in IE.

<svg height="100" width="100">
    <path d="M45 0 L15 80 L75 80 Z">
        <title>test&#xA;test</title>
        <!--<title>test&#xA;test</title>-->
        <!--<title>test&#10;test</title>-->
        <!--<title>test&#13;test</title>-->
    </path>
</svg>
<div><button title="test&#xA;test">It works here</button><div>


Solution

  • In the IE browser, using <br> tag to add a line break in the SVG element; In the Microsoft Edge and Chrome browser using the &#xA; add a line break.

    Code as below:

    <svg height="100" width="100">
        <path d="M45 0 L15 80 L75 80 Z">
            <title>test&#xA;<br>test</title>
            <!--<title>test&#xA;test</title>-->
            <!--<title>test&#10;test</title>-->
            <!--<title>test&#13;test</title>-->
        </path>
    </svg>
    <div><button title="test&#xA;test">It works here</button></div>
    

    Output like this:

    IE browser:

    enter image description here

    Chrome Browser:

    enter image description here