Categories
CSS

How to wrap text in a pre tag with CSS?

Spread the love

Sometimes, we want to wrap text in a pre tag with CSS.

In this article, we’ll look at how to wrap text in a pre tag with CSS.

How to wrap text in a pre tag with CSS?

To wrap text in a pre tag with CSS, we set the white-space property.

For instance, we write

pre {
  white-space: pre-wrap;
}

to set white-space to pre-wrap to make the text in the pre element wrap.

Conclusion

To wrap text in a pre tag with CSS, we set the white-space property.

By John Au-Yeung

Web developer specializing in React, Vue, and front end development.

Leave a Reply

Your email address will not be published. Required fields are marked *