Title html добавить строку

How can I add new line/linebreak character in title attribute in HTML [duplicate]

I am using this Click here When someone hover over it I see all the text in one line. Is there any way to show it on new line?

4 Answers 4

If they do not work individually for your browser, try using both together, and that should do the trick, .

If you are generating it dynamically put < br/>in html part and \n in non html part

$("td").attr("title", "One \n Two \n Three"); $("td").html("One 
Two \n
Three
"); $("td").append("One \n Two \n Three"); $("td").append("
One
Two \n Three");

This is using Jquery framework.

As you tagged this with accessibility, I would say the most robust approach is not to rely on the title for information.

The current HTML spec discourages this use as people using who cannot use a mouse (e.g. due to mobility impairment) but use a keyboard and see the screen will never see your tooltip/title text. People using touch screens cannot access it.

Most people using a screen reader will not be aware of the title text either, although it is possible to access in most screen readers it is not read out by default, and someone would have to know to look for it. (And there are more issues.)

The spec suggests using this for line breaks:

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

However, the display of the new lines is dependant on the browser (How can I use a carriage return in a HTML tooltip).

Читайте также:  Welcome to Example.com!

I suspect that the overall UI approach needs a little more thought, as many people would be confused by the sort of instruction in your example, i.e. what does clicking on it achieve if there are multiple options?

If your situation makes it difficult to write good link text then I would post up more about the interaction at the UX stackexchange.

Источник

Перенос строки в атрибуте title

Как сделать перенос строки в атрибуте title в firefox? В опере работает такое . Отображает так:

первая строка вторая строка и тд. 

извините, я чтот не о том подумал))вполне, возможно, что никак. но есть такая замечательная штука, как Tooltip. можно попробовать с помощью этой техники решить Вашу проблему.

2 ответа 2

В title передавать знак переноса строки = полное отсутствие кросбраузерности. Рекомендую использовать Tooltip. Если нужны подробности смотрите на этом сайте. Здесь при наведении на информационный значок. JS файл на этой же странице, СSS там же.

1 Вариант:

2 Вариант:

Согласно стандарту HTML любое количество подряд идущих пробельных символов должно интерпретироваться как один пробел.

Похожие

Подписаться на ленту

Для подписки на ленту скопируйте и вставьте эту ссылку в вашу программу для чтения RSS.

Дизайн сайта / логотип © 2023 Stack Exchange Inc; пользовательские материалы лицензированы в соответствии с CC BY-SA . rev 2023.7.27.43548

Нажимая «Принять все файлы cookie» вы соглашаетесь, что Stack Exchange может хранить файлы cookie на вашем устройстве и раскрывать информацию в соответствии с нашей Политикой в отношении файлов cookie.

Источник

Оцените статью