{"id":11158,"date":"2024-01-30T21:35:32","date_gmt":"2024-01-30T16:35:32","guid":{"rendered":"https:\/\/codehim.com\/?p=11158"},"modified":"2024-02-03T13:13:11","modified_gmt":"2024-02-03T08:13:11","slug":"text-wrap-balance-css-example","status":"publish","type":"post","link":"https:\/\/codehim.com\/text-input\/text-wrap-balance-css-example\/","title":{"rendered":"Text-wrap Balance CSS Example"},"content":{"rendered":"<p>This CSS code example helps you to integrate <a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/CSS\/text-wrap\" target=\"_blank\" rel=\"noopener\">text-wrap: balance property<\/a> on your webpage. The <code>text-wrap: balance<\/code> property, applied to a specific paragraph class, dynamically balances text layout, offering a visually appealing design. The code incorporates Google Fonts for a modern aesthetic and employs media queries for responsiveness on smaller screens<\/p>\n<h2>How to Use Text-wrap Balance In CSS<\/h2>\n<p>1. First of all, ensure you include the following CDN links in the <code>&lt;head&gt;<\/code> section of your HTML file. This imports the &#8216;Oxygen Mono&#8217; font, adding a touch of modernity to your text.<\/p>\n<pre class=\"prettyprint linenums lang-html\">&lt;link rel=\"preconnect\" href=\"https:\/\/fonts.googleapis.com\"&gt;\r\n&lt;link rel=\"preconnect\" href=\"https:\/\/fonts.gstatic.com\" crossorigin&gt;\r\n&lt;link href=\"https:\/\/fonts.googleapis.com\/css2?family=Oxygen+Mono&amp;display=swap\" rel=\"stylesheet\"&gt;\r\n<\/pre>\n<p>2. The main content should be enclosed within a <code>&lt;main&gt;<\/code> tag. Each section of text that you want to style differently should be wrapped in appropriate tags (e.g., <code>&lt;h1&gt;<\/code> for headers and <code>&lt;p&gt;<\/code> for paragraphs).<\/p>\n<pre class=\"prettyprint linenums lang-html\">&lt;main&gt;\r\n  &lt;h1&gt;normal&lt;\/h1&gt;\r\n  &lt;p&gt;Why the Humble Spatula Is the Most Underrated Tool in Your Kitchen&lt;\/p&gt;\r\n  \r\n  &lt;h1&gt;text-wrap: balance&lt;\/h1&gt;\r\n  &lt;p class=\"bottom\"&gt;Why the Humble Spatula Is the Most Underrated Tool in Your Kitchen&lt;\/p&gt;\r\n&lt;\/main&gt;<\/pre>\n<p>3. Copy and paste the following CSS code into your stylesheet or within a <code>&lt;style&gt;<\/code> tag in the <code>&lt;head&gt;<\/code> section of your HTML. Moreover, this code helps create a visually appealing layout.<\/p>\n<pre class=\"prettyprint linenums lang-css\">body {\r\n  display: grid;\r\n  place-items: center;\r\n  min-height: 100vh;\r\n  margin: 0;\r\n  color: #fff;\r\n  background-image: linear-gradient(-20deg, #d6e6f4, #9cc4e4) !important;\r\n  font: 1.5rem\/1.333 'Oxygen Mono', monospace;\r\n  overflow-x: hidden;\r\n}\r\n\r\n@media (max-width: 500px) {\r\n  body {\r\n    font-size: 1.125rem;\r\n  }\r\n}\r\n\r\nmain {\r\n  position: relative;\r\n  margin: 15px 10px;\r\n}\r\n\r\nmain::after {\r\n  content: '';\r\n  display: block;\r\n  position: absolute;\r\n  top: 16px;\r\n  left: calc(28ch + 9px);\r\n  bottom: 0;\r\n  border-left: 2px dashed #fff6;\r\n}\r\n\r\n h1 {\r\n  position: relative;\r\n  z-index: 2;\r\n  width: min-content;\r\n  margin: 0 10px;\r\n  padding: 5px 10px;\r\n  border-radius: 4px;\r\n  background-color: #000;\r\n  font-weight: normal;\r\n  font-size: 0.667em;\r\n  white-space: nowrap;\r\n  transform: translateY(50%);\r\n}\r\n\r\np {\r\n  width: 28ch;\r\n  margin: 0 0 15px;\r\n  padding: 20px 10px 10px;\r\n  border-radius: 4px;\r\n  background-color: #0006;\r\n}\r\n\r\np.bottom {\r\n  text-wrap: balance;\r\n}<\/pre>\n<p>Feel free to tweak the styles according to your preferences. Moreover, adjust font sizes, colors, or spacing to match your website&#8217;s theme.<\/p>\n<p>That&#8217;s all! hopefully, you have successfully integrated the CSS Text-wrap Balance example into your website\/app project. If you have any questions or suggestions, feel free to comment below.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>This CSS code example helps you to integrate text-wrap: balance property on your webpage. The text-wrap: balance property, applied to&#8230;<\/p>\n","protected":false},"author":1,"featured_media":11186,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"footnotes":""},"categories":[97],"tags":[],"class_list":["post-11158","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-text-input"],"acf":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v26.8 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>Text-wrap Balance CSS Example &#8212; CodeHim<\/title>\n<meta name=\"description\" content=\"Here is a free code snippet to create a Text-wrap Balance CSS Example. You can view demo and download the source code.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/codehim.com\/text-input\/text-wrap-balance-css-example\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Text-wrap Balance CSS Example &#8212; CodeHim\" \/>\n<meta property=\"og:description\" content=\"Here is a free code snippet to create a Text-wrap Balance CSS Example. You can view demo and download the source code.\" \/>\n<meta property=\"og:url\" content=\"https:\/\/codehim.com\/text-input\/text-wrap-balance-css-example\/\" \/>\n<meta property=\"og:site_name\" content=\"CodeHim\" \/>\n<meta property=\"article:publisher\" content=\"https:\/\/www.facebook.com\/codehimofficial\" \/>\n<meta property=\"article:published_time\" content=\"2024-01-30T16:35:32+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2024-02-03T08:13:11+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/codehim.com\/wp-content\/uploads\/2024\/02\/Text-wrap-Balance-CSS-Example.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1280\" \/>\n\t<meta property=\"og:image:height\" content=\"960\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Asif Mughal\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@CodeHimOfficial\" \/>\n<meta name=\"twitter:site\" content=\"@CodeHimOfficial\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Asif Mughal\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/codehim.com\/text-input\/text-wrap-balance-css-example\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/codehim.com\/text-input\/text-wrap-balance-css-example\/\"},\"author\":{\"name\":\"Asif Mughal\",\"@id\":\"https:\/\/codehim.com\/#\/schema\/person\/cc48f1dbe072a89a62a98171b7db43ed\"},\"headline\":\"Text-wrap Balance CSS Example\",\"datePublished\":\"2024-01-30T16:35:32+00:00\",\"dateModified\":\"2024-02-03T08:13:11+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/codehim.com\/text-input\/text-wrap-balance-css-example\/\"},\"wordCount\":205,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/codehim.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/codehim.com\/text-input\/text-wrap-balance-css-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/codehim.com\/wp-content\/uploads\/2024\/02\/Text-wrap-Balance-CSS-Example.png\",\"articleSection\":[\"Text &amp; Input\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/codehim.com\/text-input\/text-wrap-balance-css-example\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/codehim.com\/text-input\/text-wrap-balance-css-example\/\",\"url\":\"https:\/\/codehim.com\/text-input\/text-wrap-balance-css-example\/\",\"name\":\"Text-wrap Balance CSS Example &#8212; CodeHim\",\"isPartOf\":{\"@id\":\"https:\/\/codehim.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/codehim.com\/text-input\/text-wrap-balance-css-example\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/codehim.com\/text-input\/text-wrap-balance-css-example\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/codehim.com\/wp-content\/uploads\/2024\/02\/Text-wrap-Balance-CSS-Example.png\",\"datePublished\":\"2024-01-30T16:35:32+00:00\",\"dateModified\":\"2024-02-03T08:13:11+00:00\",\"description\":\"Here is a free code snippet to create a Text-wrap Balance CSS Example. You can view demo and download the source code.\",\"breadcrumb\":{\"@id\":\"https:\/\/codehim.com\/text-input\/text-wrap-balance-css-example\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/codehim.com\/text-input\/text-wrap-balance-css-example\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/codehim.com\/text-input\/text-wrap-balance-css-example\/#primaryimage\",\"url\":\"https:\/\/codehim.com\/wp-content\/uploads\/2024\/02\/Text-wrap-Balance-CSS-Example.png\",\"contentUrl\":\"https:\/\/codehim.com\/wp-content\/uploads\/2024\/02\/Text-wrap-Balance-CSS-Example.png\",\"width\":1280,\"height\":960,\"caption\":\"Text-wrap Balance CSS Example\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/codehim.com\/text-input\/text-wrap-balance-css-example\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/codehim.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Text &amp; Input\",\"item\":\"https:\/\/codehim.com\/category\/text-input\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"Text-wrap Balance CSS Example\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/codehim.com\/#website\",\"url\":\"https:\/\/codehim.com\/\",\"name\":\"CodeHim\",\"description\":\"Web Design Code Snippets\",\"publisher\":{\"@id\":\"https:\/\/codehim.com\/#organization\"},\"alternateName\":\"Web Design Codes\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/codehim.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/codehim.com\/#organization\",\"name\":\"CodeHim - Web Design Code & Scripts\",\"url\":\"https:\/\/codehim.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/codehim.com\/#\/schema\/logo\/image\/\",\"url\":\"http:\/\/codehim.com\/wp-content\/uploads\/2023\/06\/Codehim-short-logo.jpg\",\"contentUrl\":\"http:\/\/codehim.com\/wp-content\/uploads\/2023\/06\/Codehim-short-logo.jpg\",\"width\":280,\"height\":280,\"caption\":\"CodeHim - Web Design Code & Scripts\"},\"image\":{\"@id\":\"https:\/\/codehim.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/www.facebook.com\/codehimofficial\",\"https:\/\/x.com\/CodeHimOfficial\",\"https:\/\/www.instagram.com\/codehim\/\",\"https:\/\/www.linkedin.com\/company\/codehim\",\"https:\/\/co.pinterest.com\/codehim\/\",\"https:\/\/www.youtube.com\/@codehim\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/codehim.com\/#\/schema\/person\/cc48f1dbe072a89a62a98171b7db43ed\",\"name\":\"Asif Mughal\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/codehim.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/b25bfcd7d4e341c2c6f785a88d8ad2a4?s=96&d=mm&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/b25bfcd7d4e341c2c6f785a88d8ad2a4?s=96&d=mm&r=g\",\"caption\":\"Asif Mughal\"},\"description\":\"I code and create web elements for amazing people around the world. I like work with new people. New people new Experiences. I truly enjoy what I'm doing, which makes me more passionate about web development and coding. I am always ready to do challenging tasks whether it is about creating a custom CMS from scratch or customizing an existing system.\",\"sameAs\":[\"https:\/\/codehim.com\"],\"url\":\"https:\/\/codehim.com\/author\/asif-mughal\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Text-wrap Balance CSS Example &#8212; CodeHim","description":"Here is a free code snippet to create a Text-wrap Balance CSS Example. You can view demo and download the source code.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/codehim.com\/text-input\/text-wrap-balance-css-example\/","og_locale":"en_US","og_type":"article","og_title":"Text-wrap Balance CSS Example &#8212; CodeHim","og_description":"Here is a free code snippet to create a Text-wrap Balance CSS Example. You can view demo and download the source code.","og_url":"https:\/\/codehim.com\/text-input\/text-wrap-balance-css-example\/","og_site_name":"CodeHim","article_publisher":"https:\/\/www.facebook.com\/codehimofficial","article_published_time":"2024-01-30T16:35:32+00:00","article_modified_time":"2024-02-03T08:13:11+00:00","og_image":[{"width":1280,"height":960,"url":"https:\/\/codehim.com\/wp-content\/uploads\/2024\/02\/Text-wrap-Balance-CSS-Example.png","type":"image\/png"}],"author":"Asif Mughal","twitter_card":"summary_large_image","twitter_creator":"@CodeHimOfficial","twitter_site":"@CodeHimOfficial","twitter_misc":{"Written by":"Asif Mughal","Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/codehim.com\/text-input\/text-wrap-balance-css-example\/#article","isPartOf":{"@id":"https:\/\/codehim.com\/text-input\/text-wrap-balance-css-example\/"},"author":{"name":"Asif Mughal","@id":"https:\/\/codehim.com\/#\/schema\/person\/cc48f1dbe072a89a62a98171b7db43ed"},"headline":"Text-wrap Balance CSS Example","datePublished":"2024-01-30T16:35:32+00:00","dateModified":"2024-02-03T08:13:11+00:00","mainEntityOfPage":{"@id":"https:\/\/codehim.com\/text-input\/text-wrap-balance-css-example\/"},"wordCount":205,"commentCount":0,"publisher":{"@id":"https:\/\/codehim.com\/#organization"},"image":{"@id":"https:\/\/codehim.com\/text-input\/text-wrap-balance-css-example\/#primaryimage"},"thumbnailUrl":"https:\/\/codehim.com\/wp-content\/uploads\/2024\/02\/Text-wrap-Balance-CSS-Example.png","articleSection":["Text &amp; Input"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/codehim.com\/text-input\/text-wrap-balance-css-example\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/codehim.com\/text-input\/text-wrap-balance-css-example\/","url":"https:\/\/codehim.com\/text-input\/text-wrap-balance-css-example\/","name":"Text-wrap Balance CSS Example &#8212; CodeHim","isPartOf":{"@id":"https:\/\/codehim.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/codehim.com\/text-input\/text-wrap-balance-css-example\/#primaryimage"},"image":{"@id":"https:\/\/codehim.com\/text-input\/text-wrap-balance-css-example\/#primaryimage"},"thumbnailUrl":"https:\/\/codehim.com\/wp-content\/uploads\/2024\/02\/Text-wrap-Balance-CSS-Example.png","datePublished":"2024-01-30T16:35:32+00:00","dateModified":"2024-02-03T08:13:11+00:00","description":"Here is a free code snippet to create a Text-wrap Balance CSS Example. You can view demo and download the source code.","breadcrumb":{"@id":"https:\/\/codehim.com\/text-input\/text-wrap-balance-css-example\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/codehim.com\/text-input\/text-wrap-balance-css-example\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/codehim.com\/text-input\/text-wrap-balance-css-example\/#primaryimage","url":"https:\/\/codehim.com\/wp-content\/uploads\/2024\/02\/Text-wrap-Balance-CSS-Example.png","contentUrl":"https:\/\/codehim.com\/wp-content\/uploads\/2024\/02\/Text-wrap-Balance-CSS-Example.png","width":1280,"height":960,"caption":"Text-wrap Balance CSS Example"},{"@type":"BreadcrumbList","@id":"https:\/\/codehim.com\/text-input\/text-wrap-balance-css-example\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/codehim.com\/"},{"@type":"ListItem","position":2,"name":"Text &amp; Input","item":"https:\/\/codehim.com\/category\/text-input\/"},{"@type":"ListItem","position":3,"name":"Text-wrap Balance CSS Example"}]},{"@type":"WebSite","@id":"https:\/\/codehim.com\/#website","url":"https:\/\/codehim.com\/","name":"CodeHim","description":"Web Design Code Snippets","publisher":{"@id":"https:\/\/codehim.com\/#organization"},"alternateName":"Web Design Codes","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/codehim.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/codehim.com\/#organization","name":"CodeHim - Web Design Code & Scripts","url":"https:\/\/codehim.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/codehim.com\/#\/schema\/logo\/image\/","url":"http:\/\/codehim.com\/wp-content\/uploads\/2023\/06\/Codehim-short-logo.jpg","contentUrl":"http:\/\/codehim.com\/wp-content\/uploads\/2023\/06\/Codehim-short-logo.jpg","width":280,"height":280,"caption":"CodeHim - Web Design Code & Scripts"},"image":{"@id":"https:\/\/codehim.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/www.facebook.com\/codehimofficial","https:\/\/x.com\/CodeHimOfficial","https:\/\/www.instagram.com\/codehim\/","https:\/\/www.linkedin.com\/company\/codehim","https:\/\/co.pinterest.com\/codehim\/","https:\/\/www.youtube.com\/@codehim"]},{"@type":"Person","@id":"https:\/\/codehim.com\/#\/schema\/person\/cc48f1dbe072a89a62a98171b7db43ed","name":"Asif Mughal","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/codehim.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/b25bfcd7d4e341c2c6f785a88d8ad2a4?s=96&d=mm&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/b25bfcd7d4e341c2c6f785a88d8ad2a4?s=96&d=mm&r=g","caption":"Asif Mughal"},"description":"I code and create web elements for amazing people around the world. I like work with new people. New people new Experiences. I truly enjoy what I'm doing, which makes me more passionate about web development and coding. I am always ready to do challenging tasks whether it is about creating a custom CMS from scratch or customizing an existing system.","sameAs":["https:\/\/codehim.com"],"url":"https:\/\/codehim.com\/author\/asif-mughal\/"}]}},"views":585,"_links":{"self":[{"href":"https:\/\/codehim.com\/wp-json\/wp\/v2\/posts\/11158","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/codehim.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/codehim.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/codehim.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/codehim.com\/wp-json\/wp\/v2\/comments?post=11158"}],"version-history":[{"count":2,"href":"https:\/\/codehim.com\/wp-json\/wp\/v2\/posts\/11158\/revisions"}],"predecessor-version":[{"id":11254,"href":"https:\/\/codehim.com\/wp-json\/wp\/v2\/posts\/11158\/revisions\/11254"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/codehim.com\/wp-json\/wp\/v2\/media\/11186"}],"wp:attachment":[{"href":"https:\/\/codehim.com\/wp-json\/wp\/v2\/media?parent=11158"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/codehim.com\/wp-json\/wp\/v2\/categories?post=11158"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/codehim.com\/wp-json\/wp\/v2\/tags?post=11158"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}