CSS Word Wrap
Advertisements
CSS Word Wrap
CSS Word Wrap properties are used for break the long words and wrap onto the next line. The main use of this properties is to prevent overflow when a long string unable to fit into containing box.
CSS word wrap values
Value | Description |
---|---|
normal | This property is used to break words only at allowed break points. |
break-word | It is used to break unbreakable words. |
initial | It sets this property to its default value. |
inherit | It inherits this property from its parent element. |
Example without using word-break
In below example we understand what happen when we do not use word-break. Larger word will be display out side the box area
Example
<!DOCTYPE html> <html> <head> <style> p.box { width: 140px; background: cyan; border: 1px solid #000000; padding:10px; } </style> </head> <body> <p class="box">This is my first html with css code. Now i am happyyyyyyyyyyyyyyyyyyy. How are you friendssssssssssssssssss?</p> </body> </html>
Result
This is my first html with css code. Now i am happyyyyyyyyyyyyyyyyyyy. How are you friendssssssssssssssssss?.
Example using word-break
Example
<!DOCTYPE html> <html> <head> <style> p.box { width: 140px; background: cyan; border: 1px solid #000000; padding:10px; word-wrap: break-word; } </style> </head> <body> <p class="box">This is my first html with css code. Now i am happyyyyyyyyyyyyyyyyyyy. How are you friendssssssssssssssssss?</p> </body> </html>
Result
This is my first html with css code. Now i am happyyyyyyyyyyyyyyyyyyy. How are you friendssssssssssssssssss?.
Browser supported
Properties | |||||
word-wrap | Yes | Yes | Yes | Yes | Yes |
Google Advertisment