HTML | DOM Style wordWrap Property Last Updated : 20 Oct, 2021 Comments Improve Suggest changes Like Article Like Report The Style wordWrap property in HTML DOM is used to set or return whether long words should be broken to wrap around to the next line. Syntax: To get the wordWrap property object.style.wordWrap To set the wordWrap property object.style.wordWrap = "normal|break-word|initial|inherit" Property Values: normal: This is used to break long words only at the break points. Return Values: It returns a string value, which representing the word-wrap property of an element Example-1: html <!DOCTYPE html> <html> <head> <title> DOM Style wordWrap Property </title> <style> .content { border: 1px solid; height: 200px; width: 200px; word-wrap: break-word; } </style> </head> <body> <h1 style="color: green"> GeeksforGeeks </h1> <b> DOM Style wordWrap Property </b> <p> The wordWrap property specifies whether long words should be broken to wrap around to the next line. </p> <div class="content"> GeeksforGeeksisacomputerscienceportal. </div> <button onclick="setWordWrap()"> Change wordWrap </button> <!-- Script to set wordWrap to normal --> <script> function setWordWrap() { elem = document.querySelector('.content'); elem.style.wordWrap = 'normal'; } </script> </body> </html> Output: Before clicking the button: After clicking the button: break-word: This is used to allow unbreakable words to be broken to the next line. Example-2: html <!DOCTYPE html> <html> <head> <title> DOM Style wordWrap Property </title> <style> .content { border: 1px solid; height: 200px; width: 200px; } </style> </head> <body> <h1 style="color: green"> GeeksforGeeks </h1> <b> DOM Style wordWrap Property </b> <p> The wordWrap property specifies whether long words should be broken to wrap around to the next line. </p> <div class="content"> GeeksforGeeksisacomputerscienceportal. </div> <button onclick="setWordWrap()"> Change wordWrap </button> <!-- Script to set wordWrap to break-word --> <script> function setWordWrap() { elem = document.querySelector('.content'); elem.style.wordWrap = 'break-word'; } </script> </body> </html> Output: Before clicking the button: After clicking the button: initial: This is used to set the property to its default value. Example-3: html highligt=38-39 <!DOCTYPE html> <html> <head> <title> DOM Style wordWrap Property </title> <style> .content { border: 1px solid; height: 200px; width: 200px; word-wrap: break-word; } </style> </head> <body> <h1 style="color: green"> GeeksforGeeks </h1> <b>DOM Style wordWrap Property</b> <p> The wordWrap property specifies whether long words should be broken to wrap around to the next line. </p> <div class="content"> GeeksforGeeksisacomputerscienceportal. </div> <button onclick="setWordWrap()"> Change wordWrap </button> <!-- Script to set wordWrap to initial --> <script> function setWordWrap() { elem = document.querySelector('.content'); elem.style.wordWrap = 'initial'; } </script> </body> </html> Output: Before clicking the button: After clicking the button: inherit: This is used to inherit the value from the parent of the element. Example-4: html <!DOCTYPE html> <html> <head> <title> DOM Style wordWrap Property </title> <style> #parent { word-wrap: break-word; } .content { border: 1px solid; height: 200px; width: 200px; word-wrap: normal; } </style> </head> <body> <h1 style="color: green"> GeeksforGeeks </h1> <b> DOM Style wordWrap Property </b> <p> The wordWrap property specifies whether long words should be broken to wrap around to the next line. </p> <div id="parent"> <div class="content"> GeeksforGeeksisacomputerscienceportal. </div> </div> <button onclick="setWordWrap()"> Change wordWrap </button> <!-- Script to set wordWrap to inherit --> <script> function setWordWrap() { elem = document.querySelector('.content'); elem.style.wordWrap = 'inherit'; } </script> </body> </html> Output: Before clicking the button: After clicking the button: Supported Browsers: The browser supported by DOM Style wordWrap Property are listed below: Google Chrome Firefox Internet Explorer Opera Safari Create Quiz Comment S sayantanm19 Follow 0 Improve S sayantanm19 Follow 0 Improve Article Tags : Web Technologies HTML HTML-DOM Explore HTML BasicsHTML Introduction4 min readHTML Editors4 min readHTML Basics7 min readStructure & ElementsHTML Elements4 min readHTML Attributes7 min readHTML Headings3 min readHTML Paragraphs3 min readHTML Text Formatting4 min readHTML Block and Inline Elements3 min readHTML Charsets4 min readListsHTML Lists3 min readHTML Ordered Lists5 min readHTML Unordered Lists4 min readHTML Description Lists3 min readVisuals & MediaHTML Colors11 min readHTML Links Hyperlinks2 min readHTML Images7 min readHTML Favicon4 min readHTML Video4 min readLayouts & DesignsHTML Tables9 min readHTML Iframes4 min readHTML Layout4 min readHTML File Paths3 min readProjects & Advanced TopicsHTML Forms5 min readHTML5 Semantics5 min readHTML URL Encoding4 min readHTML Responsive Web Design11 min readTop 10 Projects For Beginners To Practice HTML and CSS Skills8 min readTutorial ReferencesHTML Tags - A to Z List5 min readHTML Attributes Complete Reference8 min readHTML Global Attributes5 min readHTML5 Complete Reference8 min readHTML5 MathML Complete Reference3 min readHTML DOM Complete Reference15+ min readHTML DOM Audio/Video Complete Reference2 min readSVG Element Complete Reference5 min readSVG Attribute Complete Reference8 min readSVG Property Complete Reference7 min readHTML Canvas Complete Reference4 min read Like