How to remove word wrap from textarea?

textarea {
  white-space: pre;
  overflow-wrap: normal;
  overflow-x: scroll;
}

white-space: nowrap also works if you don’t care about whitespace, but of course you don’t want that if you’re working with code (or indented paragraphs or any content where there might deliberately be multiple spaces) … so i prefer pre.

overflow-wrap: normal (was word-wrap in older browsers) is needed in case some parent has changed that setting; it can cause wrapping even if pre is set.

also — contrary to the currently accepted answer — textareas do often wrap by default. pre-wrap seems to be the default on my browser.

Leave a Comment