Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

CSS | overflow-wrap Property

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

The overflow-wrap property in CSS is used to specify that the browser may break lines of text inside any targeted element to prevent overflow when the original string is too long to fit. This property was earlier known as word-wrap that still supported by some browsers but it was renamed to overflow-wrap in a CSS3 draft. 

Syntax:

.box{
    overflow-wrap: break-word;
}

Values:

  • normal: The lines will break according to the original line breaking rules.
  • break-word: Words that are too long to fit in a container-element break into parts.
  • inherit: It allows the element to inherit value from its parent.
  • initial: It makes the property to use its default value.

Example: 

html




<!DOCTYPE html>
<html>
 
<head>
    <title>
        CSS overflow-wrap property
    </title>
 
    <style>
        p {
            color: green;
        }
 
        .gfg {
            margin: auto;
            padding: 15px 15px;
            color: white;
            background-color: green;
            font-size: 20px;
            width: 60px;
            overflow-wrap: break-word;
        }
 
        div {
            text-align: justify;
        }
 
        h1,
        h2 {
            color: green;
        }
 
        h1,
        h2 {
            text-align: center;
        }
    </style>
</head>
 
<body>
    <h1>GeeksforGeeks</h1>
    <h2>overflow-wrap property</h2>
    <div class="gfg">
        A computer science portal for geeks.
    </div>
</body>
 
</html>

Output:

Supported Browsers:

  • Chrome 23
  • Edge 18
  • Firefox 49
  • Opera 12.1
  • Safari 7

My Personal Notes arrow_drop_up
Last Updated : 24 Aug, 2022
Like Article
Save Article
Similar Reads
Related Tutorials