<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Colin Fahrion</title>
    <description>The latest articles on DEV Community by Colin Fahrion (@colinaut).</description>
    <link>https://dev.to/colinaut</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F548867%2F7c1c0494-c951-45fa-8586-eab70e83ae04.jpeg</url>
      <title>DEV Community: Colin Fahrion</title>
      <link>https://dev.to/colinaut</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/colinaut"/>
    <language>en</language>
    <item>
      <title>3 Web UI Design concepts that should be scrapped</title>
      <dc:creator>Colin Fahrion</dc:creator>
      <pubDate>Fri, 09 Apr 2021 22:54:51 +0000</pubDate>
      <link>https://dev.to/colinaut/3-web-ui-design-concepts-that-should-be-scrapped-189g</link>
      <guid>https://dev.to/colinaut/3-web-ui-design-concepts-that-should-be-scrapped-189g</guid>
      <description>&lt;p&gt;I've been making web sites since 1996. The web has changed a lot since then and my position on what makes for a good design has changed a lot over the years. Several things have influenced these shifts: the advancement of technology, the shifts of user habits, and lastly (and least of all) the design fads of the day.&lt;/p&gt;

&lt;p&gt;In my recent post &lt;a href="https://dev.to/colinaut/ok-fine-tailwindcss-rocks-572k"&gt;Ok fine… TailwindCSS rocks!&lt;/a&gt;, I explained why I ditched my long running allegiance to semantic css in favor of Tailwind style utility classes. In this post, I'm going into some web design concepts that have been the de-facto standard for a long time and why they should be scrapped.&lt;/p&gt;

&lt;h2&gt;
  
  
  Carousels
&lt;/h2&gt;

&lt;p&gt;The web is full of carousels. There are numerous javascript libraries out there to implement them and even a few css only experiments. The fact of the matter is the user doesn't care past the first or second slide. Unless you have really engaging content the user has already started scrolling down the page or clicked away before the it's even changed to the second slide. This is doubly true for users on mobile who are primed to just thumb scroll instantly.&lt;/p&gt;

&lt;p&gt;There is only a couple reasons any site might want to consider a carousel:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;A gallery of images&lt;/li&gt;
&lt;li&gt;A product description with feature highlights&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;And even then in most cases you'd be better off just showing the content directly on the page and allow the user to scroll down like they already were planning to. I mean why take the chance that the content on every slide past the first one will be ignored?&lt;/p&gt;

&lt;p&gt;Most sites implement carousels with branding marketing fluff that users gloss over. Since users are likely only going to see the first slide then it's a waste of time to implement more than one. Just focus your message with one big hero section.&lt;/p&gt;

&lt;h2&gt;
  
  
  Hover Dropdown Menus
&lt;/h2&gt;

&lt;p&gt;Hover drop down menus are everywhere. Ever since hover became a thing, it became the standard for how a site structured navigation. There are numerous javascript libraries to that make it easy and even css only solutions.&lt;/p&gt;

&lt;p&gt;They have always had issues however: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If you accidentally hover away from the menu it disappears. There are "hover intent" javascript functions that sorta solve this issue but it always felt like a kludge.&lt;/li&gt;
&lt;li&gt;If your primary nav items are both pages and hover triggers then it can cause UI confusion for users as they may completely miss the fact that they are buttons.&lt;/li&gt;
&lt;li&gt;The last issue is made worse on mobile where there is no hover so click becomes a hover and the user has to click once to expand the subnav and another time to go to that primary page. Since well over 50% of users are on mobile this matters a lot.&lt;/li&gt;
&lt;li&gt;Hover also becomes an accessibility issue for keyboard users where focus replaces hover.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All of this gets 10x worse when a site has nested hover menus. Nested menus in general need to go away but I've always felt that.&lt;/p&gt;

