{"id":62599,"date":"2019-03-29T04:15:37","date_gmt":"2019-03-29T11:15:37","guid":{"rendered":"http:\/\/www.taterboy.com\/blog\/2019\/03\/how-to-align-things-in-css\/"},"modified":"2019-03-29T04:15:37","modified_gmt":"2019-03-29T11:15:37","slug":"how-to-align-things-in-css","status":"publish","type":"post","link":"https:\/\/www.taterboy.com\/blog\/2019\/03\/how-to-align-things-in-css\/","title":{"rendered":"How To Align Things In CSS"},"content":{"rendered":"<link rel=\"canonical\" href=\"https:\/\/www.smashingmagazine.com\/2019\/03\/css-alignment\/\"><title>How To Align Things In CSS<\/title><\/p>\n<article>\n<header>\n<h1>How To Align Things In CSS<\/h1>\n<address>Rachel Andrew<\/address>\n<p>                  <time datetime=\"2019-03-28T12:30:41+01:00\">2019-03-28T12:30:41+01:00<\/time><time datetime=\"2019-03-29T11:05:55+00:00\">2019-03-29T11:05:55+00:00<\/time><\/header>\n<p>We have a whole selection of ways to align things in CSS today, and it isn\u2019t always an obvious decision which to use. However, knowing what is available means that you can always try a few tactics if you come across a particular alignment problem.<\/p>\n<p>In this article, I will take a look at the different alignment methods. Instead of providing a comprehensive guide to each, I\u2019ll explain a few of the sticking points people have and point to more complete references for the properties and values. As with much of CSS, you can go a long way by <strong>understanding the fundamental things<\/strong> about how the methods behave, and then need a place to go look up the finer details in terms of how you achieve the precise layout that you want.<\/p>\n<h3>Aligning Text And Inline Elements<\/h3>\n<p>When we have some text and other inline elements on a page, each line of content is treated as a line box. The property <code>text-align<\/code> will align that content on the page, for example, if you want your text centered, or justified. Sometimes, however, you may want to align things inside that line box against other things, for example, if you have an icon displayed alongside text, or text of different sizes.<\/p>\n<div data-component=\"FeaturePanel\" data-audience=\"non-subscriber\" data-remove=\"true\"><\/div>\n<p>In the example below, I have some text with a larger inline image. I am using <code>vertical-align: middle<\/code> on the image to align the text to the middle of the image.<\/p>\n<div>\n<p data-height=\"500\" data-theme-id=\"light\" data-slug-hash=\"jJJLBR\" data-user=\"rachelandrew\" data-default-tab=\"result\">See the Pen <a href=\"https:\/\/www.smashingmagazine.com\/articles\/\">Vertical Alignment example<\/a> by <a href=\"https:\/\/codepen.io\/rachelandrew\">Rachel Andrew<\/a>.<\/p>\n<\/div>\n<h4>The <code>line-height<\/code> Property And Alignment<\/h4>\n<p>Remember that the <code>line-height<\/code> property will change the size of the line-box and therefore can change your alignment. The following example uses a large line-height value of 150px, and I have aligned the image to <code>top<\/code>. The image is aligned to the top of the line box and not the top of the text, remove that line-height or make it less than the size of the image and the image and text will line up at the top of the text.<\/p>\n<div>\n<p data-height=\"500\" data-theme-id=\"light\" data-slug-hash=\"eXXGOB\" data-user=\"rachelandrew\" data-default-tab=\"result\">See the Pen <a href=\"https:\/\/www.smashingmagazine.com\/articles\/\">Vertical Alignment and line-height<\/a> by <a href=\"https:\/\/codepen.io\/rachelandrew\">Rachel Andrew<\/a>.<\/p>\n<\/div>\n<p>It turns out that <code>line-height<\/code> and indeed the size of text is pretty complicated, and I\u2019m not going to head down that rabbit hole in this article. If you are trying to precisely align inline elements and want to really understand what is going on, I recommend reading \u201c<a href=\"https:\/\/iamvdo.me\/en\/blog\/css-font-metrics-line-height-and-vertical-align\">Deep Dive CSS: Font Metrics, <code>line-height<\/code> And <code>vertical-align<\/code><\/a>.\u201d<\/p>\n<h4>When Can I Use The <code>vertical-align<\/code> Property?<\/h4>\n<p>The <code>vertical-align<\/code> property is useful if you are aligning any inline element. This includes elements with <code>display: inline-block<\/code>. The content of table cells can also be aligned with the <code>vertical-align<\/code> property.<\/p>\n<p>The <code>vertical-align<\/code> property has no effect on flex or grid items, and therefore if used as part of a fallback strategy, will cease to apply the minute the parent element is turned into a grid or flex Container. For example, in the next pen, I have a set of items laid out with <code>display: inline-block<\/code> and this means that I get the ability to align the items even if the browser does not have Flexbox:<\/p>\n<p data-height=\"500\" data-theme-id=\"light\" data-slug-hash=\"QoPMYR\" data-user=\"rachelandrew\" data-default-tab=\"result\">See the Pen <a href=\"https:\/\/www.smashingmagazine.com\/articles\/\">inline-block and vertical-align<\/a> by <a href=\"https:\/\/codepen.io\/rachelandrew\">Rachel Andrew<\/a>.<\/p>\n<p>In this next pen, I have treated the <code>inline-block<\/code> as a fallback for Flex layout. The alignment properties no longer apply, and I can add <code>align-items<\/code> to align the items in Flexbox. You can tell that the Flexbox method is in play because the gap between items that you will get when using <code>display: inline-block<\/code> is gone.<\/p>\n<p data-height=\"500\" data-theme-id=\"light\" data-slug-hash=\"xBeLBg\" data-user=\"rachelandrew\" data-default-tab=\"result\">See the Pen <a href=\"https:\/\/www.smashingmagazine.com\/articles\/\">inline-block flex fallback<\/a> by <a href=\"https:\/\/codepen.io\/rachelandrew\">Rachel Andrew<\/a>.<\/p>\n<p>The fact that <code>vertical-align<\/code> works on table cells is the reason that the trick to <a href=\"https:\/\/www.vanseodesign.com\/blog\/demo\/vertical-centering\/table-cell.php\">vertically center an item using <code>display: table-cell<\/code> works<\/a>.<\/p>\n<p>Now that we do have better ways to align boxes in CSS (as we will look at in the next section), we don\u2019t need to employ the <code>vertical-align<\/code> and <code>text-align<\/code> properties in places other than the inline and text elements for which they were designed. However, they are still completely valid to use in those text and inline formats, and so remember if you are trying to align something inline, it is these properties and not the Box Alignment ones that you need to reach for.<\/p>\n<h3>Box Alignment<\/h3>\n<p>The Box Alignment Specification deals with how we align everything else. The specification details the following alignment properties:<\/p>\n<ul>\n<li><code>justify-content<\/code><\/li>\n<li><code>align-content<\/code><\/li>\n<li><code>justify-self<\/code><\/li>\n<li><code>align-self<\/code><\/li>\n<li><code>justify-items<\/code><\/li>\n<li><code>align-items<\/code><\/li>\n<\/ul>\n<p>You might already think of these properties as being part of the Flexbox Specification, or perhaps Grid. The history of the properties is that they originated as part of Flexbox, and still exist in the Level 1 specification; however, they were moved into their own specification when it became apparent that they were more generally useful. We now also use them in Grid Layout, and they are specified for other layout methods too, although current browser support means that you won\u2019t be able to use them just yet.<\/p>\n<p>Therefore, next time someone on the Internet tells you that vertical alignment is the hardest part of CSS, you can tell them this (which even fits into a tweet):<\/p>\n<pre><code>.container {\n  display: flex;\n  align-items: center;\n  justify-content: center;\n}\n<\/code><\/pre>\n<p>In the future, we may even be able to dispense with <code>display: flex<\/code>, once the Box Alignment properties are implemented for Block Layout. At the moment, however, making the parent of the thing you want centering a flex container is the way to get alignment horizontally and vertically.<\/p>\n<div><\/div>\n<h3>The Two Types Of Alignment<\/h3>\n<p>When aligning flex and grid items, you have two possible things to align:<\/p>\n<ol>\n<li>You have the spare space in the grid or flex container (once the items or tracks have been laid out).<\/li>\n<li>You also have the item itself inside the grid area you placed it in, or on the cross axis inside the flex container.<\/li>\n<\/ol>\n<p>I showed you a set of properties above, and the alignment properties can be thought of as two groups. Those which deal with distribution of spare space, and those which align the item itself.<\/p>\n<h4>Dealing With Spare Space: <code>align-content<\/code> And <code>justify-content<\/code><\/h4>\n<p>The properties which end in <code>-content<\/code> are about space distribution, so when you choose to use <code>align-content<\/code> or <code>justify-content<\/code> you are distributing available space between grid tracks or flex items. They don\u2019t change the size of the flex or grid items themselves; they move them around because they change where the spare space goes.<\/p>\n<p>Below, I have a flex example and a grid example. Both have a container which is larger than required to display the flex items or grid tracks, so I can use <code>align-content<\/code> and <code>justify-content<\/code> to distribute that space.<\/p>\n<p data-height=\"500\" data-theme-id=\"light\" data-slug-hash=\"gEyGaQ\" data-user=\"rachelandrew\" data-default-tab=\"result\">See the Pen <a href=\"https:\/\/www.smashingmagazine.com\/articles\/\">justify-content and align-content<\/a> by <a href=\"https:\/\/codepen.io\/rachelandrew\">Rachel Andrew<\/a>.<\/p>\n<h4>Moving Items Around: <code>justify-self<\/code>, <code>align-self<\/code>, <code>justify-items<\/code> And <code>align-items<\/code><\/h4>\n<p>We then have <code>align-self<\/code> and <code>justify-self<\/code> as applied to individual flex or grid items; you can also use <code>align-items<\/code> and <code>justify-items<\/code> on the container to set all the properties at once. These properties deal with the actual flex or grid item, i.e. moving the content around inside the Grid Area or flex line.<\/p>\n<ul>\n<li><strong>Grid Layout<\/strong><br \/>\nYou get both properties as you can shift the item on the block and inline axis as we have a defined Grid Area in which it sits.<\/li>\n<li><strong>Flex Layout<\/strong><br \/>\nYou can only align on the cross axis as the main axis is controlled by space distribution alone. So if your items are a row, you can use <code>align-self<\/code> to shift them up and down inside the flex line, aligning them against each other.<\/li>\n<\/ul>\n<p>In my example below, I have a flex and a grid container, and am using <code>align-items<\/code> and <code>align-self<\/code> in Flexbox to move the items up and down against each other on the cross axis. If you use Firefox, and inspect the element using the Firefox Flexbox Inspector, you can see the size of the flex container and how the items are being moved vertically inside of that.<\/p>\n<figure><a href=\"https:\/\/i0.wp.com\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/fdde57d8-4da5-4847-bdfd-52f34c24f544\/sm-align-flex-self-alignment.png?ssl=1\"><br \/>\n\t\t<img data-recalc-dims=\"1\" decoding=\"async\" srcset=\"http:\/\/www.taterboy.com\/blog\/wp-content\/uploads\/2019\/03\/sm-align-flex-self-alignment.png 400w,\n\t\t\t        https:\/\/res.cloudinary.com\/indysigner\/image\/fetch\/f_auto,q_auto\/w_800\/https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/fdde57d8-4da5-4847-bdfd-52f34c24f544\/sm-align-flex-self-alignment.png 800w,\n\t\t\t        https:\/\/res.cloudinary.com\/indysigner\/image\/fetch\/f_auto,q_auto\/w_1200\/https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/fdde57d8-4da5-4847-bdfd-52f34c24f544\/sm-align-flex-self-alignment.png 1200w,\n\t\t\t        https:\/\/res.cloudinary.com\/indysigner\/image\/fetch\/f_auto,q_auto\/w_1600\/https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/fdde57d8-4da5-4847-bdfd-52f34c24f544\/sm-align-flex-self-alignment.png 1600w,\n\t\t\t        https:\/\/res.cloudinary.com\/indysigner\/image\/fetch\/f_auto,q_auto\/w_2000\/https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/fdde57d8-4da5-4847-bdfd-52f34c24f544\/sm-align-flex-self-alignment.png 2000w\" src=\"https:\/\/i0.wp.com\/www.taterboy.com\/blog\/wp-content\/uploads\/2019\/03\/sm-align-flex-self-alignment.png?w=900\" sizes=\"100vw\" alt=\"Flex items aligned in their container\"><\/a><figcaption>\n\t\t\tAligned flex items with the flex container highlighted in Firefox (<a href=\"https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/fdde57d8-4da5-4847-bdfd-52f34c24f544\/sm-align-flex-self-alignment.png\">Large preview<\/a>)<br \/>\n\t\t<\/figcaption><\/figure>\n<p>In grid, I can use all four properties to move the items around inside their grid area. Once again, the Firefox DevTools Grid Inspector will be useful when playing with alignment. With the grid lines overlaid, you can see the area inside which the content is being moved:<\/p>\n<figure><a href=\"https:\/\/i0.wp.com\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/91af6361-45c7-4914-b0fc-c7c7e6dd382c\/sm-align-grid-self-alignment.png?ssl=1\"><br \/>\n\t\t<img data-recalc-dims=\"1\" decoding=\"async\" srcset=\"http:\/\/www.taterboy.com\/blog\/wp-content\/uploads\/2019\/03\/sm-align-grid-self-alignment.png 400w,\n\t\t\t        https:\/\/res.cloudinary.com\/indysigner\/image\/fetch\/f_auto,q_auto\/w_800\/https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/91af6361-45c7-4914-b0fc-c7c7e6dd382c\/sm-align-grid-self-alignment.png 800w,\n\t\t\t        https:\/\/res.cloudinary.com\/indysigner\/image\/fetch\/f_auto,q_auto\/w_1200\/https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/91af6361-45c7-4914-b0fc-c7c7e6dd382c\/sm-align-grid-self-alignment.png 1200w,\n\t\t\t        https:\/\/res.cloudinary.com\/indysigner\/image\/fetch\/f_auto,q_auto\/w_1600\/https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/91af6361-45c7-4914-b0fc-c7c7e6dd382c\/sm-align-grid-self-alignment.png 1600w,\n\t\t\t        https:\/\/res.cloudinary.com\/indysigner\/image\/fetch\/f_auto,q_auto\/w_2000\/https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/91af6361-45c7-4914-b0fc-c7c7e6dd382c\/sm-align-grid-self-alignment.png 2000w\" src=\"https:\/\/i0.wp.com\/www.taterboy.com\/blog\/wp-content\/uploads\/2019\/03\/sm-align-grid-self-alignment.png?w=900\" sizes=\"100vw\" alt=\"Aligned grid items\"><\/a><figcaption>\n\t\t\tAligned grid items with the Grid highlighted in Firefox (<a href=\"https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/91af6361-45c7-4914-b0fc-c7c7e6dd382c\/sm-align-grid-self-alignment.png\">Large preview<\/a>)<br \/>\n\t\t<\/figcaption><\/figure>\n<p>Play around with the values in the CodePen demo to see how you can shift content around in each layout method:<\/p>\n<p data-height=\"500\" data-theme-id=\"light\" data-slug-hash=\"xBejYV\" data-user=\"rachelandrew\" data-default-tab=\"result\">See the Pen <a href=\"https:\/\/www.smashingmagazine.com\/articles\/\">justify-self, align-self, justify-items, align-items<\/a> by <a href=\"https:\/\/codepen.io\/rachelandrew\">Rachel Andrew<\/a>.<\/p>\n<h3>Confused By <code>align<\/code> And <code>justify<\/code><\/h3>\n<p>One of the cited issues with people remembering the alignment properties in Grid and Flexbox, is that no one can remember whether to align or to justify. Which direction is which?<\/p>\n<p>For Grid Layout, you need to know if you are aligning in the Block or Inline Direction. The Block direction is the direction blocks lay out on your page (in your writing mode), i.e. for English that is vertically. The Inline direction is the direction in which sentences run (so for English that is left to right horizontally).<\/p>\n<p>To align things in the Block Direction, you will use the properties which start with <code>align-<\/code>. You use <code>align-content<\/code> to distribute space between grid tracks, if there is free space in the grid container, and <code>align-items<\/code> or <code>align-self<\/code> to move an item around inside the grid area it has been placed in.<\/p>\n<p>The below example has two grid layouts. One has <code>writing-mode: horizontal-tb<\/code> (which is the default for English) and the other <code>writing-mode: vertical-rl<\/code>. This is the only difference between them. You can see that the alignment properties which I have applied work in exactly the same way on the block axis in both modes.<\/p>\n<p data-height=\"500\" data-theme-id=\"light\" data-slug-hash=\"rRbYmr\" data-user=\"rachelandrew\" data-default-tab=\"result\">See the Pen <a href=\"https:\/\/www.smashingmagazine.com\/articles\/\">Grid Block Axis Alignment<\/a> by <a href=\"https:\/\/codepen.io\/rachelandrew\">Rachel Andrew<\/a>.<\/p>\n<p>To align things in the inline direction, use the properties which begin with <code>justify-<\/code>. Use <code>justify-content<\/code> to distribute space between grid tracks, and <code>justify-items<\/code> or <code>justify-self<\/code> to align items inside their grid area in the inline direction.<\/p>\n<p>Once again, I have two grid layout examples so that you can see that inline is always inline \u2014 no matter which writing mode you are using.<\/p>\n<p data-height=\"500\" data-theme-id=\"light\" data-slug-hash=\"eXoeEK\" data-user=\"rachelandrew\" data-default-tab=\"result\">See the Pen <a href=\"https:\/\/www.smashingmagazine.com\/articles\/\">Grid Inline Alignment<\/a> by <a href=\"https:\/\/codepen.io\/rachelandrew\">Rachel Andrew<\/a>.<\/p>\n<p>Flexbox is a little trickier due to the fact that we have a main axis which can be changed to <code>row<\/code> or <code>column<\/code>. So, let\u2019s first think about that main axis. It is set with the <code>flex-direction<\/code> property. The initial (or default) value of this property is <code>row<\/code> which will lay the flex items out as a row in the writing mode currently in use \u2014 this is why when working in English, we end up with items laid out horizontally when we create a flex container. You can then change the main axis to <code>flex-direction: column<\/code> and the items will be laid out as a column which means they are laid out in the block direction for that writing mode.<\/p>\n<p>As we can do this axis switching, the most important factor in Flexbox is asking, \u201cWhich axis is my main axis?\u201d Once you know that, then for alignment (when on your main axis) you simply use <code>justify-content<\/code>. It doesn\u2019t matter if your main axis is row or column. You control space <em>between<\/em> the flex items with <code>justify-content<\/code>.<\/p>\n<p data-height=\"500\" data-theme-id=\"light\" data-slug-hash=\"pYBdda\" data-user=\"rachelandrew\" data-default-tab=\"result\">See the Pen <a href=\"https:\/\/www.smashingmagazine.com\/articles\/\">justfy-content in Flexbox<\/a> by <a href=\"https:\/\/codepen.io\/rachelandrew\">Rachel Andrew<\/a>.<\/p>\n<p>On the cross axis, you can use <code>align-items<\/code> which will align the items inside the flex container or flex line in a multi-line flex container. If you have a multi-line container using <code>flex-wrap: wrap<\/code> <em>and<\/em> have space in that container, you can use <code>align-content<\/code> to distribute the space on the cross axis.<\/p>\n<p>In the example below, we are doing both with a flex container displayed as a row and a column:<\/p>\n<p data-height=\"500\" data-theme-id=\"light\" data-slug-hash=\"mogqLP\" data-user=\"rachelandrew\" data-default-tab=\"result\">See the Pen <a href=\"https:\/\/www.smashingmagazine.com\/articles\/\">Cross axis alignment in Flexbox<\/a> by <a href=\"https:\/\/codepen.io\/rachelandrew\">Rachel Andrew<\/a>.<\/p>\n<h3>When <code>justify-content<\/code> Or <code>align-content<\/code> Do Not Work<\/h3>\n<p>The <code>justify-content<\/code> and <code>align-content<\/code> properties in Grid and Flexbox are about <strong>distributing extra space<\/strong>. So the thing to check is that you have extra space.<\/p>\n<p>Here is a Flex example: I have set <code>flex-direction: row<\/code> and I have three items. They don\u2019t take up all of the space in the flex container, so I have spare space on the main axis, the initial value for <code>justify-content<\/code> is <code>flex-start<\/code> and so my items all line up at the start and the extra space is at the end. I am using the Firefox Flex Inspector to highlight the space.<\/p>\n<figure><a href=\"https:\/\/i0.wp.com\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/7078b4f1-0270-4dff-874c-8cb9e9016976\/sm-align-spare-space-end.png?ssl=1\"><br \/>\n\t\t<img data-recalc-dims=\"1\" decoding=\"async\" srcset=\"http:\/\/www.taterboy.com\/blog\/wp-content\/uploads\/2019\/03\/sm-align-spare-space-end.png 400w,\n\t\t\t        https:\/\/res.cloudinary.com\/indysigner\/image\/fetch\/f_auto,q_auto\/w_800\/https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/7078b4f1-0270-4dff-874c-8cb9e9016976\/sm-align-spare-space-end.png 800w,\n\t\t\t        https:\/\/res.cloudinary.com\/indysigner\/image\/fetch\/f_auto,q_auto\/w_1200\/https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/7078b4f1-0270-4dff-874c-8cb9e9016976\/sm-align-spare-space-end.png 1200w,\n\t\t\t        https:\/\/res.cloudinary.com\/indysigner\/image\/fetch\/f_auto,q_auto\/w_1600\/https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/7078b4f1-0270-4dff-874c-8cb9e9016976\/sm-align-spare-space-end.png 1600w,\n\t\t\t        https:\/\/res.cloudinary.com\/indysigner\/image\/fetch\/f_auto,q_auto\/w_2000\/https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/7078b4f1-0270-4dff-874c-8cb9e9016976\/sm-align-spare-space-end.png 2000w\" src=\"https:\/\/i0.wp.com\/www.taterboy.com\/blog\/wp-content\/uploads\/2019\/03\/sm-align-spare-space-end.png?w=900\" sizes=\"100vw\" alt=\"Flex items aligned left, highlighted spare space on the right\"><\/a><figcaption>\n\t\t\tThe spare space at the end of the container (<a href=\"https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/7078b4f1-0270-4dff-874c-8cb9e9016976\/sm-align-spare-space-end.png\">Large preview<\/a>)<br \/>\n\t\t<\/figcaption><\/figure>\n<p>If I change flex-direction to <code>space-between<\/code>, that extra space is now distributed between the items:<\/p>\n<figure><a href=\"https:\/\/i0.wp.com\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/19c263bf-f567-445e-aa83-a101399f0130\/sm-align-spare-space-between.png?ssl=1\"><br \/>\n\t\t<img data-recalc-dims=\"1\" decoding=\"async\" srcset=\"http:\/\/www.taterboy.com\/blog\/wp-content\/uploads\/2019\/03\/sm-align-spare-space-between.png 400w,\n\t\t\t        https:\/\/res.cloudinary.com\/indysigner\/image\/fetch\/f_auto,q_auto\/w_800\/https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/19c263bf-f567-445e-aa83-a101399f0130\/sm-align-spare-space-between.png 800w,\n\t\t\t        https:\/\/res.cloudinary.com\/indysigner\/image\/fetch\/f_auto,q_auto\/w_1200\/https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/19c263bf-f567-445e-aa83-a101399f0130\/sm-align-spare-space-between.png 1200w,\n\t\t\t        https:\/\/res.cloudinary.com\/indysigner\/image\/fetch\/f_auto,q_auto\/w_1600\/https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/19c263bf-f567-445e-aa83-a101399f0130\/sm-align-spare-space-between.png 1600w,\n\t\t\t        https:\/\/res.cloudinary.com\/indysigner\/image\/fetch\/f_auto,q_auto\/w_2000\/https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/19c263bf-f567-445e-aa83-a101399f0130\/sm-align-spare-space-between.png 2000w\" src=\"https:\/\/i0.wp.com\/www.taterboy.com\/blog\/wp-content\/uploads\/2019\/03\/sm-align-spare-space-between.png?w=900\" sizes=\"100vw\" alt=\"Flex items aligned so space is distributed between the items\"><\/a><figcaption>\n\t\t\tThe spare space is now between the items (<a href=\"https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/19c263bf-f567-445e-aa83-a101399f0130\/sm-align-spare-space-between.png\">Large preview<\/a>)<br \/>\n\t\t<\/figcaption><\/figure>\n<p>If I now add more content to my items so they become larger and there is no longer any additional space, then <code>justify-content<\/code> does nothing \u2014 simply because there is no space to distribute.<\/p>\n<figure><a href=\"https:\/\/i0.wp.com\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/2e170401-a58d-4fdf-acfe-dacb6f30bb94\/sm-align-no-space.png?ssl=1\"><br \/>\n\t\t<img data-recalc-dims=\"1\" decoding=\"async\" srcset=\"http:\/\/www.taterboy.com\/blog\/wp-content\/uploads\/2019\/03\/sm-align-no-space.png 400w,\n\t\t\t        https:\/\/res.cloudinary.com\/indysigner\/image\/fetch\/f_auto,q_auto\/w_800\/https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/2e170401-a58d-4fdf-acfe-dacb6f30bb94\/sm-align-no-space.png 800w,\n\t\t\t        https:\/\/res.cloudinary.com\/indysigner\/image\/fetch\/f_auto,q_auto\/w_1200\/https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/2e170401-a58d-4fdf-acfe-dacb6f30bb94\/sm-align-no-space.png 1200w,\n\t\t\t        https:\/\/res.cloudinary.com\/indysigner\/image\/fetch\/f_auto,q_auto\/w_1600\/https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/2e170401-a58d-4fdf-acfe-dacb6f30bb94\/sm-align-no-space.png 1600w,\n\t\t\t        https:\/\/res.cloudinary.com\/indysigner\/image\/fetch\/f_auto,q_auto\/w_2000\/https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/2e170401-a58d-4fdf-acfe-dacb6f30bb94\/sm-align-no-space.png 2000w\" src=\"https:\/\/i0.wp.com\/www.taterboy.com\/blog\/wp-content\/uploads\/2019\/03\/sm-align-no-space.png?w=900\" sizes=\"100vw\" alt=\"Flex items are filling the container with no spare space\"><\/a><figcaption>\n\t\t\tThere is now no space to distribute (<a href=\"https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/2e170401-a58d-4fdf-acfe-dacb6f30bb94\/sm-align-no-space.png\">Large preview<\/a>)<br \/>\n\t\t<\/figcaption><\/figure>\n<p>A common question I\u2019m asked is why <code>justify-content<\/code> isn\u2019t working when <code>flex-direction<\/code> is <code>column<\/code>. This is generally because there is no space to distribute. If you take the above example and make it <code>flex-direction: column<\/code>, the items will display as a column, but there will be no additional space below the items as there is when you do <code>flex-direction: row<\/code>. This is because when you make a Flex Container with <code>display: flex<\/code> you have a block level flex container; this will take up all possible space in the inline direction. In CSS, things do not stretch in the block direction, so no extra space.<\/p>\n<figure><a href=\"https:\/\/i0.wp.com\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/218248c5-1b58-4a15-a478-058df4b07369\/sm-align-column-no-space.png?ssl=1\"><br \/>\n\t\t<img data-recalc-dims=\"1\" decoding=\"async\" srcset=\"http:\/\/www.taterboy.com\/blog\/wp-content\/uploads\/2019\/03\/sm-align-column-no-space.png 400w,\n\t\t\t        https:\/\/res.cloudinary.com\/indysigner\/image\/fetch\/f_auto,q_auto\/w_800\/https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/218248c5-1b58-4a15-a478-058df4b07369\/sm-align-column-no-space.png 800w,\n\t\t\t        https:\/\/res.cloudinary.com\/indysigner\/image\/fetch\/f_auto,q_auto\/w_1200\/https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/218248c5-1b58-4a15-a478-058df4b07369\/sm-align-column-no-space.png 1200w,\n\t\t\t        https:\/\/res.cloudinary.com\/indysigner\/image\/fetch\/f_auto,q_auto\/w_1600\/https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/218248c5-1b58-4a15-a478-058df4b07369\/sm-align-column-no-space.png 1600w,\n\t\t\t        https:\/\/res.cloudinary.com\/indysigner\/image\/fetch\/f_auto,q_auto\/w_2000\/https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/218248c5-1b58-4a15-a478-058df4b07369\/sm-align-column-no-space.png 2000w\" src=\"https:\/\/i0.wp.com\/www.taterboy.com\/blog\/wp-content\/uploads\/2019\/03\/sm-align-column-no-space.png?w=900\" sizes=\"100vw\" alt=\"Flex items arranged as a column\"><\/a><figcaption>\n\t\t\tThe column is only as tall as needed to display the items (<a href=\"https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/218248c5-1b58-4a15-a478-058df4b07369\/sm-align-column-no-space.png\">Large preview<\/a>)<br \/>\n\t\t<\/figcaption><\/figure>\n<p>Add a height to the container and \u2014 as long as that is more than is required to display the items \u2014 you have extra space and therefore <code>justify-content<\/code> will work on your column.<\/p>\n<figure><a href=\"https:\/\/i0.wp.com\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/4a2ef53a-540b-406e-98d2-fd5ed0be49bd\/sm-align-column-space-between.png?ssl=1\"><br \/>\n\t\t<img data-recalc-dims=\"1\" decoding=\"async\" srcset=\"http:\/\/www.taterboy.com\/blog\/wp-content\/uploads\/2019\/03\/sm-align-column-space-between.png 400w,\n\t\t\t        https:\/\/res.cloudinary.com\/indysigner\/image\/fetch\/f_auto,q_auto\/w_800\/https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/4a2ef53a-540b-406e-98d2-fd5ed0be49bd\/sm-align-column-space-between.png 800w,\n\t\t\t        https:\/\/res.cloudinary.com\/indysigner\/image\/fetch\/f_auto,q_auto\/w_1200\/https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/4a2ef53a-540b-406e-98d2-fd5ed0be49bd\/sm-align-column-space-between.png 1200w,\n\t\t\t        https:\/\/res.cloudinary.com\/indysigner\/image\/fetch\/f_auto,q_auto\/w_1600\/https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/4a2ef53a-540b-406e-98d2-fd5ed0be49bd\/sm-align-column-space-between.png 1600w,\n\t\t\t        https:\/\/res.cloudinary.com\/indysigner\/image\/fetch\/f_auto,q_auto\/w_2000\/https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/4a2ef53a-540b-406e-98d2-fd5ed0be49bd\/sm-align-column-space-between.png 2000w\" src=\"https:\/\/i0.wp.com\/www.taterboy.com\/blog\/wp-content\/uploads\/2019\/03\/sm-align-column-space-between.png?w=900\" sizes=\"100vw\" alt=\"A column of flex items with space between them.\"><\/a><figcaption>\n\t\t\tAdding a height to the container means we have spare space (<a href=\"https:\/\/cloud.netlifyusercontent.com\/assets\/344dbf88-fdf9-42bb-adb4-46f01eedd629\/4a2ef53a-540b-406e-98d2-fd5ed0be49bd\/sm-align-column-space-between.png\">Large preview<\/a>)<br \/>\n\t\t<\/figcaption><\/figure>\n<h3>Why Is There No <code>justify-self<\/code> In Flexbox?<\/h3>\n<p>Grid Layout implements all of the properties for both axes because we always have two axes to deal with in Grid Layout. We create tracks (which may leave additional space in the grid container in either dimension,) and so we can distribute that space with <code>align-content<\/code> or <code>justify-content<\/code>. We also have Grid Areas, and the element in that area may not take up the full space of the area, so we can use <code>align-self<\/code> or <code>justify-self<\/code> to move the content around the area (or <code>align-items<\/code>, <code>justify-items<\/code> to change the alignment of all items).<\/p>\n<p>Flexbox does not have tracks in the way that Grid layout does. On the main axis, all we have to play with is the distribution of space between the items. There is no concept of a track into which a flex item is placed. So there is no area created in which to move the item around in. This is why there is no <code>justify-self<\/code> property on the main axes in Flexbox.<\/p>\n<p>Sometimes, however, you do want to be able to align one item or part of the group of items in a different way. A common pattern would be a split navigation bar with one item being separated out from the group. In that situation, the specification advises the use of auto margins.<\/p>\n<p>An auto margin will take up all of the space in the direction it is applied, which is why we can center a block (such as our main page layout) using a left and right margin of auto. With an auto margin on both sides, each margin tries to take up all the space and so pushes the block into the middle. With our row of flex items, we can add <code>margin-left: auto<\/code> to the item we want the split to happen on, and as long as there is available space in the flex container, you get a split. This plays nicely with Flexbox because as soon as there is no available space, the items behave as regular flex items do.<\/p>\n<div>\n<p data-height=\"500\" data-theme-id=\"light\" data-slug-hash=\"wOZmBG\" data-user=\"rachelandrew\" data-default-tab=\"result\">See the Pen <a href=\"https:\/\/www.smashingmagazine.com\/articles\/\">Alignment with auto margins<\/a> by <a href=\"https:\/\/codepen.io\/rachelandrew\">Rachel Andrew<\/a>.<\/p>\n<\/div>\n<h3>Flexbox And Micro-Components<\/h3>\n<p>One of the things I think is often overlooked is how useful Flexbox is for doing tiny layout jobs, where you might think that using <code>vertical-align<\/code> is the way to go. I often use Flexbox to get neat alignment of small patterns; for example, aligning an icon next to text, baseline aligning two things with different font sizes, or making form fields and buttons line up properly. If you are struggling to get something to line up nicely with <code>vertical-align<\/code>, then perhaps try doing the job with Flexbox. Remember that you can also create an inline flex container if you want with <code>display: inline-flex<\/code>.<\/p>\n<div>\n<p data-height=\"500\" data-theme-id=\"light\" data-slug-hash=\"aMxYWQ\" data-user=\"rachelandrew\" data-default-tab=\"result\">See the Pen <a href=\"https:\/\/www.smashingmagazine.com\/articles\/\">inline-flex example<\/a> by <a href=\"https:\/\/codepen.io\/rachelandrew\">Rachel Andrew<\/a>.<\/p>\n<\/div>\n<p>There is no reason not to use Flexbox, or even Grid for tiny layout jobs. They aren\u2019t just for big chunks of layout. Try the different things available to you, and see what works best.<\/p>\n<p>People are often very keen to know what the right or wrong way to do things is. In reality, there often is no right or wrong; a small difference in your pattern might mean the difference between Flexbox working best, where otherwise you would use <code>vertical-align<\/code>.<\/p>\n<h3>Wrapping Up<\/h3>\n<p>To wrap up, I have a quick summary of the basics of alignment. If you remember these few rules, you should be able to align most things with CSS:<\/p>\n<ol>\n<li>Are you aligning text or an inline element? If so, you need to use <code>text-align<\/code>, <code>vertical-align<\/code>, and <code>line-height<\/code>.<\/li>\n<li>Do you have an item or items you want to align in the center of the page or container? If so, make the container a flex container then set <code>align-items: center<\/code> and <code>justify-content: center<\/code>.<\/li>\n<li>For Grid Layouts, the properties that start with <code>align-<\/code> work in the Block direction; those which start with <code>justify-<\/code> work in the inline direction.<\/li>\n<li>For Flex Layouts, the properties that start with <code>align-<\/code> work on the Cross Axis; those which start with <code>justify-<\/code> work on the main axis.<\/li>\n<li>The <code>justify-content<\/code> and <code>align-content<\/code> properties distribute extra space. If you have no extra space in your flex or grid container, they will do nothing.<\/li>\n<li>If you think you need <code>justify-self<\/code> in Flexbox, then using an auto margin will probably give you the pattern you are after.<\/li>\n<li>You can use Grid and Flexbox along with the alignment properties for tiny layout jobs as well as main components \u2014 experiment!<\/li>\n<\/ol>\n<p>For more information about alignment, see these resources:<\/p>\n<ul>\n<li><a href=\"https:\/\/developer.mozilla.org\/en-US\/docs\/Web\/CSS\/CSS_Box_Alignment\">CSS Box Alignment (MDN web docs)<\/a><\/li>\n<li><a href=\"https:\/\/www.smashingmagazine.com\/2018\/08\/flexbox-alignment\/\">Everything You Need To Know About Alignment In Flexbox<\/a><\/li>\n<li><a href=\"https:\/\/rachelandrew.co.uk\/css\/cheatsheets\/box-alignment\">Box Alignment Cheatsheet<\/a><\/li>\n<\/ul>\n<div>\n  <img data-recalc-dims=\"1\" decoding=\"async\" src=\"https:\/\/i0.wp.com\/www.taterboy.com\/blog\/wp-content\/uploads\/2019\/03\/logo-red-21.png?w=900\" alt=\"Smashing Editorial\"><span>(il)<\/span>\n<\/div>\n<\/article>\n<p class=\"wpematico_credit\"><small>Powered by <a href=\"http:\/\/www.wpematico.com\" target=\"_blank\">WPeMatico<\/a><\/small><\/p>\n","protected":false},"excerpt":{"rendered":"<p>How To Align Things In CSS How To Align Things In CSS Rachel Andrew 2019-03-28T12:30:41+01:002019-03-29T11:05:55+00:00 We have a whole selection of ways to align things in CSS today, and it isn\u2019t always an obvious decision which to use. However, knowing what is available means that you can always try a few tactics if you come&#8230;<a class=\"moretag\" href=\"https:\/\/www.taterboy.com\/blog\/2019\/03\/how-to-align-things-in-css\/\"> Read the full article&#8230;<\/a><\/p>\n","protected":false},"author":4,"featured_media":62600,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_jetpack_newsletter_access":"","_jetpack_dont_email_post_to_subs":false,"_jetpack_newsletter_tier_id":0,"_jetpack_memberships_contains_paywalled_content":false,"_jetpack_feature_clip_id":0,"_jetpack_memberships_contains_paid_content":false,"footnotes":"","jetpack_publicize_message":"","jetpack_publicize_feature_enabled":true,"jetpack_social_post_already_shared":true,"jetpack_social_options":{"image_generator_settings":{"template":"highway","default_image_id":0,"font":"","enabled":false},"version":2},"jetpack_post_was_ever_published":false},"categories":[371],"tags":[],"class_list":["post-62599","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-user-experience"],"aioseo_notices":[],"aioseo_head":"\n\t\t<!-- All in One SEO 5.0.0.1 - aioseo.com -->\n\t<meta name=\"description\" content=\"How To Align Things In CSSHow To Align Things In CSS Rachel Andrew 2019-03-28T12:30:41+01:002019-03-29T11:05:55+00:00We have a whole selection of ways to align things in CSS today, and it isn\u2019t always an obvious decision which to use. However, knowing what is available means that you can always try a few tactics if you come across a\" \/>\n\t<meta name=\"robots\" content=\"max-image-preview:large\" \/>\n\t<meta name=\"author\" content=\"Guest Contribution\"\/>\n\t<meta name=\"keywords\" content=\"user experience\" \/>\n\t<link rel=\"canonical\" href=\"https:\/\/www.taterboy.com\/blog\/2019\/03\/how-to-align-things-in-css\/\" \/>\n\t<meta name=\"generator\" content=\"All in One SEO (AIOSEO) 5.0.0.1\" \/>\n\t\t<meta property=\"og:locale\" content=\"en_US\" \/>\n\t\t<meta property=\"og:site_name\" content=\"Design for Immersive Technologies | User Experience for Games, Virtual Reality (VR) and Augmented\/Mixed Reality (AR\/MR)\" \/>\n\t\t<meta property=\"og:type\" content=\"article\" \/>\n\t\t<meta property=\"og:title\" content=\"How To Align Things In CSS | Design for Immersive Technologies\" \/>\n\t\t<meta property=\"og:description\" content=\"How To Align Things In CSSHow To Align Things In CSS Rachel Andrew 2019-03-28T12:30:41+01:002019-03-29T11:05:55+00:00We have a whole selection of ways to align things in CSS today, and it isn\u2019t always an obvious decision which to use. However, knowing what is available means that you can always try a few tactics if you come across a\" \/>\n\t\t<meta property=\"og:url\" content=\"https:\/\/www.taterboy.com\/blog\/2019\/03\/how-to-align-things-in-css\/\" \/>\n\t\t<meta property=\"article:published_time\" content=\"2019-03-29T11:15:37+00:00\" \/>\n\t\t<meta property=\"article:modified_time\" content=\"2019-03-29T11:15:37+00:00\" \/>\n\t\t<meta name=\"twitter:card\" content=\"summary\" \/>\n\t\t<meta name=\"twitter:title\" content=\"How To Align Things In CSS | Design for Immersive Technologies\" \/>\n\t\t<meta name=\"twitter:description\" content=\"How To Align Things In CSSHow To Align Things In CSS Rachel Andrew 2019-03-28T12:30:41+01:002019-03-29T11:05:55+00:00We have a whole selection of ways to align things in CSS today, and it isn\u2019t always an obvious decision which to use. However, knowing what is available means that you can always try a few tactics if you come across a\" \/>\n\t\t<script type=\"application\/ld+json\" class=\"aioseo-schema\">\n\t\t\t{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/2019\\\/03\\\/how-to-align-things-in-css\\\/#article\",\"name\":\"How To Align Things In CSS | Design for Immersive Technologies\",\"headline\":\"How To Align Things In CSS\",\"author\":{\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/author\\\/guestcontribution\\\/#author\"},\"publisher\":{\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/#organization\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/www.taterboy.com\\\/blog\\\/wp-content\\\/uploads\\\/2019\\\/03\\\/sm-align-flex-self-alignment.png?fit=400%2C162&ssl=1\",\"width\":400,\"height\":162},\"datePublished\":\"2019-03-29T04:15:37-07:00\",\"dateModified\":\"2019-03-29T04:15:37-07:00\",\"inLanguage\":\"en-US\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/2019\\\/03\\\/how-to-align-things-in-css\\\/#webpage\"},\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/2019\\\/03\\\/how-to-align-things-in-css\\\/#webpage\"},\"articleSection\":\"User Experience\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/2019\\\/03\\\/how-to-align-things-in-css\\\/#breadcrumblist\",\"itemListElement\":[{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog#listItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.taterboy.com\\\/blog\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/category\\\/user-experience\\\/#listItem\",\"name\":\"User Experience\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/category\\\/user-experience\\\/#listItem\",\"position\":2,\"name\":\"User Experience\",\"item\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/category\\\/user-experience\\\/\",\"nextItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/2019\\\/03\\\/how-to-align-things-in-css\\\/#listItem\",\"name\":\"How To Align Things In CSS\"},\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog#listItem\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/2019\\\/03\\\/how-to-align-things-in-css\\\/#listItem\",\"position\":3,\"name\":\"How To Align Things In CSS\",\"previousItem\":{\"@type\":\"ListItem\",\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/category\\\/user-experience\\\/#listItem\",\"name\":\"User Experience\"}}]},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/#organization\",\"name\":\"Design for Immersive Technologies\",\"description\":\"User Experience for Games, Virtual Reality (VR) and Augmented\\\/Mixed Reality (AR\\\/MR)\",\"url\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/\"},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/author\\\/guestcontribution\\\/#author\",\"url\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/author\\\/guestcontribution\\\/\",\"name\":\"Guest Contribution\",\"image\":{\"@type\":\"ImageObject\",\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/2019\\\/03\\\/how-to-align-things-in-css\\\/#authorImage\",\"url\":\"https:\\\/\\\/secure.gravatar.com\\\/avatar\\\/d2aad73eb0f48c67b141e9fc978a0e498969791ed623346e361d02d19775b0bb?s=96&d=mm&r=g\",\"width\":96,\"height\":96,\"caption\":\"Guest Contribution\"}},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/2019\\\/03\\\/how-to-align-things-in-css\\\/#webpage\",\"url\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/2019\\\/03\\\/how-to-align-things-in-css\\\/\",\"name\":\"How To Align Things In CSS | Design for Immersive Technologies\",\"description\":\"How To Align Things In CSSHow To Align Things In CSS Rachel Andrew 2019-03-28T12:30:41+01:002019-03-29T11:05:55+00:00We have a whole selection of ways to align things in CSS today, and it isn\\u2019t always an obvious decision which to use. However, knowing what is available means that you can always try a few tactics if you come across a\",\"inLanguage\":\"en-US\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/#website\"},\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/2019\\\/03\\\/how-to-align-things-in-css\\\/#breadcrumblist\"},\"author\":{\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/author\\\/guestcontribution\\\/#author\"},\"creator\":{\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/author\\\/guestcontribution\\\/#author\"},\"image\":{\"@type\":\"ImageObject\",\"url\":\"https:\\\/\\\/i0.wp.com\\\/www.taterboy.com\\\/blog\\\/wp-content\\\/uploads\\\/2019\\\/03\\\/sm-align-flex-self-alignment.png?fit=400%2C162&ssl=1\",\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/2019\\\/03\\\/how-to-align-things-in-css\\\/#mainImage\",\"width\":400,\"height\":162},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/2019\\\/03\\\/how-to-align-things-in-css\\\/#mainImage\"},\"datePublished\":\"2019-03-29T04:15:37-07:00\",\"dateModified\":\"2019-03-29T04:15:37-07:00\"},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/\",\"name\":\"Design for Immersive Technologies\",\"description\":\"User Experience for Games, Virtual Reality (VR) and Augmented\\\/Mixed Reality (AR\\\/MR)\",\"inLanguage\":\"en-US\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.taterboy.com\\\/blog\\\/#organization\"}}]}\n\t\t<\/script>\n\t\t<!-- All in One SEO -->\n\n","aioseo_head_json":{"title":"How To Align Things In CSS | Design for Immersive Technologies","description":"How To Align Things In CSSHow To Align Things In CSS Rachel Andrew 2019-03-28T12:30:41+01:002019-03-29T11:05:55+00:00We have a whole selection of ways to align things in CSS today, and it isn\u2019t always an obvious decision which to use. However, knowing what is available means that you can always try a few tactics if you come across a","canonical_url":"https:\/\/www.taterboy.com\/blog\/2019\/03\/how-to-align-things-in-css\/","robots":"max-image-preview:large","keywords":"user experience","webmasterTools":{"miscellaneous":""},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.taterboy.com\/blog\/2019\/03\/how-to-align-things-in-css\/#article","name":"How To Align Things In CSS | Design for Immersive Technologies","headline":"How To Align Things In CSS","author":{"@id":"https:\/\/www.taterboy.com\/blog\/author\/guestcontribution\/#author"},"publisher":{"@id":"https:\/\/www.taterboy.com\/blog\/#organization"},"image":{"@type":"ImageObject","url":"https:\/\/i0.wp.com\/www.taterboy.com\/blog\/wp-content\/uploads\/2019\/03\/sm-align-flex-self-alignment.png?fit=400%2C162&ssl=1","width":400,"height":162},"datePublished":"2019-03-29T04:15:37-07:00","dateModified":"2019-03-29T04:15:37-07:00","inLanguage":"en-US","mainEntityOfPage":{"@id":"https:\/\/www.taterboy.com\/blog\/2019\/03\/how-to-align-things-in-css\/#webpage"},"isPartOf":{"@id":"https:\/\/www.taterboy.com\/blog\/2019\/03\/how-to-align-things-in-css\/#webpage"},"articleSection":"User Experience"},{"@type":"BreadcrumbList","@id":"https:\/\/www.taterboy.com\/blog\/2019\/03\/how-to-align-things-in-css\/#breadcrumblist","itemListElement":[{"@type":"ListItem","@id":"https:\/\/www.taterboy.com\/blog#listItem","position":1,"name":"Home","item":"https:\/\/www.taterboy.com\/blog","nextItem":{"@type":"ListItem","@id":"https:\/\/www.taterboy.com\/blog\/category\/user-experience\/#listItem","name":"User Experience"}},{"@type":"ListItem","@id":"https:\/\/www.taterboy.com\/blog\/category\/user-experience\/#listItem","position":2,"name":"User Experience","item":"https:\/\/www.taterboy.com\/blog\/category\/user-experience\/","nextItem":{"@type":"ListItem","@id":"https:\/\/www.taterboy.com\/blog\/2019\/03\/how-to-align-things-in-css\/#listItem","name":"How To Align Things In CSS"},"previousItem":{"@type":"ListItem","@id":"https:\/\/www.taterboy.com\/blog#listItem","name":"Home"}},{"@type":"ListItem","@id":"https:\/\/www.taterboy.com\/blog\/2019\/03\/how-to-align-things-in-css\/#listItem","position":3,"name":"How To Align Things In CSS","previousItem":{"@type":"ListItem","@id":"https:\/\/www.taterboy.com\/blog\/category\/user-experience\/#listItem","name":"User Experience"}}]},{"@type":"Organization","@id":"https:\/\/www.taterboy.com\/blog\/#organization","name":"Design for Immersive Technologies","description":"User Experience for Games, Virtual Reality (VR) and Augmented\/Mixed Reality (AR\/MR)","url":"https:\/\/www.taterboy.com\/blog\/"},{"@type":"Person","@id":"https:\/\/www.taterboy.com\/blog\/author\/guestcontribution\/#author","url":"https:\/\/www.taterboy.com\/blog\/author\/guestcontribution\/","name":"Guest Contribution","image":{"@type":"ImageObject","@id":"https:\/\/www.taterboy.com\/blog\/2019\/03\/how-to-align-things-in-css\/#authorImage","url":"https:\/\/secure.gravatar.com\/avatar\/d2aad73eb0f48c67b141e9fc978a0e498969791ed623346e361d02d19775b0bb?s=96&d=mm&r=g","width":96,"height":96,"caption":"Guest Contribution"}},{"@type":"WebPage","@id":"https:\/\/www.taterboy.com\/blog\/2019\/03\/how-to-align-things-in-css\/#webpage","url":"https:\/\/www.taterboy.com\/blog\/2019\/03\/how-to-align-things-in-css\/","name":"How To Align Things In CSS | Design for Immersive Technologies","description":"How To Align Things In CSSHow To Align Things In CSS Rachel Andrew 2019-03-28T12:30:41+01:002019-03-29T11:05:55+00:00We have a whole selection of ways to align things in CSS today, and it isn\u2019t always an obvious decision which to use. However, knowing what is available means that you can always try a few tactics if you come across a","inLanguage":"en-US","isPartOf":{"@id":"https:\/\/www.taterboy.com\/blog\/#website"},"breadcrumb":{"@id":"https:\/\/www.taterboy.com\/blog\/2019\/03\/how-to-align-things-in-css\/#breadcrumblist"},"author":{"@id":"https:\/\/www.taterboy.com\/blog\/author\/guestcontribution\/#author"},"creator":{"@id":"https:\/\/www.taterboy.com\/blog\/author\/guestcontribution\/#author"},"image":{"@type":"ImageObject","url":"https:\/\/i0.wp.com\/www.taterboy.com\/blog\/wp-content\/uploads\/2019\/03\/sm-align-flex-self-alignment.png?fit=400%2C162&ssl=1","@id":"https:\/\/www.taterboy.com\/blog\/2019\/03\/how-to-align-things-in-css\/#mainImage","width":400,"height":162},"primaryImageOfPage":{"@id":"https:\/\/www.taterboy.com\/blog\/2019\/03\/how-to-align-things-in-css\/#mainImage"},"datePublished":"2019-03-29T04:15:37-07:00","dateModified":"2019-03-29T04:15:37-07:00"},{"@type":"WebSite","@id":"https:\/\/www.taterboy.com\/blog\/#website","url":"https:\/\/www.taterboy.com\/blog\/","name":"Design for Immersive Technologies","description":"User Experience for Games, Virtual Reality (VR) and Augmented\/Mixed Reality (AR\/MR)","inLanguage":"en-US","publisher":{"@id":"https:\/\/www.taterboy.com\/blog\/#organization"}}]},"og:locale":"en_US","og:site_name":"Design for Immersive Technologies | User Experience for Games, Virtual Reality (VR) and Augmented\/Mixed Reality (AR\/MR)","og:type":"article","og:title":"How To Align Things In CSS | Design for Immersive Technologies","og:description":"How To Align Things In CSSHow To Align Things In CSS Rachel Andrew 2019-03-28T12:30:41+01:002019-03-29T11:05:55+00:00We have a whole selection of ways to align things in CSS today, and it isn\u2019t always an obvious decision which to use. However, knowing what is available means that you can always try a few tactics if you come across a","og:url":"https:\/\/www.taterboy.com\/blog\/2019\/03\/how-to-align-things-in-css\/","article:published_time":"2019-03-29T11:15:37+00:00","article:modified_time":"2019-03-29T11:15:37+00:00","twitter:card":"summary","twitter:title":"How To Align Things In CSS | Design for Immersive Technologies","twitter:description":"How To Align Things In CSSHow To Align Things In CSS Rachel Andrew 2019-03-28T12:30:41+01:002019-03-29T11:05:55+00:00We have a whole selection of ways to align things in CSS today, and it isn\u2019t always an obvious decision which to use. However, knowing what is available means that you can always try a few tactics if you come across a"},"aioseo_meta_data":{"post_id":"62599","title":null,"description":null,"keywords":null,"keyphrases":null,"canonical_url":null,"og_title":null,"og_description":null,"og_object_type":"default","og_image_type":"default","og_image_custom_url":null,"og_image_custom_fields":null,"og_custom_image_width":null,"og_custom_image_height":null,"og_video":null,"og_custom_url":null,"og_article_section":null,"og_article_tags":null,"twitter_use_og":false,"twitter_card":"default","twitter_image_type":"default","twitter_image_custom_url":null,"twitter_image_custom_fields":null,"twitter_title":null,"twitter_description":null,"schema_type":null,"schema_type_options":null,"pillar_content":false,"robots_default":true,"robots_noindex":false,"robots_noarchive":false,"robots_nosnippet":false,"robots_nofollow":false,"robots_noimageindex":false,"robots_noodp":false,"robots_notranslate":false,"robots_max_snippet":null,"robots_max_videopreview":null,"robots_max_imagepreview":"large","priority":null,"frequency":null,"location":null,"local_seo":null,"created":"2021-02-07 21:23:16","updated":"2026-09-01 07:39:52","focus_keyword":null,"additional_keywords":null,"truseo_locale":null,"primary_term":null,"og_image_url":null,"og_image_width":null,"og_image_height":null,"twitter_image_url":null,"schema":{"blockGraphs":[],"customGraphs":[],"default":{"data":{"Article":[],"Course":[],"Dataset":[],"FAQPage":[],"Movie":[],"Person":[],"Product":[],"ProductReview":[],"Car":[],"Recipe":[],"Service":[],"SoftwareApplication":[],"WebPage":[]},"graphName":"Article","isEnabled":true},"graphs":[]},"limit_modified_date":false,"ai":null,"breadcrumb_settings":null,"seo_analyzer_scan_date":null},"aioseo_breadcrumb":"<div class=\"aioseo-breadcrumbs\"><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/www.taterboy.com\/blog\" title=\"Home\">Home<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\t<a href=\"https:\/\/www.taterboy.com\/blog\/category\/user-experience\/\" title=\"User Experience\">User Experience<\/a>\n\t\t<\/span><span class=\"aioseo-breadcrumb-separator\">&raquo;<\/span><span class=\"aioseo-breadcrumb\">\n\t\t\tHow To Align Things In CSS\n\t\t<\/span><\/div>","aioseo_breadcrumb_json":[{"label":"Home","link":"https:\/\/www.taterboy.com\/blog"},{"label":"User Experience","link":"https:\/\/www.taterboy.com\/blog\/category\/user-experience\/"},{"label":"How To Align Things In CSS","link":"https:\/\/www.taterboy.com\/blog\/2019\/03\/how-to-align-things-in-css\/"}],"jetpack_publicize_connections":[],"jetpack_sharing_enabled":true,"jetpack_shortlink":"https:\/\/wp.me\/p8wzr5-ghF","jetpack_featured_media_url":"https:\/\/i0.wp.com\/www.taterboy.com\/blog\/wp-content\/uploads\/2019\/03\/sm-align-flex-self-alignment.png?fit=400%2C162&ssl=1","_links":{"self":[{"href":"https:\/\/www.taterboy.com\/blog\/wp-json\/wp\/v2\/posts\/62599","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.taterboy.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.taterboy.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.taterboy.com\/blog\/wp-json\/wp\/v2\/users\/4"}],"replies":[{"embeddable":true,"href":"https:\/\/www.taterboy.com\/blog\/wp-json\/wp\/v2\/comments?post=62599"}],"version-history":[{"count":0,"href":"https:\/\/www.taterboy.com\/blog\/wp-json\/wp\/v2\/posts\/62599\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.taterboy.com\/blog\/wp-json\/wp\/v2\/media\/62600"}],"wp:attachment":[{"href":"https:\/\/www.taterboy.com\/blog\/wp-json\/wp\/v2\/media?parent=62599"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.taterboy.com\/blog\/wp-json\/wp\/v2\/categories?post=62599"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.taterboy.com\/blog\/wp-json\/wp\/v2\/tags?post=62599"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}