Open In App
Related Articles

CSS word-wrap Property

Improve Article
Improve
Save Article
Save
Like Article
Like

The word-wrap property in CSS is used to break long words and wrap them into the next line. It defines whether to break words when the content exceeds the boundaries of its container.  

  

Syntax:

word-wrap: normal|break-word|initial|inherit;

Property Value:

  • normal: It is the default value, The lines can only be broken at normal break points (spaces, non-alphanumeric characters, etc.). 
  • break-word: Words that exceed the width of the container will be arbitrarily broken to fit within the container’s bounds.
  • initial: It is used to set word-wrap property to its default value.
  • inherit: This property is inherited from its parent.

Example: In this example, we are using word-wrap: normal; property.

html




<!DOCTYPE html>
<html>
   
<head>
    <title>
        word-wrap property
    </title>
 
    <style>
        div {
            word-wrap: normal;
            width: 150px;
            border: 1px solid black;
        }
    </style>
</head>
 
<body>
    <div>
        GeeksforGeeks:AComputerSciencePortalForGeeks
    </div>
 
</body>
   
</html>


Output:

 word wrap 

Example: In this example, we are using word-wrap: break-word property.

html




<!DOCTYPE html>
<html>
   
<head>
    <title>
        word-wrap property
    </title>
 
    <style>
        div {
            word-wrap: break-word;
            width: 150px;
            border: 1px solid black;
        }
    </style>
</head>
 
<body>
    <div>
        GeeksforGeeks:AComputerSciencePortalForGeeks
    </div>
 
</body>
   
</html>


Output:

word wrap

Supported Browsers: The browser supported by word-wrap property are listed below:

  • Google Chrome 
  • Firefox
  • Safari
  • Opera

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!

Last Updated : 20 Jun, 2023
Like Article
Save Article
Previous
Next
Similar Reads
Complete Tutorials