&lt;p&gt;I'm not the only one to see this issue. &lt;a href="https://medium.com/@adambsilver?source=post_page-----b21d6c7de91c--------------------------------"&gt;Adam Silver&lt;/a&gt; wrote about this in his article &lt;a href="https://medium.com/simple-human/why-hover-menus-are-problematic-b21d6c7de91c"&gt;4 reasons why hover menus are problematic&lt;/a&gt; way back in 2015. And &lt;a href="https://uxmovement.com"&gt;UX Movement&lt;/a&gt; wrote about this way way back in 2011: &lt;a href="https://uxmovement.com/navigation/why-hover-menus-do-users-more-harm-than-good/"&gt;Why Hover Menus Do Users More Harm Than Good&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;Every site navigation I develop now either uses a flat navigation that goes directly to a page or uses click button menu. The button doesn't go anywhere and it uses the actual &lt;code&gt;&amp;lt;button&amp;gt;&lt;/code&gt; html element since you get a lot of accessibility for free using it. It's sole purpose is to open a menu that contains a list of links. There are a lot of good examples out there for this technique. This W3C ARIA &lt;a href="https://w3c.github.io/aria-practices/examples/menu-button/menu-button-links.html"&gt;Navigation Menu Button Example&lt;/a&gt; is a good example in pure vanilla js. If you are using React check out this article &lt;a href="https://www.a11ywithlindsey.com/blog/accessible-interactive-components-react"&gt;A Guide to Accessible Interactive Components using React Libraries&lt;/a&gt; or the accessible components from &lt;a href="https://github.com/tailwindlabs/headlessui/blob/main/packages/%40headlessui-react/README.md"&gt;Headless UI&lt;/a&gt;, &lt;a href="https://react-spectrum.adobe.com/react-spectrum/Menu.html"&gt;Adobe Spectrum&lt;/a&gt;, &lt;a href="https://reakit.io/docs/menu/"&gt;Reakit&lt;/a&gt;, &lt;a href="https://chakra-ui.com"&gt;CharkaUI&lt;/a&gt;, or &lt;a href="https://reach.tech/menu-button"&gt;Reach UI&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Fancy Hover Animations
&lt;/h2&gt;

&lt;p&gt;Ok I don't actually think hover animations need to be scrapped completely. Hover animations are fun. Everyone loves them and they can add to usability — for desktop users. However as over 50% of users are on mobile, that means all that work you put into that fancy hover has gone unnoticed and unloved.&lt;/p&gt;

&lt;p&gt;Also hover states can lead to the dreaded sticky hover on mobile devices since mobile devices register a click as a hover. There are &lt;a href="https://www.prowebdesign.ro/how-to-deal-with-hover-on-touch-screen-devices/"&gt;ways around this&lt;/a&gt; but it's something to look out for.&lt;/p&gt;

&lt;p&gt;In my current web design work I use hover animations sparingly and I don't waste too much time on them knowing that most of my users will never see them. If animation is useful for a design, it's better to focus my effort on animations on active state, loading animations, or scroll position animations.&lt;/p&gt;

&lt;p&gt;So that's my thoughts for now. What web UI concepts do you think are no longer a good practice and a waste of your precious development time? Are there any new UI design trends you view as bad ideas?&lt;/p&gt;




&lt;p&gt;Cover Photo by &lt;a href="https://unsplash.com/@neonbrand?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;NeONBRAND&lt;/a&gt; on &lt;a href="https://unsplash.com/s/photos/dumpster?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Unsplash&lt;/a&gt;&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>ux</category>
    </item>
    <item>
      <title>Dark Mode Three Way Switch</title>
      <dc:creator>Colin Fahrion</dc:creator>
      <pubDate>Tue, 30 Mar 2021 01:29:31 +0000</pubDate>
      <link>https://dev.to/colinaut/dark-mode-three-way-switch-40e</link>
      <guid>https://dev.to/colinaut/dark-mode-three-way-switch-40e</guid>
      <description>&lt;p&gt;Dark mode is the new web design hotness. There are a lot of examples of switches out there but most of them are just dual switches — Light/Dark. I wanted to implement a three way switch in the site I am designing: Light/Auto/Dark so that people can choose to lock it in one mode or another or leave it auto so that it adjusts with &lt;code&gt;prefers-color-scheme&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;To implement it, I borrowed some ideas from &lt;a href="https://ghinda.net/css-toggle-switch/"&gt;CSS Toggle Switch&lt;/a&gt; using radio buttons and css to build the toggle. I implemented it in Tailwind with light/dark mode colors provided via css variables. I then wrote some simple vanilla JS to store the add "dark"/"light" class to the body tag and store the state in localStorage.&lt;/p&gt;

