How can I use a carriage return in a HTML tooltip?

前端 未结 27 1285
说谎
说谎 2020-11-22 11:59

I\'m currently adding verbose tooltips to our site, and I\'d like (without having to resort to a whizz-bang jQuery plugin, I know there are many!) to use carriage returns to

相关标签:
27条回答
  • 2020-11-22 12:24

    From the information available on accessibility and the use of tooltips making them larger with the use of CR or line break is appreciated, the fact that the various browsers cannot/will not agree on basics shows that they don't much care about accessibility.

    0 讨论(0)
  • 2020-11-22 12:27

    As a contribution to the 
 solution, we can also use &#009 for tabs if you ever need to do something like this.

    <button title="My to-do list:&#013;&#009;-Item 2&#013;&#009;-Item 3&#013;&#009;-Item 4&#013;&#009;&#009;-Subitem 1">TEST</button>

    Demo

    0 讨论(0)
  • 2020-11-22 12:27

    On Chrome 79, &#13; does not work anymore.

    I was successful with:

    &#13;&#10;

    This works in all major browsers.

    0 讨论(0)
  • 2020-11-22 12:27

    Just use JavaScript. Then compatible with most and older browsers. Use the escape sequence \n for newline.

       document.getElementById("ElementID").title = 'First Line text \n Second line text'
    
    0 讨论(0)
  • 2020-11-22 12:28

    It’s so simple you’ll kick yourself: just press Enter!

    <a title='Tool
    Tip
    On
    New
    Line'>link with tip</a>
    
    0 讨论(0)
  • 2020-11-22 12:28

    On Chrome 16, and possibly earlier versions, you can use "\n". As a sidenote, "\t" also works

    0 讨论(0)
提交回复
热议问题