Wrapping title attribute

后端 未结 3 1313
难免孤独
难免孤独 2021-01-24 23:16

Firefox does not wrap words in a title attribute:


Is there a way to do word-wr

相关标签:
3条回答
  • 2021-01-24 23:21

    For what it's worth, the only part of the HTML5 specifications that deals with line breaks in title attributes states:

    If the title attribute's value contains U+000A LINE FEED (LF) characters, the content is split into multiple lines. Each U+000A LINE FEED (LF) character represents a line break.

    So you could break up the title attribute on the server-side, although this is unlikely to be a desirable solution. Alternatively, you can try inserting zero width spaces, though browser support for this may also be inconsistent.

    0 讨论(0)
  • 2021-01-24 23:32

    Use escaped n, example:

    <input type="text" title="first line \n second line"></input>
    
    0 讨论(0)
  • 2021-01-24 23:42

    No, you cannot make Firefox deviate from its way of rendering title attribute values; cf. to How can I use a carriage return in a HTML tooltip?

    The tooltips created by using title attributes are of questionable usability (tiny font that cannot be easily increased by the user; disapperance after some seconds; etc.), so they are suitable (at most) for short advisory titles (mainly for links), which not cause a need for wrapping.

    For longer tooltips, consider using CSS techniques. Or just put the tip into the text proper.

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