&lt;p&gt;I'm pleased with the result. It's simple and clean and ideally should be accessible since it's based in the same technique that CSS Toggle Switch uses (I haven't tested it for accessibility though so no promises).&lt;/p&gt;

&lt;p&gt;Here's my CodePen of it!&lt;/p&gt;

&lt;p&gt;&lt;iframe height="600" src="https://codepen.io/colinaut/embed/dyNpdOV?height=600&amp;amp;default-tab=result&amp;amp;embed-version=2"&gt;
&lt;/iframe&gt;
 &lt;/p&gt;

&lt;p&gt;Cover photo by &lt;a href="https://unsplash.com/@elliottengelmann?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Elliott Engelmann&lt;/a&gt;&lt;/p&gt;

</description>
      <category>css</category>
      <category>javascript</category>
      <category>tailwindcss</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Ok fine… TailwindCSS rocks!</title>
      <dc:creator>Colin Fahrion</dc:creator>
      <pubDate>Fri, 26 Feb 2021 21:33:05 +0000</pubDate>
      <link>https://dev.to/colinaut/ok-fine-tailwindcss-rocks-572k</link>
      <guid>https://dev.to/colinaut/ok-fine-tailwindcss-rocks-572k</guid>
      <description>&lt;h2&gt;
  
  
  Ew this is basically inline styles!
&lt;/h2&gt;

&lt;p&gt;When I first ran across &lt;a href="https://tailwindcss.com/"&gt;TailwindCSS&lt;/a&gt;, I admittedly had an instant guttural dislike. I've been designing and building websites since 1996 — when CSS was just a baby and html tables were the defacto way to lay out sites. …Yes to all you dev newbies, I'm that old. I've had to reboot my skills and best practices several times over the past 25 years.&lt;/p&gt;

&lt;p&gt;I've honestly never much liked any CSS framework. I can see a Bootstrap site from a mile away. I know how CSS works, I've been using CSS for styling and layout since early &lt;a href="http://www.csszengarden.com"&gt;CSS Zen Garden&lt;/a&gt; days. It's often easier for me just code the css myself rather than fight to override the styles the framework provides.&lt;/p&gt;

&lt;p&gt;I've also long been a big proponent of semantic css and the separation of style and markup. That best practice has been engrained in my so long it's become nearly an ethical philosophy. So you can see why I had an instant dislike of Tailwind. It is the complete opposite of those ideals. It's basically a codified inline style system.&lt;/p&gt;

&lt;h2&gt;
  
  
  Questioning my own Best Practices
&lt;/h2&gt;

&lt;p&gt;One thing I've learned however in several times I've had to reboot my web dev skills is that you need to keep an open mind. It pays to learn about the new shiny thing and sometimes you even need to throw out everything you thought you knew. &lt;/p&gt;

&lt;p&gt;I give credit to my inner punk for giving me this perspective – question authority even, and especially, your own inner authority.&lt;/p&gt;

&lt;p&gt;The best practice of semantic CSS and separating style from markup honestly served me well for a long time. I learned how to redesign the look of a site just using css. This paid off a lot over the years in situations where the CMS template engine that spit out the html was a pain to update. I've updated lots of old sites to polished mobile ready sites just by changing the CSS. Give me a good &lt;a href="http://getbem.com/naming/"&gt;BEM&lt;/a&gt; structured html page and I can make it look however you want. Though I've also restyled a lot of sites with shit css naming.&lt;/p&gt;

&lt;h2&gt;
  
  
  CSS Styling Today's Web
&lt;/h2&gt;

