Monday, January 6, 2025
HomeProgrammingHow to wrap text in CSS

How to wrap text in CSS

To wrap text in CSS, use the following properties:

  1. word-wrap (Deprecated, use overflow-wrap)
    Forces text to wrap onto the next line if it’s too long.

    css
    word-wrap: break-word;
  2. overflow-wrap (Preferred)
    Similar to word-wrap for breaking long words.

    css
    overflow-wrap: break-word;
  3. white-space
    Controls how whitespace and line breaks are handled:

    css
    white-space: normal; /* Default: wraps text */
  4. Example:
    css
    p {
    overflow-wrap: break-word;
    white-space: normal;
    }

Default Behavior:

Most block elements like <p> wrap text automatically unless styles like white-space: nowrap; are applied.

RELATED ARTICLES
0 0 votes
Article Rating

Leave a Reply

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
- Advertisment -

Most Popular

Recent Comments

0
Would love your thoughts, please comment.x
()
x