{"id":4995,"date":"2020-06-23T12:44:00","date_gmt":"2020-06-23T12:44:00","guid":{"rendered":"https:\/\/azoora.com\/blog\/?p=4995"},"modified":"2020-08-19T12:58:01","modified_gmt":"2020-08-19T12:58:01","slug":"how-to-easily-create-a-responsive-vertical-rhythm-with-css","status":"publish","type":"post","link":"https:\/\/azoora.com\/blog\/code\/how-to-easily-create-a-responsive-vertical-rhythm-with-css\/","title":{"rendered":"How to Easily Create a Responsive Vertical Rhythm with CSS"},"content":{"rendered":"\n<p>Maintaining\u00a0grid systems\u00a0across a website can be a challenge. Implementing a CSS grid\u00a0has become standard practice, whereas implementing horizontal grids \u2013 aka vertical rhythm \u2013 can be too. However, there is added complexity thanks to responsive design and responsive typography. Though, it\u2019s actually quite easy to create a responsive vertical rhythm that is flexible to responsive design and responsive\u00a0typography.<\/p>\n\n\n\n<p><strong>Responsive vertical rhythm<\/strong>\u00a0allows the design to be consistent and visually appealing no matter the font or screen sizes used. Additionally, both horizontal and vertical grids are a staple asset of any design system, which allows both designers and developers to work more\u00a0efficiently.<\/p>\n\n\n\n<h2>What makes responsive vertical rhythm an important implementation?<\/h2>\n\n\n\n<p>For the best results (and the best use of any vertical rhythm), there has to be a consistent pattern. From the visual design perspective, vertical rhythm is there&nbsp;<a href=\"https:\/\/www.amazeelabs.com\/en\/journal\/designer-toolbox-vertical-rhythm\" target=\"_blank\" rel=\"noreferrer noopener\">to balance out the different content<\/a>, typography, and design elements. The more consistent the pattern, the better the design can lead the viewer\u2019s eye around the content without interruptions. A consistent and responsive vertical rhythm pattern makes a design more appealing. Utilizing responsive typography improves user experiences and can improve accessibility and usability&nbsp;too.<\/p>\n\n\n\n<p>From the development perspective, it makes&nbsp;<a href=\"https:\/\/zellwk.com\/blog\/why-vertical-rhythms\/\" target=\"_blank\" rel=\"noreferrer noopener\">coding the website easier<\/a>&nbsp;because you\u2019re no longer crunching numbers or guessing what the different spacings should be. Instead, you can now reuse the patterns with ease thanks to the various reference points already predefined within the responsive vertical&nbsp;rhythm.<\/p>\n\n\n\n<p>Coding a vertical rhythm isn\u2019t too tricky if you\u2019ve never done it. The process can be broken down into several steps \u2013 5 steps exactly, as outlined in this&nbsp;tutorial.<\/p>\n\n\n\n<ul><li>Creating Interactive, Highly Optimized AMP Emails<\/li><li>Create a Beautiful and Responsive HTML Email Template with Postcards<\/li><li>Create a Product Page with Interactive Colors in HTML, CSS3 &amp; jQuery<\/li><li>Create a Minimalist Website Design using Slides Framework<\/li><\/ul>\n\n\n\n<h2>Vertical rhythm&nbsp;basics<\/h2>\n\n\n\n<p>Most vertical rhythms are based on a line-height, usually aligned to the text\u2019s baseline. Although typography is a core component of vertical rhythm, it\u2019s simply where the spacing measurements are taken from. It\u2019s also used for all the other design elements such as images, input forms, and so\u00a0on.<\/p>\n\n\n\n<p>Which CSS properties do vertical rhythms&nbsp;use?<\/p>\n\n\n\n<ul><li>Line-height<\/li><li>Top and bottom offset<\/li><li>Height, min-height, max-height<\/li><li>Padding-top, padding-bottom, margin-top, margin-bottom.<\/li><\/ul>\n\n\n\n<h2>What makes a vertical rhythm&nbsp;responsive?<\/h2>\n\n\n\n<p>As you will see shortly, creating a responsive vertical rhythm depends on two things. You identify the different font-sizes, line heights and spacings dependant on specific screen sizes. Basically, you will be recreating the various vertical rhythm patterns in different media queries. The overall process is the same for each new screen&nbsp;size.<\/p>\n\n\n\n<h3>1. Setting up the basic CSS&nbsp;pattern<\/h3>\n\n\n\n<p>The very first thing you\u2019ll want to do is define the default font size on either the HTML tag or the body tag. The default font-size and line-height should be the same as the body&nbsp;paragraph\u2019s.<\/p>\n\n\n\n<p>If you\u2019re dealing with responsive typography, which font size do you want to choose as your default base? My recommendation is to create all responsive vertical rhythm through progressive enhancement. And, that\u2019s what we\u2019ll do in this tutorial. So, start with typography from the smallest\u00a0screens.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-attachment-id=\"4996\" data-permalink=\"https:\/\/azoora.com\/blog\/code\/how-to-easily-create-a-responsive-vertical-rhythm-with-css\/attachment\/responsive-vertical-rhythm-01\/#main\" data-orig-file=\"https:\/\/azoora.com\/blog\/wp-content\/uploads\/2020\/08\/Responsive-Vertical-Rhythm-01.jpg\" data-orig-size=\"1280,600\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Responsive-Vertical-Rhythm-01\" data-image-description=\"\" data-medium-file=\"https:\/\/azoora.com\/blog\/wp-content\/uploads\/2020\/08\/Responsive-Vertical-Rhythm-01-300x141.jpg\" data-large-file=\"https:\/\/azoora.com\/blog\/wp-content\/uploads\/2020\/08\/Responsive-Vertical-Rhythm-01-1024x480.jpg\" loading=\"lazy\" width=\"1024\" height=\"480\" src=\"https:\/\/azoora.com\/blog\/wp-content\/uploads\/2020\/08\/Responsive-Vertical-Rhythm-01-1024x480.jpg\" alt=\"\" class=\"wp-image-4996\" srcset=\"https:\/\/azoora.com\/blog\/wp-content\/uploads\/2020\/08\/Responsive-Vertical-Rhythm-01-1024x480.jpg 1024w, https:\/\/azoora.com\/blog\/wp-content\/uploads\/2020\/08\/Responsive-Vertical-Rhythm-01-300x141.jpg 300w, https:\/\/azoora.com\/blog\/wp-content\/uploads\/2020\/08\/Responsive-Vertical-Rhythm-01-768x360.jpg 768w, https:\/\/azoora.com\/blog\/wp-content\/uploads\/2020\/08\/Responsive-Vertical-Rhythm-01.jpg 1280w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"\"><tbody><tr><td><code>body {<\/code><code>\/* Set default font size for mobile only *\/<\/code><code>font-size<\/code><code>: <\/code><code>12px<\/code><code>;<\/code><code>\/* Set base line-height for mobile only *\/<\/code><code>line-height<\/code><code>: <\/code><code>1.5<\/code><code>; <\/code><code>\/* 18px *\/<\/code><code>}<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>With these two declarations, you\u2019ve created a vertical rhythm spacing of 18px: 12 x 1.5 =\u00a018.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-attachment-id=\"4996\" data-permalink=\"https:\/\/azoora.com\/blog\/code\/how-to-easily-create-a-responsive-vertical-rhythm-with-css\/attachment\/responsive-vertical-rhythm-01\/#main\" data-orig-file=\"https:\/\/azoora.com\/blog\/wp-content\/uploads\/2020\/08\/Responsive-Vertical-Rhythm-01.jpg\" data-orig-size=\"1280,600\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Responsive-Vertical-Rhythm-01\" data-image-description=\"\" data-medium-file=\"https:\/\/azoora.com\/blog\/wp-content\/uploads\/2020\/08\/Responsive-Vertical-Rhythm-01-300x141.jpg\" data-large-file=\"https:\/\/azoora.com\/blog\/wp-content\/uploads\/2020\/08\/Responsive-Vertical-Rhythm-01-1024x480.jpg\" loading=\"lazy\" width=\"1024\" height=\"480\" src=\"https:\/\/azoora.com\/blog\/wp-content\/uploads\/2020\/08\/Responsive-Vertical-Rhythm-01-1024x480.jpg\" alt=\"\" class=\"wp-image-4996\" srcset=\"https:\/\/azoora.com\/blog\/wp-content\/uploads\/2020\/08\/Responsive-Vertical-Rhythm-01-1024x480.jpg 1024w, https:\/\/azoora.com\/blog\/wp-content\/uploads\/2020\/08\/Responsive-Vertical-Rhythm-01-300x141.jpg 300w, https:\/\/azoora.com\/blog\/wp-content\/uploads\/2020\/08\/Responsive-Vertical-Rhythm-01-768x360.jpg 768w, https:\/\/azoora.com\/blog\/wp-content\/uploads\/2020\/08\/Responsive-Vertical-Rhythm-01.jpg 1280w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h3>2. Adding the&nbsp;spacing<\/h3>\n\n\n\n<p>With the default vertical rhythm established, the spacing is next. If the margins above and below the paragraphs are the same, the math is straight&nbsp;forward.<\/p>\n\n\n\n<p>By default, web browsers insert a top and bottom margin of 1em to paragraphs. We\u2019ll simply have to redefine it for them to match our vertical&nbsp;rhythm.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"\"><tbody><tr><td><code>p {<\/code><code>margin-top<\/code><code>: <\/code><code>1.5em<\/code><code>; <\/code><code>\/* 18px *\/<\/code><code>margin-bottom<\/code><code>: <\/code><code>1.5em<\/code><code>; <\/code><code>\/* 18px *\/<\/code>&nbsp;<code>\/* !Font-size and line-height for reference only! *\/<\/code><code>\/* font-size: 1em; *\/<\/code> <code>\/* 14px *\/<\/code><code>\/* line-height: 1em; *\/<\/code> <code>\/* 18px *\/<\/code><code>}<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>The spacing will be different for other elements such as headers that use a different font-size and line-height but more on that later. We\u2019re also tackling different spacing multipliers later\u00a0too.<\/p>\n\n\n\n<h3>3. Variations in&nbsp;font-sizes<\/h3>\n\n\n\n<p>It\u2019s expected for a design to use multiple font-sizes, especially in headings. However, this can also include things like blockquotes, figure captions, and so on. Not to mention, it can get a bit complicated if you\u2019re also using responsive typography for each of these&nbsp;too.<\/p>\n\n\n\n<p>Below we\u2019re setting up the line-height and margins for an H1 that has a font-size of 20px from the vertical rhythm base of\u00a018px.<\/p>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-attachment-id=\"4997\" data-permalink=\"https:\/\/azoora.com\/blog\/code\/how-to-easily-create-a-responsive-vertical-rhythm-with-css\/attachment\/responsive-vertical-rhythm-02\/#main\" data-orig-file=\"https:\/\/azoora.com\/blog\/wp-content\/uploads\/2020\/08\/Responsive-Vertical-Rhythm-02.jpg\" data-orig-size=\"1280,600\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Responsive-Vertical-Rhythm-02\" data-image-description=\"\" data-medium-file=\"https:\/\/azoora.com\/blog\/wp-content\/uploads\/2020\/08\/Responsive-Vertical-Rhythm-02-300x141.jpg\" data-large-file=\"https:\/\/azoora.com\/blog\/wp-content\/uploads\/2020\/08\/Responsive-Vertical-Rhythm-02-1024x480.jpg\" loading=\"lazy\" width=\"1024\" height=\"480\" src=\"https:\/\/azoora.com\/blog\/wp-content\/uploads\/2020\/08\/Responsive-Vertical-Rhythm-02-1024x480.jpg\" alt=\"\" class=\"wp-image-4997\" srcset=\"https:\/\/azoora.com\/blog\/wp-content\/uploads\/2020\/08\/Responsive-Vertical-Rhythm-02-1024x480.jpg 1024w, https:\/\/azoora.com\/blog\/wp-content\/uploads\/2020\/08\/Responsive-Vertical-Rhythm-02-300x141.jpg 300w, https:\/\/azoora.com\/blog\/wp-content\/uploads\/2020\/08\/Responsive-Vertical-Rhythm-02-768x360.jpg 768w, https:\/\/azoora.com\/blog\/wp-content\/uploads\/2020\/08\/Responsive-Vertical-Rhythm-02.jpg 1280w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"\"><tbody><tr><td><code>h<\/code><code>1<\/code> <code>{<\/code><code>font-size<\/code><code>: <\/code><code>1.6667em<\/code><code>; <\/code><code>\/* 20px; *\/<\/code><code>line-height<\/code><code>: <\/code><code>1.8000em<\/code><code>; <\/code><code>\/* 36px *\/<\/code><code>margin-top<\/code><code>: <\/code><code>0.9em<\/code><code>; <\/code><code>\/* 18px *\/<\/code><code>margin-bottom<\/code><code>: <\/code><code>0.9em<\/code><code>; <\/code><code>\/* 18px *\/<\/code><code>}<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<h4>How did we get these numbers?<\/h4>\n\n\n\n<ul><li>To calculate the heading\u2019s font-size divide the desired font\u2019s pixel size (20px) by the default font-size (12px): 20\/12 = 1.6667<\/li><li>To calculate the new line-height, first, double the line height (because of the larger font size), then divide the new line-height (36px) by the heading\u2019s font size (20px): (18*2) = 36, 36\/20 = 1.8<\/li><li>To calculate the margins, divide the default line-height (18pxm) by the heading\u2019s font size (20px): 18\/20: 0.9<\/li><\/ul>\n\n\n\n<p>Can the new line-height be different? Yes, of course. The&nbsp;<a href=\"https:\/\/webdesign.tutsplus.com\/articles\/improving-layout-with-vertical-rhythm--webdesign-14070\" target=\"_blank\" rel=\"noreferrer noopener\">design determines the line heights<\/a>. It could be 2.5, for instance. This example assumes the H1\u2019s line-height is double for&nbsp;simplicity.<\/p>\n\n\n\n<p>What if you wanted to have larger margins than the default 18px line-height? That\u2019s where the multipliers come&nbsp;in!<\/p>\n\n\n\n<h3>4. Generating spacing&nbsp;multipliers<\/h3>\n\n\n\n<p>In the example so far, the spacing between the H1 and a paragraph would be exactly the same as the spacing between multiple paragraphs. That\u2019s where the multipliers come in. We can create them in plain CSS, but using variables with LESS or SASS will make the math more accurate and easier to handle&nbsp;too.<\/p>\n\n\n\n<p>Adding multipliers to your CSS system is a great way to have additional classes for the different numbers of vertical rhythm units, such as x1, x2, and so on. You can then use these classes as additional padding and spacing around&nbsp;elements.<\/p>\n\n\n\n<p>You will be able to reuse the spacing as needed instead of hard coding them into a specific element. This way, the code can easily be customized if you want to add 3x spacing below an H1 and a paragraph or 2x spacing between an H1 and H2. This method also makes responsive vertical rhythm easier too. That\u2019s because all you have to do is update the reusable multipliers instead of a slew of CSS dependencies. Yes, you can use this padding on other elements too like images or&nbsp;sections.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"\"><tbody><tr><td><code>.vertical-spacing-bottom<\/code><code>-1<\/code><code>x {<\/code><code>padding-bottom<\/code><code>: <\/code><code>1.5em<\/code><code>; <\/code><code>\/* 18px *\/<\/code><code>}<\/code>&nbsp;<code>.vertical-spacing-bottom<\/code><code>-2<\/code><code>x {<\/code><code>padding-bottom<\/code><code>: <\/code><code>3em<\/code><code>; <\/code><code>\/* 36px *\/<\/code><code>}<\/code>&nbsp;<code>.vertical-spacing-bottom<\/code><code>-3<\/code><code>x {<\/code><code>padding-bottom<\/code><code>: <\/code><code>4.5em<\/code><code>; <\/code><code>\/* 54px *\/<\/code><code>}<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<p>The math here is nothing complicated (18*X)\/12 = #em. Naturally, to create you follow the same process for padding-top multipliers&nbsp;too.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"\"><tbody><tr><td><code>.vertical-spacing-top<\/code><code>-1<\/code><code>x {<\/code><code>padding-bottom<\/code><code>: <\/code><code>1.5em<\/code><code>; <\/code><code>\/* 18px *\/<\/code><code>}<\/code>&nbsp;<code>.vertical-spacing-top<\/code><code>-2<\/code><code>x {<\/code><code>padding-bottom<\/code><code>: <\/code><code>3em<\/code><code>; <\/code><code>\/* 36px *\/<\/code><code>}<\/code>&nbsp;<code>.vertical-spacing-top<\/code><code>-3<\/code><code>x {<\/code><code>padding-bottom<\/code><code>: <\/code><code>4.5em<\/code><code>; <\/code><code>\/* 54px *\/<\/code><code>}<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-attachment-id=\"5001\" data-permalink=\"https:\/\/azoora.com\/blog\/code\/how-to-easily-create-a-responsive-vertical-rhythm-with-css\/attachment\/responsive-vertical-rhythm-03\/#main\" data-orig-file=\"https:\/\/azoora.com\/blog\/wp-content\/uploads\/2020\/08\/Responsive-Vertical-Rhythm-03.jpg\" data-orig-size=\"1280,800\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Responsive-Vertical-Rhythm-03\" data-image-description=\"\" data-medium-file=\"https:\/\/azoora.com\/blog\/wp-content\/uploads\/2020\/08\/Responsive-Vertical-Rhythm-03-300x188.jpg\" data-large-file=\"https:\/\/azoora.com\/blog\/wp-content\/uploads\/2020\/08\/Responsive-Vertical-Rhythm-03-1024x640.jpg\" loading=\"lazy\" width=\"1024\" height=\"640\" src=\"https:\/\/azoora.com\/blog\/wp-content\/uploads\/2020\/08\/Responsive-Vertical-Rhythm-03-1024x640.jpg\" alt=\"\" class=\"wp-image-5001\" srcset=\"https:\/\/azoora.com\/blog\/wp-content\/uploads\/2020\/08\/Responsive-Vertical-Rhythm-03-1024x640.jpg 1024w, https:\/\/azoora.com\/blog\/wp-content\/uploads\/2020\/08\/Responsive-Vertical-Rhythm-03-300x188.jpg 300w, https:\/\/azoora.com\/blog\/wp-content\/uploads\/2020\/08\/Responsive-Vertical-Rhythm-03-768x480.jpg 768w, https:\/\/azoora.com\/blog\/wp-content\/uploads\/2020\/08\/Responsive-Vertical-Rhythm-03.jpg 1280w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h3>5. Creating a responsive vertical&nbsp;rhythm<\/h3>\n\n\n\n<p>Responsive typography\u00a0is a design practice of using\u00a0<a rel=\"noreferrer noopener\" href=\"https:\/\/www.smashingmagazine.com\/2017\/05\/fluid-responsive-typography-css-poly-fluid-sizing\/\" target=\"_blank\">different font sizes and spacing on different devices<\/a>.\u00a0 It\u2019s a great idea for improved user experiences on various\u00a0devices.<\/p>\n\n\n\n<p>What we\u2019ve done up until this point will work for a website with no responsive typography. As already mentioned, progressive enhancement is a great method for creating a responsive vertical rhythm. It will be the default vertical rhythm and one for mobile devices. Next, we can focus on creating a new vertical rhythm for&nbsp;desktops.<\/p>\n\n\n\n<h2>What about tablet&nbsp;sizes?<\/h2>\n\n\n\n<p>The design you\u2019re coding might have multiple typography requirements for a variety of screen sizes. With progressive enhancement, you\u2019d first define the vertical rhythm from the smallest device to the largest. To keep this tutorial short and sweet, we\u2019ll only concern ourselves with a mobile and&nbsp;desktop.<\/p>\n\n\n\n<h3>Setting up the desktop vertical rhythm with media&nbsp;queries<\/h3>\n\n\n\n<p>The first thing we\u2019ll&nbsp;<a href=\"https:\/\/internetingishard.com\/html-and-css\/responsive-design\/\" target=\"_blank\" rel=\"noreferrer noopener\">set up is a media query<\/a>&nbsp;for the minimum device width we want our new desktop vertical rhythm to take effect on. Then, we can copy and paste what we\u2019ve already done and replace the numbers&nbsp;accordingly.<\/p>\n\n\n\n<p>It\u2019s really that simple. Although, it can be tedious and redundant. That\u2019s why using LESS or SASS is recommended because they allow for use of&nbsp;variables.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"\"><tbody><tr><td><code>@media only <\/code><code>screen<\/code> <code>and (<\/code><code>min-width<\/code><code>: <\/code><code>600px<\/code><code>) {<\/code><code>@media only <\/code><code>screen<\/code> <code>and (<\/code><code>min-width<\/code><code>: <\/code><code>600px<\/code><code>) {<\/code><code>body {<\/code><code>\/* Set default font size for desktop only *\/<\/code><code>font-size<\/code><code>: <\/code><code>16px<\/code><code>;<\/code><code>\/* Set base line-height for desktop only *\/<\/code><code>line-height<\/code><code>: <\/code><code>1.375<\/code><code>; <\/code><code>\/* 22px *\/<\/code><code>}<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-attachment-id=\"4999\" data-permalink=\"https:\/\/azoora.com\/blog\/code\/how-to-easily-create-a-responsive-vertical-rhythm-with-css\/attachment\/responsive-vertical-rhythm-04\/#main\" data-orig-file=\"https:\/\/azoora.com\/blog\/wp-content\/uploads\/2020\/08\/Responsive-Vertical-Rhythm-04.jpg\" data-orig-size=\"1280,600\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Responsive-Vertical-Rhythm-04\" data-image-description=\"\" data-medium-file=\"https:\/\/azoora.com\/blog\/wp-content\/uploads\/2020\/08\/Responsive-Vertical-Rhythm-04-300x141.jpg\" data-large-file=\"https:\/\/azoora.com\/blog\/wp-content\/uploads\/2020\/08\/Responsive-Vertical-Rhythm-04-1024x480.jpg\" loading=\"lazy\" width=\"1024\" height=\"480\" src=\"https:\/\/azoora.com\/blog\/wp-content\/uploads\/2020\/08\/Responsive-Vertical-Rhythm-04-1024x480.jpg\" alt=\"\" class=\"wp-image-4999\" srcset=\"https:\/\/azoora.com\/blog\/wp-content\/uploads\/2020\/08\/Responsive-Vertical-Rhythm-04-1024x480.jpg 1024w, https:\/\/azoora.com\/blog\/wp-content\/uploads\/2020\/08\/Responsive-Vertical-Rhythm-04-300x141.jpg 300w, https:\/\/azoora.com\/blog\/wp-content\/uploads\/2020\/08\/Responsive-Vertical-Rhythm-04-768x360.jpg 768w, https:\/\/azoora.com\/blog\/wp-content\/uploads\/2020\/08\/Responsive-Vertical-Rhythm-04.jpg 1280w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Next, we need to set the default margins for a p tag and adjust all the numbers surrounding the&nbsp;H1.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"\"><tbody><tr><td><code>p {<\/code><code>margin-top<\/code><code>: <\/code><code>1.375em<\/code><code>; <\/code><code>\/* 22px *\/<\/code><code>margin-bottom<\/code><code>: <\/code><code>1.375em<\/code><code>; <\/code><code>\/* 22px *\/<\/code>&nbsp;<code>\/* !Font-size and line-height for reference only! *\/<\/code><code>\/* font-size: 1em; *\/<\/code> <code>\/* 16px *\/<\/code><code>\/* line-height: 1em; *\/<\/code> <code>\/* 22px *\/<\/code><code>}<\/code><code>h<\/code><code>1<\/code> <code>{<\/code><code>font-size<\/code><code>: <\/code><code>1.75em<\/code><code>; <\/code><code>\/* 28px; *\/<\/code><code>line-height<\/code><code>: <\/code><code>1.5714em<\/code><code>; <\/code><code>\/* 33px (1.5*22px) *\/<\/code><code>margin-top<\/code><code>: <\/code><code>0.7857em<\/code><code>; <\/code><code>\/* 18px *\/<\/code><code>margin-bottom<\/code><code>: <\/code><code>0.7857em<\/code><code>; <\/code><code>\/* 18px *\/<\/code><code>}<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-attachment-id=\"4998\" data-permalink=\"https:\/\/azoora.com\/blog\/code\/how-to-easily-create-a-responsive-vertical-rhythm-with-css\/attachment\/responsive-vertical-rhythm-05\/#main\" data-orig-file=\"https:\/\/azoora.com\/blog\/wp-content\/uploads\/2020\/08\/Responsive-Vertical-Rhythm-05.jpg\" data-orig-size=\"1280,600\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Responsive-Vertical-Rhythm-05\" data-image-description=\"\" data-medium-file=\"https:\/\/azoora.com\/blog\/wp-content\/uploads\/2020\/08\/Responsive-Vertical-Rhythm-05-300x141.jpg\" data-large-file=\"https:\/\/azoora.com\/blog\/wp-content\/uploads\/2020\/08\/Responsive-Vertical-Rhythm-05-1024x480.jpg\" loading=\"lazy\" width=\"1024\" height=\"480\" src=\"https:\/\/azoora.com\/blog\/wp-content\/uploads\/2020\/08\/Responsive-Vertical-Rhythm-05-1024x480.jpg\" alt=\"\" class=\"wp-image-4998\" srcset=\"https:\/\/azoora.com\/blog\/wp-content\/uploads\/2020\/08\/Responsive-Vertical-Rhythm-05-1024x480.jpg 1024w, https:\/\/azoora.com\/blog\/wp-content\/uploads\/2020\/08\/Responsive-Vertical-Rhythm-05-300x141.jpg 300w, https:\/\/azoora.com\/blog\/wp-content\/uploads\/2020\/08\/Responsive-Vertical-Rhythm-05-768x360.jpg 768w, https:\/\/azoora.com\/blog\/wp-content\/uploads\/2020\/08\/Responsive-Vertical-Rhythm-05.jpg 1280w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<p>Lastly, we\u2019ll have to adjust the multiplier&nbsp;classes.<\/p>\n\n\n\n<figure class=\"wp-block-table\"><table class=\"\"><tbody><tr><td><code>.vertical-spacing-bottom<\/code><code>-1<\/code><code>x {<\/code><code>padding-bottom<\/code><code>: <\/code><code>1.375<\/code><code>; <\/code><code>\/* 22px *\/<\/code><code>}<\/code>&nbsp;<code>.vertical-spacing-bottom<\/code><code>-2<\/code><code>x {<\/code><code>padding-bottom<\/code><code>: <\/code><code>2.75em<\/code><code>; <\/code><code>\/* 44px *\/<\/code><code>}<\/code>&nbsp;<code>.vertical-spacing-bottom<\/code><code>-3<\/code><code>x {<\/code><code>padding-bottom<\/code><code>: <\/code><code>4.125em<\/code><code>; <\/code><code>\/* 66px *\/<\/code><code>}<\/code><code>.vertical-spacing-top<\/code><code>-1<\/code><code>x {<\/code><code>padding-bottom<\/code><code>: <\/code><code>1.375<\/code><code>; <\/code><code>\/* 22px *\/<\/code><code>}<\/code>&nbsp;<code>.vertical-spacing-top<\/code><code>-2<\/code><code>x {<\/code><code>padding-bottom<\/code><code>: <\/code><code>2.75em<\/code><code>; <\/code><code>\/* 44px *\/<\/code><code>}<\/code>&nbsp;<code>.vertical-spacing-top<\/code><code>-3<\/code><code>x {<\/code><code>padding-bottom<\/code><code>: <\/code><code>4.125em<\/code><code>; <\/code><code>\/* 66px *\/<\/code><code>}<\/code><code>}<\/code><code>\/* End @media only screen and (min-width: 600px) *\/<\/code><\/td><\/tr><\/tbody><\/table><\/figure>\n\n\n\n<figure class=\"wp-block-image size-large\"><img data-attachment-id=\"5000\" data-permalink=\"https:\/\/azoora.com\/blog\/code\/how-to-easily-create-a-responsive-vertical-rhythm-with-css\/attachment\/responsive-vertical-rhythm-06\/#main\" data-orig-file=\"https:\/\/azoora.com\/blog\/wp-content\/uploads\/2020\/08\/Responsive-Vertical-Rhythm-06.jpg\" data-orig-size=\"1280,600\" data-comments-opened=\"1\" data-image-meta=\"{&quot;aperture&quot;:&quot;0&quot;,&quot;credit&quot;:&quot;&quot;,&quot;camera&quot;:&quot;&quot;,&quot;caption&quot;:&quot;&quot;,&quot;created_timestamp&quot;:&quot;0&quot;,&quot;copyright&quot;:&quot;&quot;,&quot;focal_length&quot;:&quot;0&quot;,&quot;iso&quot;:&quot;0&quot;,&quot;shutter_speed&quot;:&quot;0&quot;,&quot;title&quot;:&quot;&quot;,&quot;orientation&quot;:&quot;0&quot;}\" data-image-title=\"Responsive-Vertical-Rhythm-06\" data-image-description=\"\" data-medium-file=\"https:\/\/azoora.com\/blog\/wp-content\/uploads\/2020\/08\/Responsive-Vertical-Rhythm-06-300x141.jpg\" data-large-file=\"https:\/\/azoora.com\/blog\/wp-content\/uploads\/2020\/08\/Responsive-Vertical-Rhythm-06-1024x480.jpg\" loading=\"lazy\" width=\"1024\" height=\"480\" src=\"https:\/\/azoora.com\/blog\/wp-content\/uploads\/2020\/08\/Responsive-Vertical-Rhythm-06-1024x480.jpg\" alt=\"\" class=\"wp-image-5000\" srcset=\"https:\/\/azoora.com\/blog\/wp-content\/uploads\/2020\/08\/Responsive-Vertical-Rhythm-06-1024x480.jpg 1024w, https:\/\/azoora.com\/blog\/wp-content\/uploads\/2020\/08\/Responsive-Vertical-Rhythm-06-300x141.jpg 300w, https:\/\/azoora.com\/blog\/wp-content\/uploads\/2020\/08\/Responsive-Vertical-Rhythm-06-768x360.jpg 768w, https:\/\/azoora.com\/blog\/wp-content\/uploads\/2020\/08\/Responsive-Vertical-Rhythm-06.jpg 1280w\" sizes=\"(max-width: 1024px) 100vw, 1024px\" \/><\/figure>\n\n\n\n<h2>Conclusion<\/h2>\n\n\n\n<p>As you can see, it only takes five small steps to create a flexible and responsive vertical rhythm with plain CSS. You can customize the vertical rhythm to fit your specific design requirements as needed and use the above tutorial as your basic set&nbsp;up.<\/p>\n\n\n\n<p>If you need to, you can add media queries for tablets, medium-size devices like netbooks or small laptops, typical desktop sizes, and extra-large desktop monitors. All you have to do is define the right media query and repeat this process for&nbsp;each.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Maintaining\u00a0grid systems\u00a0across a website can be a challenge. Implementing a CSS grid\u00a0has become standard practice, whereas implementing horizontal grids \u2013 aka vertical rhythm \u2013 can be too. However, there is added complexity thanks to responsive design and responsive typography. Though, it\u2019s actually quite easy to create a responsive vertical rhythm that is flexible to responsive [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":5002,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"spay_email":"","jetpack_publicize_message":"","jetpack_is_tweetstorm":false},"categories":[4,145],"tags":[25,56,94,146,116,217],"jetpack_featured_media_url":"https:\/\/azoora.com\/blog\/wp-content\/uploads\/2020\/08\/Responsive-Vertical-Rhythm.jpg","jetpack_publicize_connections":[],"jetpack_shortlink":"https:\/\/wp.me\/p7FQPL-1iz","jetpack-related-posts":[],"jetpack_sharing_enabled":true,"jetpack_likes_enabled":true,"_links":{"self":[{"href":"https:\/\/azoora.com\/blog\/wp-json\/wp\/v2\/posts\/4995"}],"collection":[{"href":"https:\/\/azoora.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/azoora.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/azoora.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/azoora.com\/blog\/wp-json\/wp\/v2\/comments?post=4995"}],"version-history":[{"count":1,"href":"https:\/\/azoora.com\/blog\/wp-json\/wp\/v2\/posts\/4995\/revisions"}],"predecessor-version":[{"id":5003,"href":"https:\/\/azoora.com\/blog\/wp-json\/wp\/v2\/posts\/4995\/revisions\/5003"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/azoora.com\/blog\/wp-json\/wp\/v2\/media\/5002"}],"wp:attachment":[{"href":"https:\/\/azoora.com\/blog\/wp-json\/wp\/v2\/media?parent=4995"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/azoora.com\/blog\/wp-json\/wp\/v2\/categories?post=4995"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/azoora.com\/blog\/wp-json\/wp\/v2\/tags?post=4995"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}