&lt;p&gt;Today's web is a different place. Everything is component in which css is usually scoped by default. BEM isn't necessary. Hell a lot of the time you can just ignore class names at all. Svelte and Vue have single file components mean that you can plop the style on the div. And the myriad of CSS-in-JS approaches in React attach the styles directly to the element.&lt;/p&gt;

&lt;p&gt;Building a site or app with scoped using components is great! No longer do I have to worry about naming conflicts or the CSS cascade.&lt;/p&gt;

&lt;h2&gt;
  
  
  How I came around to TailwindCSS
&lt;/h2&gt;

&lt;p&gt;When I first worked with React, I used CSS Modules for my styling. It was how I was used to working with a separate css file — CSS-in-JS felt wrong. Then I tried Svelte. Svelte's single file components are great and simple to work in. The CSS is just there right alongside the markup. I never realized how much context switching between the markup file and the css file slowed me down until then. After working with Svelte I began using CSS-in-JS in my React projects for the same reason. It reduced the context switching.&lt;/p&gt;

&lt;p&gt;Still even though I had adapted there I didn't see the point of Tailwind. I mean I know CSS. Tailwind felt like just a syntax to learn. I read Adam Wathan's long involved post on &lt;a href="https://adamwathan.me/css-utility-classes-and-separation-of-concerns/"&gt;CSS Utility Classes and "Separation of Concerns"&lt;/a&gt;, which made me begin to rethink the issue.&lt;/p&gt;

&lt;p&gt;To get it off my mind I decided it was time to question my own biases. I installed Tailwind Intellisense for VS Code and started up a test project with a starter that included Tailwind (actually it uses &lt;a href="https://windicss.netlify.app"&gt;Windi&lt;/a&gt;, which is a Tailwind compiler). I then started making a basic site, forcing myself to use the utility classes for (most) all of the styling.&lt;/p&gt;

&lt;p&gt;It took a while to get over the learning curve of the Tailwind syntax. Intellisense helped a lot with this but also the syntax is pretty intuitive once I got to using it. After a while, I discovered it was faster using Tailwind classes than writing the css out.&lt;/p&gt;

&lt;p&gt;I realized two things…&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Using a utility css framework pretty much completely gets rid of the issue of context switching. No more looking at another document or even down to the style area of the page like with Svelte. I can see how the element is styled and make changes just on the element itself!&lt;/li&gt;
&lt;li&gt;Another great aspect is that it makes it easier to change from say Svelte to React or 11ty to Gatsby or whatever. Since the styling is embedded with the html I can just copy paste wherever I want. I just need to make sure that Tailwind is integrated and I'm good to go.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;The first advantage is great but the second is what really won me over. I have a couple projects that I'm working on right now that I'm not settled on how I want to build it. But now with Tailwind I don't really care. I can design all the components just with plain html or a simple Svelte app. Then I can easily bring both the html and styling components to Gatsby or Next once I get going with building out the functionality.&lt;/p&gt;

&lt;h2&gt;
  
  
  My new CSS Best Practice
&lt;/h2&gt;

&lt;p&gt;Tailwind is great as you can use as much or as little of it as you want. Tailwind's base css has everything normalized so nothing has any styling. I personally like start with a classless css file for at least some basic typography and form elements. So here's my current best practice:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Set styles for all html elements in a global CSS file using either my own or any of the number of &lt;a href="https://github.com/dbohdan/classless-css"&gt;classless css frameworks&lt;/a&gt;. I personally like to use &lt;a href="https://websemantics.uk/tools/responsive-font-calculator/"&gt;fluid responsive type sizes&lt;/a&gt; here which I set at :root and make sure that all padding/margins/sizes use rem or em.&lt;/li&gt;
&lt;li&gt;Use Tailwind or Windi for styling of layout and components.&lt;/li&gt;
&lt;li&gt;Use component scoped or CSS-in-JS for more complicated styling or where styles change based on functionality. (NOTE: &lt;a href="https://twind.dev"&gt;Twind&lt;/a&gt; aka Tailwind in JS is potentially useful).&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Of course, there are times too where Tailwind is not the best fit — namely if I'm working with a CMS that I don't fully control the templating. My fallback here is a good base classless css framework along with using css custom properties style variables to set up my design system. Level Up Tutorials has a good &lt;a href="https://www.leveluptutorials.com/tutorials/modern-css-design-systems"&gt;Modern CSS Design Systems&lt;/a&gt; course that touches on this approach.&lt;/p&gt;

