Перейти к содержимому

HTML-тег <nobr>

Тег <nobr> не даёт тексту переноситься на новую строку: весь фрагмент остаётся в одной линии. Если контейнер уже текста, появляется горизонтальная полоса прокрутки.

Обычно браузер переносит длинную строку; <nobr> отключает автоматический перенос.

DANGER

<nobr> нестандартен; использовать не рекомендуется. Вместо него — CSS white-space.

Синтаксис

Парный тег.

Пример <nobr>

Длинный текст в одной строке

html
<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
  </head>
  <body>
    <nobr>
     Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown printer took a galley of type and scrambled it to make a type specimen book.
    </nobr>
  </body>
</html>

Результат

nobr example

Тот же эффект даёт white-space: nowrap у блочного элемента.

CSS вместо <nobr>

html
<!DOCTYPE html>
<html>
  <head>
    <title>Title of the document</title>
    <style>
      p.a {
        white-space: nowrap;
      }
    </style>
  </head>
  <body>
    <h1>Example of using the CSS property white-space</h1>
    <p class="a">
      It is an ordinary and very long text that is very inconvenient to read, as it is written in one line, and you have to scroll horizontally to read it.
    </p>
  </body>
</html>

Атрибуты

Глобальные атрибуты и атрибуты событий.

Глобальные атрибуты на <nobr>

html
<nobr id="my-text" class="highlight">
  This text will stay on one line and can be targeted or styled using global attributes.
</nobr>

Practice

Что делает тег nobr в HTML?

Предпросмотр dual-run — сравните с маршрутами Symfony на продакшене.