{"id":14650,"date":"2019-05-05T12:38:15","date_gmt":"2019-05-05T10:38:15","guid":{"rendered":"https:\/\/marabelia.com\/?p=14650"},"modified":"2025-06-19T12:55:31","modified_gmt":"2025-06-19T10:55:31","slug":"css-styled-text-boxes","status":"publish","type":"post","link":"https:\/\/marabelia.com\/en\/css-styled-text-boxes\/","title":{"rendered":"CSS styled text boxes"},"content":{"rendered":"<div class=\"wpb-content-wrapper\">[vc_row][vc_column][vc_column_text]\n<h1 style=\"text-align: justify;\">Boxes with Colored Borders and Text.<\/h1>\n<h2 style=\"text-align: justify;\">A Simple CSS Tutorial<\/h2>\n<p>&nbsp;<\/p>\n<p style=\"text-align: justify;\">I\u2019m going to explain how to make an asymmetric bordered text box like this using CSS:<\/p>\n<p class=\"box\">Hello! I\u2019m a very stylish box<\/p>\n<p style=\"text-align: justify;\">If you also want the inner text to include a link with a different style, you can check my blog post:<br \/>\n<a href=\"https:\/\/marabelia.com\/en\/how-to-create-a-new-link-style-in-wordpress\/\" target=\"_blank\" rel=\"noopener noreferrer\">How to create a new style for links in WordPress<\/a><\/p>\n<p style=\"text-align: justify;\">To start, in my CSS stylesheet <em>style.css<\/em>, I\u2019ll create a new style called &#8220;box&#8221; and assign the basic properties:<\/p>\n<pre>.box { \r\nfont-family: sans-serif; \r\nfont-size: 18px; \r\nfont-weight: 400; \r\ncolor: #ffffff; \r\nbackground:#ee0467 }<\/pre>\n<p style=\"text-align: justify;\">I\u2019ve set the font type, size, weight, and color, as well as the background color of the box.<\/p>\n<p style=\"text-align: justify;\">Now, in my HTML editor (in WordPress: the <em>text editor<\/em> of the page), I\u2019m going to test the style I just created by using the conventional <em>class<\/em> attribute:<\/p>\n<pre>&lt;div class=\"box\"&gt;Hello! I\u2019m a very stylish box&lt;\/div&gt;<\/pre>\n<p style=\"text-align: justify;\">Or the <em>class<\/em> attribute for paragraphs:<\/p>\n<pre>&lt;p class=\"box\"&gt;Hello! I\u2019m a very stylish box&lt;\/p&gt;<\/pre>\n<p>And the result will be this:<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" class=\"wp-image-7652 size-full alignnone\" src=\"https:\/\/marabelia.com\/wp-content\/uploads\/2015\/07\/caja-texto-css.png\" alt=\"\" width=\"844\" height=\"69\" srcset=\"https:\/\/marabelia.com\/wp-content\/uploads\/2015\/07\/caja-texto-css.png 844w, https:\/\/marabelia.com\/wp-content\/uploads\/2015\/07\/caja-texto-css-800x65.png 800w, https:\/\/marabelia.com\/wp-content\/uploads\/2015\/07\/caja-texto-css-300x25.png 300w, https:\/\/marabelia.com\/wp-content\/uploads\/2015\/07\/caja-texto-css-768x63.png 768w\" sizes=\"auto, (max-width: 844px) 100vw, 844px\" \/><\/p>\n<p>Let\u2019s continue adding properties to our text box. Remember that <a href=\"http:\/\/www.mclibre.org\/consultar\/htmlcss\/css\/css_propiedades.html\" target=\"_blank\" rel=\"noopener noreferrer\">on this website<\/a> you can find a good list of CSS properties.<\/p>\n<p style=\"text-align: justify;\">To prevent the text from being &#8220;stuck&#8221; to the box edges, we add some breathing space using padding. You can give a general padding or break it down for better control. Here, I\u2019ll set padding of 20px on all sides:<\/p>\n<pre>padding: 20px;<\/pre>\n<p>But if you want to break it down it would be like this:<\/p>\n<pre>padding-top: 20px;\r\npadding-right: 20px;\r\npadding-bottom: 20px;\r\npadding-left: 20px;<\/pre>\n<p style=\"text-align: justify;\">Or like this:<\/p>\n<pre>padding: 20px 20px 20px 20px;<\/pre>\n<p style=\"text-align: justify;\">Then we give margin to our box using the <em>margin<\/em> property:<\/p>\n<pre>margin: 0 0 25px;<\/pre>\n<p style=\"text-align: justify;\">Finally, we define the <a href=\"http:\/\/librosweb.es\/referencia\/css\/overflow.html\" target=\"_blank\" rel=\"noopener noreferrer\">behavior of box elements<\/a> when they don\u2019t fit their container using the <em>overflow<\/em> property:<\/p>\n<pre>overflow: hidden;<\/pre>\n<p style=\"text-align: justify;\">In this case, anything outside the box will be hidden, but we can fix it by using the <em>div<\/em> tag for <em>paragraphs<\/em>. This way, nothing will overflow because the box will contain the entire paragraph.<\/p>\n<p style=\"text-align: justify;\">Our code so far looks like this:<\/p>\n<pre>.box {\r\nfont-family: sans-serif;\r\nfont-size: 18px;\r\nfont-weight: 400;\r\ncolor: #ffffff;\r\nbackground: #889ccf;\r\nmargin: 0 0 25px;\r\noverflow: hidden;\r\npadding: 20px;\r\n}<\/pre>\n<p style=\"text-align: justify;\">Our resulting box so far looks like this:<\/p>\n<p style=\"text-align: justify;\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone wp-image-7653 size-full\" src=\"https:\/\/marabelia.com\/wp-content\/uploads\/2015\/07\/caja-estilo-css.png\" alt=\"\" width=\"851\" height=\"126\" srcset=\"https:\/\/marabelia.com\/wp-content\/uploads\/2015\/07\/caja-estilo-css.png 851w, https:\/\/marabelia.com\/wp-content\/uploads\/2015\/07\/caja-estilo-css-800x118.png 800w, https:\/\/marabelia.com\/wp-content\/uploads\/2015\/07\/caja-estilo-css-300x44.png 300w, https:\/\/marabelia.com\/wp-content\/uploads\/2015\/07\/caja-estilo-css-768x114.png 768w\" sizes=\"auto, (max-width: 851px) 100vw, 851px\" \/><br \/>\nNow I\u2019m going to add the <em>border-radius<\/em> property so the box has rounded corners. To make it easy, I recommend using the tool <a href=\"http:\/\/www.cssmatic.com\/es\/border-radius\" target=\"_blank\" rel=\"noopener noreferrer\">CSSmatic<\/a> which automatically generates border styles while previewing them. It also lets us set border thickness, color, and background.<\/p>\n<p style=\"text-align: justify;\">I decided to give a 35px radius to the top-left and top-right corners to create asymmetric boxes. I also added a 2px border in a darker tone:<\/p>\n<pre>border-radius: 35px 0px 35px 0px;\r\n-moz-border-radius: 35px 0px 35px 0px;\r\n-webkit-border-radius: 35px 0px 35px 0px;\r\nborder: 2px solid #5878ca;\r\n<\/pre>\n<p style=\"text-align: justify;\">My box is almost ready:<\/p>\n<p style=\"text-align: justify;\"><img loading=\"lazy\" decoding=\"async\" class=\"alignnone size-full wp-image-7654\" src=\"https:\/\/marabelia.com\/wp-content\/uploads\/2015\/07\/caja-css-borde-asimetrico.png\" alt=\"\" width=\"844\" height=\"122\" srcset=\"https:\/\/marabelia.com\/wp-content\/uploads\/2015\/07\/caja-css-borde-asimetrico.png 844w, https:\/\/marabelia.com\/wp-content\/uploads\/2015\/07\/caja-css-borde-asimetrico-800x116.png 800w, https:\/\/marabelia.com\/wp-content\/uploads\/2015\/07\/caja-css-borde-asimetrico-300x43.png 300w, https:\/\/marabelia.com\/wp-content\/uploads\/2015\/07\/caja-css-borde-asimetrico-768x111.png 768w\" sizes=\"auto, (max-width: 844px) 100vw, 844px\" \/><\/p>\n<p style=\"text-align: justify;\">Looking at the result, I\u2019m going to change some properties and add some more to adjust the design.<\/p>\n<p style=\"text-align: justify;\">I\u2019ll make the text inside the box centered by default using <em>text-align<\/em> and change the <em>font-family<\/em> to a geometric sans-serif font, <em>Century Gothic<\/em> :<\/p>\n<pre>text-align: center;\r\nfont-family: Century Gothic,CenturyGothic,AppleGothic,sans-serif;\r\n<\/pre>\n<p style=\"text-align: justify;\">With these last changes, I have the box I was looking for. In my WordPress HTML editor, I call my box using the <em>div class<\/em> tag:<\/p>\n<pre>&lt;div class=\"box\"&gt;Hello! I\u2019m a very stylish box&lt;\/div&gt;\r\n<\/pre>\n<p style=\"text-align: justify;\">Now I can see the final result:<\/p>\n<p class=\"box\">Hello! I\u2019m a very stylish box<\/p>\n<pre>\/*----------- BOX ----------- *\/\r\n.box { \r\nfont-family: Century Gothic,CenturyGothic,AppleGothic,sans-serif; \r\ncolor: #ffffff; \r\nfont-size: 18px; \r\nfont-weight: 400; \r\ntext-align: center; \r\nbackground: #889ccf; \r\nmargin: 0 0 25px; \r\noverflow: hidden; \r\npadding: 20px; \r\nborder-radius: 35px 0px 35px 0px; \r\n-moz-border-radius: 35px 0px 35px 0px; \r\n-webkit-border-radius: 35px 0px 35px 0px; \r\nborder: 2px solid #5878ca;\r\n}<\/pre>\n<pre><\/pre>\n<p style=\"text-align: justify;\">\ud83d\ude09 Yeah!<\/p>\n<p><em><strong>If you liked the content, please comment, share, or see how we make <a href=\"https:\/\/marabelia.com\/en\/web-design-in-valencia\/\">our web pages<\/a>.<\/strong><\/em>[\/vc_column_text][\/vc_column][\/vc_row]\n<\/div>","protected":false},"excerpt":{"rendered":"[vc_row][vc_column][vc_column_text] Boxes with Colored Borders and Text. A Simple CSS Tutorial &nbsp; I\u2019m going to explain how to make an asymmetric bordered text box like this using CSS: Hello! I\u2019m a very stylish box If you also want the inner text to include a link with a different style, you can check my blog post: [&#8230;]\n","protected":false},"author":1,"featured_media":13361,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1,98],"tags":[],"class_list":["post-14650","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-sin-categoria","category-wordpress-2"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>CSS styled text boxes &#8226; Marabelia | Agencia Digital en Valencia<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/marabelia.com\/en\/css-styled-text-boxes\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"CSS styled text boxes &#8226; Marabelia | Agencia Digital en Valencia\" \/>\n<meta property=\"og:description\" content=\"[vc_row][vc_column][vc_column_text] Boxes with Colored Borders and Text. A Simple CSS Tutorial &nbsp; I\u2019m going to explain how to make an asymmetric bordered text box like this using CSS: Hello! I\u2019m a very stylish box If you also want the inner text to include a link with a different style, you can check my blog post: [...]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/marabelia.com\/en\/css-styled-text-boxes\/\" \/>\n<meta property=\"og:site_name\" content=\"Marabelia | Agencia Digital en Valencia\" \/>\n<meta property=\"article:published_time\" content=\"2019-05-05T10:38:15+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-06-19T10:55:31+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/marabelia.com\/wp-content\/uploads\/2015\/07\/caja.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"829\" \/>\n\t<meta property=\"og:image:height\" content=\"419\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"admin-mbl\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin-mbl\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"CSS styled text boxes &#8226; Marabelia | Agencia Digital en Valencia","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:\/\/marabelia.com\/en\/css-styled-text-boxes\/","og_locale":"en_US","og_type":"article","og_title":"CSS styled text boxes &#8226; Marabelia | Agencia Digital en Valencia","og_description":"[vc_row][vc_column][vc_column_text] Boxes with Colored Borders and Text. A Simple CSS Tutorial &nbsp; I\u2019m going to explain how to make an asymmetric bordered text box like this using CSS: Hello! I\u2019m a very stylish box If you also want the inner text to include a link with a different style, you can check my blog post: [...]","og_url":"https:\/\/marabelia.com\/en\/css-styled-text-boxes\/","og_site_name":"Marabelia | Agencia Digital en Valencia","article_published_time":"2019-05-05T10:38:15+00:00","article_modified_time":"2025-06-19T10:55:31+00:00","og_image":[{"width":829,"height":419,"url":"https:\/\/marabelia.com\/wp-content\/uploads\/2015\/07\/caja.jpg","type":"image\/jpeg"}],"author":"admin-mbl","twitter_card":"summary_large_image","twitter_misc":{"Written by":"admin-mbl","Est. reading time":"3 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[]}},"_links":{"self":[{"href":"https:\/\/marabelia.com\/en\/wp-json\/wp\/v2\/posts\/14650","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/marabelia.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/marabelia.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/marabelia.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/marabelia.com\/en\/wp-json\/wp\/v2\/comments?post=14650"}],"version-history":[{"count":3,"href":"https:\/\/marabelia.com\/en\/wp-json\/wp\/v2\/posts\/14650\/revisions"}],"predecessor-version":[{"id":14885,"href":"https:\/\/marabelia.com\/en\/wp-json\/wp\/v2\/posts\/14650\/revisions\/14885"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/marabelia.com\/en\/wp-json\/wp\/v2\/media\/13361"}],"wp:attachment":[{"href":"https:\/\/marabelia.com\/en\/wp-json\/wp\/v2\/media?parent=14650"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/marabelia.com\/en\/wp-json\/wp\/v2\/categories?post=14650"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/marabelia.com\/en\/wp-json\/wp\/v2\/tags?post=14650"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}