&lt;p&gt;This is how I'm approaching things now at least. It might very well change once some new better way of working comes along.&lt;/p&gt;

&lt;p&gt;This post turned out to be longer than expected but then as I said I've been at this web game for a long time. I had a lot of thoughts to process and it was good to get them out. Hopefully this helps you on your journey to find your Best Practice!&lt;/p&gt;

</description>
      <category>tailwindcss</category>
      <category>css</category>
    </item>
    <item>
      <title>Multiple CSS Approaches to Responsive Width Centered Containers</title>
      <dc:creator>Colin Fahrion</dc:creator>
      <pubDate>Thu, 18 Feb 2021 23:07:45 +0000</pubDate>
      <link>https://dev.to/colinaut/multiple-css-approaches-to-responsive-width-centered-containers-224h</link>
      <guid>https://dev.to/colinaut/multiple-css-approaches-to-responsive-width-centered-containers-224h</guid>
      <description>&lt;p&gt;Centered column containers are the foundation of almost every website on the internet. The basic approach that everyone knows is the max-width with margin auto approach. Often you see this using pixels.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;max-width: 700px;
margin: 0 auto;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Pro:&lt;/strong&gt; works all the way back to IE7&lt;br&gt;
&lt;strong&gt;Con:&lt;/strong&gt; hard-coded pixel sizes can mess with users who change their default font size. Zoom still works fine though.&lt;/p&gt;

&lt;p&gt;Now that we no longer have to care about old versions of IE, there are several ways to better ways to accomplish a responsive centered columns. &lt;/p&gt;
&lt;h2&gt;
  
  
  Responsive Typography Width
&lt;/h2&gt;

&lt;p&gt;By using a type unit for width we can allow the column to flex with size of the font. This allows us adjust the size by changing the base font size. It also to allows us to easily set column sizes for desired line lengths. &lt;a href="https://typographica.org/typography-books/the-elements-of-typographic-style-4th-edition/"&gt;The Elements of Typographic Style&lt;/a&gt; by Robert Bringhurst recommends no more than 75 characters per line, in &lt;code&gt;ch&lt;/code&gt; this amounts to about 60ch.&lt;/p&gt;
&lt;h3&gt;
  
  
  A Note on ch vs rem or em
&lt;/h3&gt;

&lt;p&gt;Often developers reach for &lt;code&gt;rem&lt;/code&gt; or &lt;code&gt;em&lt;/code&gt; but in for line length sizing the &lt;code&gt;ch&lt;/code&gt; unit works better. The &lt;code&gt;ch&lt;/code&gt; unit is the width of the “0” character is in a given font-family and font-size. Whereas &lt;code&gt;em&lt;/code&gt; and &lt;code&gt;rem&lt;/code&gt; strictly amounts to the font-size and does not take into account the font-family, which is useful to know in the case of condensed or wide fonts. Read &lt;a href="https://meyerweb.com/eric/thoughts/2018/06/28/what-is-the-css-ch-unit/"&gt;What is the CSS ‘ch’ Unit?&lt;/a&gt; by Eric Meyer for a good overview.&lt;/p&gt;

&lt;p&gt;NOTE: IE10-11 computes &lt;code&gt;ch&lt;/code&gt; wrong ignoring the space around the character. So you may need to use &lt;code&gt;rem&lt;/code&gt; or &lt;code&gt;em&lt;/code&gt; instead. 75 characters is about 36em for an average width font.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;max-width: 60ch;
margin: 0 auto;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Pro:&lt;/strong&gt; Width is set variably based on ch which is the width of the "O" of the font-family and font-size. This &lt;br&gt;
&lt;strong&gt;Con:&lt;/strong&gt; IE10/11 measure ch incorrectly so sizes will be smaller.&lt;/p&gt;
&lt;h2&gt;
  
  
  Containers with full width backgrounds
