Menu Close

How to wrap text in a pre tag with CSS?

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.

Posted in CSS