Languages
[Edit]
EN

CSS - how to disable line wrapping in HTML?

2 points
Created by:
DrJoystick
585

Using CSS it is possible to remove line wrapping in following ways.

Note: read this article how to disable world wrapping.

1. white-space: nowrap example

// ONLINE-RUNNER:browser;

<!doctype html>
<html>
<head>
  <style>

    p {
        border: 1px solid black;
        width: 200px;
        white-space: nowrap;
    }

  </style>
</head>
<body>
  <p>
    Very long web page text here: 1 2 3 4 5 ...
    Very long web page text here: 1 2 3 4 5 ...
  </p>
</body>
</html>

Note: use <br /> element to break lines.

2. white-space: pre example

This approach makes text behaving similar to pre tag - white characters in source code are visible on web page.

// ONLINE-RUNNER:browser;

<!doctype html>
<html>
<head>
  <style>

    p {
        border: 1px solid black;
        width: 200px;
        white-space: pre;
    }

  </style>
</head>
<body>
  <p>Very long web page text here: 1 2 3 4 5 ...
Very long web page text here: 1 2 3 4 5 ...</p>
</body>
</html>

Merged quastions

  1. CSS - how to turn off line wrapping in HTML?
  2. CSS - how to remove line wrapping in HTML?
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.

CSS

Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join