&lt;/h2&gt;

&lt;p&gt;Having a full width background with a centered container for content is a common technique for hero type areas. Typically if you want to do this you need to have a wrapper around your centered container element like so:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.wrapper {
  background: lightcoral;
}

.wrapper &amp;gt; * {
  max-width: 60ch;
  margin: 0 auto;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Pro:&lt;/strong&gt; Works on IE 10 and newer if you use rems&lt;br&gt;
&lt;strong&gt;Con:&lt;/strong&gt; Requires an inner element&lt;/p&gt;
&lt;h2&gt;
  
  
  Full width background using padding with max()
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://css-tricks.com/using-max-for-an-inner-element-max-width/"&gt;This article CSS-Tricks&lt;/a&gt; however has a brilliant technique using padding and the max() css function which does not require an inner element! This simpler approach is great for component style development.&lt;/p&gt;

&lt;p&gt;With the css variables you have a very flexible component that can be resized for various needs.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.wrapper {
  --max-width: 60ch;
  --pad-y: 1rem;  
  --min-gutter: 1rem;
  --bg: lightcoral;
  background: var(--bg);
  padding: var(--pad-y) max(var(--min-gutter), 50vw - var(--max-width) / 2);
}

.wrapper.hero {
--max-width: 100ch;
--min-gutter: 0rem;
--bg: url("hero.jpg") no-repeat cover;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;Pro:&lt;/strong&gt; Works without an inner element!&lt;br&gt;
&lt;strong&gt;Con:&lt;/strong&gt; max() does not work with IE11 or earlier.&lt;/p&gt;
&lt;h2&gt;
  
  
  CSS Flexbox and CSS Grid Wrappers
&lt;/h2&gt;

&lt;p&gt;There are several ways to use CSS Flexbox and CSS Grid for layout — too much to go into in this article honestly. With flexbox you can create multiple columns layouts. With css grid you can create layouts with well &lt;em&gt;grids duh&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;One of interesting technique for centered containers is to use css grid with named grid areas. This allows for a single wrapper with the ability to set widths for different types of child content.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.wrapper {
  --gutter-min: 1rem;
  display: grid;
  grid-template-columns: [start] minmax(var(-gutter-min), 1fr) [hero-start] minmax(0, 1fr) [content-start] minmax(30ch, 60ch) [content-end] minmax(0, 1fr) [hero-end] minmax(var(-gutter-min), 1fr) [end]
}

.wrapper &amp;gt; *,
.wrapper &amp;gt; .content {
   grid-column: content-start / content-end;
}

.wrapper &amp;gt; .hero {
   grid-column: hero-start / hero-end;
}

.wrapper &amp;gt; .full-width {
  grid-column: start / end;
}

&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can even get really complicated using this technique if you want with 12 column grid style layout as Michelle Barker explains in &lt;a href="https://css-tricks.com/super-power-grid-components-with-css-custom-properties/"&gt;Super-Powered Grid Components with CSS Custom Properties&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pro:&lt;/strong&gt; Very flexible as it's CSS Grid &lt;br&gt;
&lt;strong&gt;Cons:&lt;/strong&gt; Obviously does not work with IE11 or earlier. Requires inner element. Grid does not allow margin collapse.&lt;/p&gt;

&lt;p&gt;You can see all these techniques and more on this &lt;a href="https://codepen.io/colinaut/pen/OJbgQrK"&gt;CodePen&lt;/a&gt;!&lt;/p&gt;

&lt;p&gt;What centered container techniques do you reach for? Are there any other techniques you've discovered?&lt;/p&gt;

&lt;p&gt;&lt;em&gt;(Cover photo by &lt;a href="https://unsplash.com/@dmey503?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Dan Meyers&lt;/a&gt;)&lt;/em&gt;&lt;/p&gt;

</description>
      <category>css</category>
      <category>layout</category>
    </item>
  </channel>
</rss>
