Skip to content
Related Articles

Related Articles

CSS | overflow-wrap Property
  • Last Updated : 13 May, 2020

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:




<!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:




My Personal Notes arrow_drop_up
Recommended Articles
Page :