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

前端 未结 27 1335
说谎
说谎 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:47

    According to this article on the w3c website:

    CDATA is a sequence of characters from the document character set and may include character entities. User agents should interpret attribute values as follows:

    • Replace character entities with characters,
    • Ignore line feeds,
    • Replace each carriage return or tab with a single space.

    This means that (at least) CR and LF won't work inside title attribute. I suggest that you use a tooltip plugin. Most of these plugins allow arbitrary HTML to be displayed as an element's tooltip.

提交回复
热议问题