{"id":3033,"date":"2017-01-22T18:15:47","date_gmt":"2017-01-23T00:15:47","guid":{"rendered":"http:\/\/cssnewbie.com\/?p=2071"},"modified":"2017-01-22T18:15:47","modified_gmt":"2017-01-23T00:15:47","slug":"csss-word-wrap-property","status":"publish","type":"post","link":"https:\/\/cssdeck.com\/blog\/csss-word-wrap-property\/","title":{"rendered":"CSS&#8217;s Word-Wrap Property"},"content":{"rendered":"<p class=\"p1\"><span class=\"s1\">CSS\u2019s word-wrap property can be used to break a really long word so that it continues on the next line rather than having the word extend beyond its potential boundaries so that it all stays on one line.<\/span><\/p>\n<p class=\"p1\"><span class=\"s1\">Let\u2019s say you had a really long word that was taking up way too much space, like in the image below:<\/span><\/p>\n<p class=\"p1\"><img decoding=\"async\" loading=\"lazy\" class=\"wp-image-2072 aligncenter\" src=\"http:\/\/cssnewbie.com\/wp-content\/uploads\/2017\/01\/Screen-Shot-2017-01-23-at-11.22.58-AM-1024x166.png\" alt=\"Screen Shot 2017-01-23 at 11.22.58 AM\" width=\"642\" height=\"104\" \/><\/p>\n<p class=\"p1\">\n<p class=\"p1\">\n<p class=\"p1\"><span class=\"s1\">If you wanted the word to stay within its boundaries (the container that the paragraph is in is only supposed to be 250px wide), you can use the word-wrap property to tell the code that it\u2019s okay to break up the word to keep it contained to the confines of its parent div. Here\u2019s what your CSS would need to look like:<\/span><\/p>\n<p class=\"p1\">p{<br \/>\nword-wrap: break-word;<br \/>\n}<\/p>\n<p class=\"p1\"><span class=\"s1\">Now your text should look like this:<br \/>\n<\/span><\/p>\n<p class=\"p1\"><img decoding=\"async\" loading=\"lazy\" class=\" wp-image-2073 aligncenter\" src=\"http:\/\/cssnewbie.com\/wp-content\/uploads\/2017\/01\/Screen-Shot-2017-01-23-at-11.23.49-AM-1024x298.png\" alt=\"Screen Shot 2017-01-23 at 11.23.49 AM\" width=\"457\" height=\"133\" \/><\/p>\n<p class=\"p1\"><span class=\"s1\">You\u2019ll see that the word is now cut off almost in the middle. This isn\u2019t the default in CSS because it doesn\u2019t always look great, but there are definitely times when you\u2019ll need to use word-wrap property to make sure the text doesn\u2019t overflow and maintain the integrity of your divs.<\/span><\/p>\n<p class=\"p1\">\n<div class=\"wp-socializer wpsr-share-icons \" data-lg-action=\"show\" data-sm-action=\"show\" data-sm-width=\"768\" ><h3>Share and Enjoy !<\/h3><div class=\"wpsr-si-inner\"><div class=\"wpsr-counter wpsrc-sz-32px\" style=\"color:#000\"><span class=\"scount\"><span data-wpsrs=\"\" data-wpsrs-svcs=\"facebook,twitter,linkedin,pinterest,print,pdf\">0<\/span><\/span><small class=\"stext\">Shares<\/small><\/div><div class=\"socializer sr-popup sr-32px sr-circle sr-opacity sr-pad sr-count-1 sr-count-1\"><span class=\"sr-facebook\"><a rel=\"nofollow\" href=\"https:\/\/www.facebook.com\/share.php?u=\" target=\"_blank\"  title=\"Share this on Facebook\"  style=\"color: #ffffff\" ><i class=\"fab fa-facebook-f\"><\/i><span class=\"ctext\"><span data-wpsrs=\"\" data-wpsrs-svcs=\"facebook\">0<\/span><\/span><\/a><\/span>\n<span class=\"sr-twitter\"><a rel=\"nofollow\" href=\"https:\/\/twitter.com\/intent\/tweet?text=%20-%20%20\" target=\"_blank\"  title=\"Tweet this !\"  style=\"color: #ffffff\" ><i class=\"fab fa-twitter\"><\/i><\/a><\/span>\n<span class=\"sr-linkedin\"><a rel=\"nofollow\" href=\"https:\/\/www.linkedin.com\/sharing\/share-offsite\/?url=\" target=\"_blank\"  title=\"Add this to LinkedIn\"  style=\"color: #ffffff\" ><i class=\"fab fa-linkedin-in\"><\/i><\/a><\/span>\n<span class=\"sr-pinterest\"><a rel=\"nofollow\" href=\"https:\/\/www.pinterest.com\/pin\/create\/button\/?url=&amp;media=&amp;description=\" target=\"_blank\"  title=\"Submit this to Pinterest\"  style=\"color: #ffffff\" data-pin-custom=\"true\"><i class=\"fab fa-pinterest\"><\/i><span class=\"ctext\"><span data-wpsrs=\"\" data-wpsrs-svcs=\"pinterest\">0<\/span><\/span><\/a><\/span>\n<span class=\"sr-print\"><a rel=\"nofollow\" href=\"https:\/\/www.printfriendly.com\/print?url=\" target=\"_blank\"  title=\"Print this article \"  style=\"color: #ffffff\" ><i class=\"fa fa-print\"><\/i><\/a><\/span>\n<span class=\"sr-pdf\"><a rel=\"nofollow\" href=\"https:\/\/www.printfriendly.com\/print?url=\" target=\"_blank\"  title=\"Convert to PDF\"  style=\"color: #ffffff\" ><i class=\"fa fa-file-pdf\"><\/i><\/a><\/span><\/div><\/div><\/div>","protected":false},"excerpt":{"rendered":"<p class=\"p1\">CSS\u2019s word-wrap property can be used to break a really long word so that it continues on the next line rather than having the word extend beyond its potential boundaries so that it all stays on one line.<\/p>\n<p class=\"p1\">Let\u2019s [&#8230;]<\/p>\n<p><a class=\"more-link article\" href=\"https:\/\/cssdeck.com\/blog\/csss-word-wrap-property\/\" title=\"Click to read 'CSS&#8217;s Word-Wrap Property'\">Read Article<\/a><\/p>\n","protected":false},"author":18,"featured_media":2799,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[174],"tags":[],"_links":{"self":[{"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/posts\/3033"}],"collection":[{"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/users\/18"}],"replies":[{"embeddable":true,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/comments?post=3033"}],"version-history":[{"count":0,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/posts\/3033\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/media\/2799"}],"wp:attachment":[{"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/media?parent=3033"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/categories?post=3033"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/cssdeck.com\/blog\/wp-json\/wp\/v2\/tags?post=3033"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}