<?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: JD Brewer-Hofmann</title>
    <description>The latest articles on DEV Community by JD Brewer-Hofmann (@jdbrewerhofmann).</description>
    <link>https://dev.to/jdbrewerhofmann</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%2F555534%2Ff1bf494d-9407-4d40-b877-c77e9049aaff.jpg</url>
      <title>DEV Community: JD Brewer-Hofmann</title>
      <link>https://dev.to/jdbrewerhofmann</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jdbrewerhofmann"/>
    <language>en</language>
    <item>
      <title>Aria Labels here we come</title>
      <dc:creator>JD Brewer-Hofmann</dc:creator>
      <pubDate>Tue, 06 Apr 2021 16:41:01 +0000</pubDate>
      <link>https://dev.to/jdbrewerhofmann/aria-labels-here-we-come-44lo</link>
      <guid>https://dev.to/jdbrewerhofmann/aria-labels-here-we-come-44lo</guid>
      <description>&lt;p&gt;I recently built an e-commerce site, and I attempted to build a strong accessible foundation along the way. The project is mostly complete, but I thought it was a great opportunity to comb through the project to add aria labels where they are needed.&lt;/p&gt;

&lt;p&gt;I hope this can serve as an introduction to adding aria labels in a React/NextJS project.&lt;/p&gt;

&lt;h2&gt;
  
  
  Landing Page
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqi2vuf59y2ugsoydsqrq.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqi2vuf59y2ugsoydsqrq.gif" alt="landing-page-one"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;On the landing page we have a few items to address. Using Firefox's Accessibility Inspector we can see multiple issues in the header alone. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1oyjylfntu54o38lmryg.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F1oyjylfntu54o38lmryg.png" alt="Screen Shot 2021-04-06 at 11.35.58 AM"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Burger Menu
&lt;/h3&gt;

&lt;p&gt;First and foremost I want to make sure the burger menu is accessible and makes sense to everyone. Adding an aria-label easily removes our warning.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

&amp;lt;button 
  className={ menuOpen ? "burger-btn active" : "burger-btn"}
  onClick={handleMenuToggle}
  aria-label="open main menu"
&amp;gt;


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

&lt;/div&gt;

&lt;p&gt;But, you may notice that this button is a toggle button, so what happens when our menu is open? &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwx81k4rw9iadloahpqwm.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fwx81k4rw9iadloahpqwm.png" alt="Screen Shot 2021-04-06 at 11.42.25 AM"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Our label informs our user that this button will "open main menu". But the menu is already open, and visually we are showing a huge X, so this is rubbish. &lt;/p&gt;

&lt;p&gt;Using the same ternary logic I used for my button className, I can update the aria-label to change based on the state. &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

&amp;lt;button 
  className={ menuOpen ? "burger-btn active" : "burger-btn"}
  onClick={handleMenuToggle}
  aria-label={ menuOpen ? "close main menu" : "open main menu"}
&amp;gt;


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

&lt;/div&gt;

&lt;p&gt;Now our aria label updates with our menu opening and closing. When I use voice-over I hear "open main menu, button" when I apply focus (tab to the button) and when I hit enter, I hear "close main menu" immediately. That worked better than I even though honestly.&lt;/p&gt;

&lt;h3&gt;
  
  
  Page Header
&lt;/h3&gt;

&lt;p&gt;My site title is "C&amp;amp;G", which doubles as a link to the landing page, though I am not sure you'd never know that from the voice over. What I currently hear is "link, C &amp;amp; G". I'm going to add an aria label to this as well.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

&amp;lt;Link href="/"&amp;gt;
  &amp;lt;a aria-label="c &amp;amp; g home page"&amp;gt;C&amp;lt;span&amp;gt;&amp;amp;&amp;lt;/span&amp;gt;G&amp;lt;/a&amp;gt;
&amp;lt;/Link&amp;gt;


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

&lt;/div&gt;

&lt;p&gt;Now I hear "link, c &amp;amp; g home page" when I apply focus to the element. If this link element looks strange, just know I'm using NextJS along with React.&lt;/p&gt;

&lt;h3&gt;
  
  
  Cart Icon
&lt;/h3&gt;

&lt;p&gt;Next up is our cart icon. The code currently reads as such&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

&amp;lt;button 
  className="header-cart"
  onClick={handleCartPreviewClick}
&amp;gt;
  &amp;lt;img className="cart-vector" src="/shopping-cart-vector.png"&amp;gt;&amp;lt;/img&amp;gt;

  {context.contextCart.length &amp;gt; 0 ? 
  &amp;lt;span className="cart-count"&amp;gt; {context.contextCart.length}&amp;lt;/span&amp;gt;
  : null }
&amp;lt;/button&amp;gt;


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

&lt;/div&gt;

&lt;p&gt;I immediately notice some issues. For one, my image tag has no alt attribute. While I'm fixing that, I can add a ternary aria label just like our burger menu button. &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

&amp;lt;button 
  className="header-cart"
  onClick={handleCartPreviewClick}
  aria-label={ cartPreview ? "close shopping cart preview" : "open shopping cart preview" }
&amp;gt;
  &amp;lt;img 
    className="cart-vector" 
    src="/shopping-cart-vector.png"
    alt="shopping cart" 
   /&amp;gt;
{context.contextCart.length &amp;gt; 0 ? 
    &amp;lt;span className="cart-count"&amp;gt;{context.contextCart.length}&amp;lt;/span&amp;gt;
: null }
&amp;lt;/button&amp;gt;


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

&lt;/div&gt;

&lt;p&gt;That solves the same issues I had with my burger menu toggle button. Although when I use the screen reader I only receive information about the image inside the button, or the span when I am first loading the page. I'm not thrilled about that, I'd like to have the number of cart items be relayed somehow. I am going to try to add that into the button's aria label. &lt;/p&gt;

&lt;p&gt;I attempted to interpolate my cart items length into the aria label, but that doesn't work. So I will leave that issue open for now. At least the button instructions make sense now.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;Well addressing only the header took a while, so I will have to write another article detailing the slider on the landing page and digging further into our cart items - which I fear aren't laid out too well.&lt;/p&gt;

&lt;p&gt;If you'd like to see the page as it stands currently or checkout out the code the links are included below.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://candg.netlify.app/" rel="noopener noreferrer"&gt;live page&lt;/a&gt;&lt;br&gt;
&lt;a href="https://github.com/JDHofmann/plugs-frontend" rel="noopener noreferrer"&gt;github repo&lt;/a&gt;&lt;/p&gt;

</description>
      <category>a11y</category>
      <category>html</category>
    </item>
    <item>
      <title>User Prefers Dark Mode/Light Mode</title>
      <dc:creator>JD Brewer-Hofmann</dc:creator>
      <pubDate>Tue, 30 Mar 2021 15:28:15 +0000</pubDate>
      <link>https://dev.to/jdbrewerhofmann/user-prefers-dark-mode-light-mode-afa</link>
      <guid>https://dev.to/jdbrewerhofmann/user-prefers-dark-mode-light-mode-afa</guid>
      <description>&lt;p&gt;This blog covers super basic theming in CSS based on  the user's preferences for light mode or dark mode.&lt;/p&gt;

&lt;h2&gt;
  
  
  CSS variables
&lt;/h2&gt;

&lt;p&gt;If you are unfamiliar with CSS variables, this doubles as an introduction. CSS variables are declared at the top level of our document 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;:root {
  --black: #101010;
  --white: #ffffff;
  --brand: #ff9999;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then we can call the variables for our H1 tag 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;h1 {
  background: var(--white);
  color: var(--black);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Using User Preference and Variables to update our page
&lt;/h2&gt;

&lt;p&gt;Let's start with one element and toggle between dark mode and light mode. Utilizing user preference queries, we can check to see if our user prefers dark mode or light mode. Together with our CSS variables our CSS file will read as&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;:root {
  --black: #101010;
  --white: #ffffff;
  --brand: #ff9999;
}
h1 {
  background: var(--white);
  color: var(--black);
  padding: 5vh 0;
  text-align: center;
  transition: 1s;
}
@media (prefers-color-scheme: dark) {
  h1 {
    background: var(--black);
    color: var(--white);
  }
} 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--T_pzJGZ9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k8t99ivawp75b00fq4vh.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--T_pzJGZ9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k8t99ivawp75b00fq4vh.gif" alt="one" width="478" height="396"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;By adding in a few lines of CSS, our H1 will update when the user changes their preferences. That is super responsive.&lt;/p&gt;

&lt;h2&gt;
  
  
  Extending Into a Whole Theme
&lt;/h2&gt;

&lt;p&gt;Taking the concepts another step, we can refactor our code to change the variables themselves to change if our user prefers dark mode. Then we can use the same CSS variables regardless of user preference.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;:root {
  --background: #ffffff;
  --text: #101010;
  --brand: #ff9999;
}
@media (prefers-color-scheme: dark) {
  :root {
    --background: #101010;
    --text: #ffffff;
  }
}
body {
  background: var(--background);
  color: var(--text);
}
h1 {
  border: 2px solid var(--brand);
  padding: 5vh 0;
  text-align: center;
  transition: 1s;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2gLoeLQP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yci15dj0zm87ldird06r.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2gLoeLQP--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/yci15dj0zm87ldird06r.gif" alt="two" width="492" height="514"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It's basic, but the concept works well, and with little code. If I dig into this further I would work to integrate the brand color in an accessible way beyond a border color. &lt;/p&gt;

</description>
      <category>darkmode</category>
      <category>css</category>
    </item>
    <item>
      <title>Reduce Your Motion - aka maybe users don't like your "cool" animations
</title>
      <dc:creator>JD Brewer-Hofmann</dc:creator>
      <pubDate>Tue, 23 Mar 2021 16:56:41 +0000</pubDate>
      <link>https://dev.to/jdbrewerhofmann/reduce-your-motion-aka-maybe-users-don-t-like-your-cool-animations-2n92</link>
      <guid>https://dev.to/jdbrewerhofmann/reduce-your-motion-aka-maybe-users-don-t-like-your-cool-animations-2n92</guid>
      <description>&lt;p&gt;Some recent additions to CSS media queries include new ways to personalize a users experience based on their preferences. Because you are using CSS, whenever a user changes a preference on their machine, your page can update instant - if you add a touch of code. Seems cool, and accommodating, but it is far more than that. &lt;/p&gt;

&lt;p&gt;Much of the web is designed to grab your attention, but some of that attention grabbing is harmful, or at least irritating. Utilizing these new media queries, developers can now accommodate situations where users prefer dark mode, high contrast, or reduced motion.  &lt;/p&gt;

&lt;p&gt;If you'd like to understand some reasons behind these new preferences I recommend &lt;a href="https://source.opennews.org/articles/motion-sick/"&gt; Your Interactive Makes Me Sick &lt;/a&gt; by Eileen Webb. She explains:&lt;/p&gt;

&lt;p&gt;“The issue usually isn’t the motion itself, or the existence of animation. The problem is a mismatch between my expectations for what I’m going to encounter on a webpage and what actually displays on that page”&lt;/p&gt;

&lt;p&gt;I will focus on one of these new media queries, prefers-reduced-motion. With the prefers-reduced-motion media query, users can request to minimize the amount of non-essential motion the page uses. &lt;/p&gt;

&lt;h2&gt;
  
  
  Transitions
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;body&amp;gt;
   &amp;lt;h1&amp;gt;Prefers Reduced Motion&amp;lt;/h1&amp;gt;
&amp;lt;/body&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;h1{
   background: #202020;
   color: #ffffff;
   padding: 5vh 0;
   text-align: center;
   transition: 1s;
}
h1:hover {
   background: #008888;
}
@media (prefers-reduced-motion) {
   h1 {
       transition: none;
   }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZfS28mHK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hd4spd9p9sbhjp5h01dd.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZfS28mHK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hd4spd9p9sbhjp5h01dd.gif" alt="prefers-reduced-motion-1" width="666" height="774"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In our first example, we have an example of disabling a simple hover transition based on user preference. That is simple enough.&lt;/p&gt;

&lt;h2&gt;
  
  
  Smooth Scrolling
&lt;/h2&gt;

&lt;p&gt;We are all familiar with smooth scrolling, and it’s super common on single page sites where all the content is stacked for easy scrolling through content. Personally, I like the smooth scroll for orienting me on the page, but lots of people don’t, so let’s adjust our code for them too.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;h1 id="home"&amp;gt;Prefers Reduced Motion&amp;lt;/h1&amp;gt;
   &amp;lt;ul&amp;gt;
       &amp;lt;li&amp;gt;&amp;lt;a href="#one"&amp;gt;One&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;
       &amp;lt;li&amp;gt;&amp;lt;a href="#two"&amp;gt;Two&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;
       &amp;lt;li&amp;gt;&amp;lt;a href="#three"&amp;gt;Three&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;
   &amp;lt;/ul&amp;gt;
   &amp;lt;div id="one"&amp;gt;
       &amp;lt;a href="#home"&amp;gt;Home&amp;lt;/a&amp;gt;
       &amp;lt;a href="#two"&amp;gt;Two&amp;lt;/a&amp;gt;
       &amp;lt;a href="#three"&amp;gt;Three&amp;lt;/a&amp;gt;
   &amp;lt;/div&amp;gt;
   &amp;lt;div id="two"&amp;gt;
       &amp;lt;a href="#home"&amp;gt;Home&amp;lt;/a&amp;gt;
       &amp;lt;a href="#one"&amp;gt;One&amp;lt;/a&amp;gt;
       &amp;lt;a href="#three"&amp;gt;Three&amp;lt;/a&amp;gt;
   &amp;lt;/div&amp;gt;
   &amp;lt;div id="three"&amp;gt;
       &amp;lt;a href="#home"&amp;gt;Home&amp;lt;/a&amp;gt;
       &amp;lt;a href="#one"&amp;gt;One&amp;lt;/a&amp;gt;
       &amp;lt;a href="#two"&amp;gt;Two&amp;lt;/a&amp;gt;
   &amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;* {
 scroll-behavior: smooth;
}

a {
 color: #008888;
}

@media (prefers-reduced-motion) {
 * {
   scroll-behavior: auto;
 }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--OF4ns2Mf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xq5dfq5yu6n8nnxgbhye.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--OF4ns2Mf--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/xq5dfq5yu6n8nnxgbhye.gif" alt="prefers-reduced-motion-2" width="666" height="756"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here I prepared a demo page of different menu sections that we can jump between to examine the smooth scroll behavior vs auto behavior. We can see a larger difference for our user here.&lt;/p&gt;

&lt;h2&gt;
  
  
  Full Animation
&lt;/h2&gt;

&lt;p&gt;In the last example, we will look at a full animation example where the colors of our background change infinitely. The colors and rate are intentionally annoying to drive the point home.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@keyframes example {
 0%   {background-color:#ff80ff}
 25%  {background-color:#ffff80}
 50%  {background-color:#ff8080}
 75%  {background-color:#80ffff}
 100% {background-color:#ff80ff}
}

div {
 height: 90vh;
 background-color:#ff00ff;
 border: 1px solid;
 margin: 5vh 5vw;
 animation-name: example;
 animation-duration: 4s;
 animation-iteration-count: infinite;
}

@media (prefers-reduced-motion) {
 div {
   animation: none;
 }
}

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

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--V-p69k9I--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dsvkcumt3ynrwtl5iv6y.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--V-p69k9I--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dsvkcumt3ynrwtl5iv6y.gif" alt="animation-full" width="666" height="756"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Once again, only a few lines and this potentially harmful animation can be ignored by users.&lt;/p&gt;

&lt;p&gt;It’s that easy to account for those who wish for a reduced motion experience, a few lines and we can allow more users to enjoy our content. Prefers Reduced Motion has good browser support - every major browser except, you guessed it IE11.&lt;/p&gt;

&lt;p&gt;If you'd like to know more about preference media queries, I suggest &lt;br&gt;
&lt;a href="https://pod.link/thecsspodcast"&gt;The CSS Podcast's&lt;/a&gt; episode on "Preference Media"&lt;/p&gt;

&lt;p&gt;If you would like to understand more about motion sensitivities, Val Head wrote a great article &lt;a href="https://www.smashingmagazine.com/2020/09/design-reduced-motion-sensitivities/"&gt;Designing With Reduced Motion For Motion Sensitivities&lt;/a&gt; for Smashing Magazine.&lt;/p&gt;

</description>
      <category>css</category>
      <category>responsive</category>
    </item>
    <item>
      <title>CSS Grids Project - A Responsive Solar System - part 2</title>
      <dc:creator>JD Brewer-Hofmann</dc:creator>
      <pubDate>Wed, 10 Mar 2021 14:22:27 +0000</pubDate>
      <link>https://dev.to/jdbrewerhofmann/css-grids-project-a-responsive-solar-system-part-2-3jfi</link>
      <guid>https://dev.to/jdbrewerhofmann/css-grids-project-a-responsive-solar-system-part-2-3jfi</guid>
      <description>&lt;p&gt;Picking up from part one, we left off with two planets with orbits.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--HAgdj8rz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sbnzcyft8lqd06yxqwuw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--HAgdj8rz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/sbnzcyft8lqd06yxqwuw.png" alt="Screen Shot 2021-03-09 at 10.58.28" width="500" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Saturn and beyond
&lt;/h2&gt;

&lt;p&gt;Preparing to add another planet in (actually two), my next move is to double our grid size again.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;grid-template-columns: repeat(8, 1fr);
grid-template-rows: repeat(8, 1fr);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And using our grid numbers supplied in this case by Mozilla’s inspector, I can adjust the row and column assignments for Neptune and Uranus before adding the next two planets.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.neptune {
   grid-row: 1/2;
   grid-column: 1/9;
}
.neptune-orbit {
   grid-row: 1/9;
   grid-column: 1/9;
}
.uranus {
   grid-row: 2/3;
   grid-column: 1/9;
}
.uranus-orbit {
   grid-row: 2/8;
   grid-column: 2/8;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And that brings us back to basically the same design as before. But, now I can add two more planets and their respective orbits. Continuing to use the line numbers provided in the inspector, I can place the next two planets right away.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div class="saturn-orbit orbit"&amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;div class="saturn planet"&amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;div class="jupiter-orbit orbit"&amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;div class="jupiter planet"&amp;gt;&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.saturn {
   grid-row: 3/4;
   grid-column: 1/9;
}
.saturn-orbit {
   grid-row: 3/7;
   grid-column: 3/7;
}
.jupiter {
   grid-row: 4/5;
   grid-column: 1/9;
}
.jupiter-orbit {
   grid-row: 4/6;
   grid-column: 4/6;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--tUmIib5d--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5arvxidetgu0slnojysq.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--tUmIib5d--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/5arvxidetgu0slnojysq.png" alt="Screen Shot 2021-03-09 at 14.22.08" width="500" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Double it
&lt;/h2&gt;

&lt;p&gt;Now we have a system developing here ( pun intended ), though it’s a bid tedious we can simply double our grid again, then adjust all the previous row and column assignments to account for the change.&lt;/p&gt;

&lt;p&gt;Just to update, this is what our code looks like at this point&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;main&amp;gt;
       &amp;lt;div class="neptune-orbit orbit"&amp;gt;&amp;lt;/div&amp;gt;
       &amp;lt;div class="neptune planet"&amp;gt;&amp;lt;/div&amp;gt;
       &amp;lt;div class="uranus-orbit orbit"&amp;gt;&amp;lt;/div&amp;gt;
       &amp;lt;div class="uranus planet"&amp;gt;&amp;lt;/div&amp;gt;
       &amp;lt;div class="saturn-orbit orbit"&amp;gt;&amp;lt;/div&amp;gt;
       &amp;lt;div class="saturn planet"&amp;gt;&amp;lt;/div&amp;gt;
       &amp;lt;div class="jupiter-orbit orbit"&amp;gt;&amp;lt;/div&amp;gt;
       &amp;lt;div class="jupiter planet"&amp;gt;&amp;lt;/div&amp;gt;
       &amp;lt;div class="mars-orbit orbit"&amp;gt;&amp;lt;/div&amp;gt;
       &amp;lt;div class="mars planet"&amp;gt;&amp;lt;/div&amp;gt;
       &amp;lt;div class="earth-orbit orbit"&amp;gt;&amp;lt;/div&amp;gt;
       &amp;lt;div class="earth planet"&amp;gt;&amp;lt;/div&amp;gt;
       &amp;lt;div class="venus-orbit orbit"&amp;gt;&amp;lt;/div&amp;gt;
       &amp;lt;div class="venus planet"&amp;gt;&amp;lt;/div&amp;gt;
       &amp;lt;div class="mercury-orbit orbit"&amp;gt;&amp;lt;/div&amp;gt;
       &amp;lt;div class="mercury planet"&amp;gt;&amp;lt;/div&amp;gt;
   &amp;lt;/main&amp;gt;

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

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;body {
   padding: 0;
   margin: 0;
   box-sizing: border-box;
   display: grid;
   place-items: center;
   height: 100vh;
} 
main {
   width: 90vw;
   height: 90vw;
   margin: 5vh 5vw;
   border: 1px solid #cccccc;
   display: grid;
   grid-template-columns: repeat(16, 1fr);
   grid-template-rows: repeat(16, 1fr);
}
.planet {
   height: 5vmin;
   width: 5vmin;
   border-radius: 50%;
   border: 2px solid #000000;
   background: #ffffff;
   justify-self: center;
   margin-top: -2.5vmin;
}
.orbit {
   border-radius: 50%;
   border: 2px solid #000000;
}
.neptune {
   grid-row: 1/2;
   grid-column: 1/17;
}
.neptune-orbit {
   grid-row: 1/17;
   grid-column: 1/17;
}
.uranus {
   grid-row: 2/3;
   grid-column: 1/17;
}
.uranus-orbit {
   grid-row: 2/16;
   grid-column: 2/16;
}
.saturn {
   grid-row: 3/4;
   grid-column: 1/17;
}
.saturn-orbit {
   grid-row: 3/15;
   grid-column: 3/15;
}
.jupiter {
   grid-row: 4/5;
   grid-column: 1/17;
}
.jupiter-orbit {
   grid-row: 4/14;
   grid-column: 4/14;
}
.mars {
   grid-row: 5/6;
   grid-column: 1/17;
}
.mars-orbit {
   grid-row: 5/13;
   grid-column: 5/13;
}
.earth {
   grid-row: 6/7;
   grid-column: 1/17;
}
.earth-orbit {
   grid-row: 6/12;
   grid-column: 6/12;
}
.venus {
   grid-row: 7/8;
   grid-column: 1/17;
}
.venus-orbit {
   grid-row: 7/11;
   grid-column: 7/11;
}
.mercury {
   grid-row: 8/9;
   grid-column: 1/17;
}
.mercury-orbit {
   grid-row: 8/10;
   grid-column: 8/10;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With all of our planets, RIP pluto, here is what our system looks like.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--uPg9Qkd6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k2dnwvguehxg5igvcu9a.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--uPg9Qkd6--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/k2dnwvguehxg5igvcu9a.gif" alt="8-planets" width="512" height="514"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, we have a good foundation. We are missing a sun for all these planets to revolve around, unless that’s not your thing, which I don’t even know where to begin. So adding a div for our sun, and the following CSS&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.sun {
   grid-row: 8/10;
   grid-column: 8/10;
   height: 5vmin;
   width: 5vmin;
   border-radius: 50%;
   background: #000000;
   justify-self: center;
   align-self: center;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We can drop it into the same grid position as mercury, but place it in the middle both vertically and horizontally.&lt;/p&gt;

&lt;p&gt;And there it is, a basic responsive solar system with CSS grids. Now, the sizes, spacing, ratios and anything else you can imagine are totally off, but it works!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--XGhelMJo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4dbt3z8ppqt0yqa1p6t2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XGhelMJo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/4dbt3z8ppqt0yqa1p6t2.png" alt="Screen Shot 2021-03-09 at 14.50.43" width="500" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Finishing touches
&lt;/h2&gt;

&lt;p&gt;Before we continue, I’m going to invert the colors. Anything that was white, I will make #101010 and black will flip to #ffffff. I will also change the orbit border to 2px dotted #ffffff.&lt;/p&gt;

&lt;p&gt;Now that everything is aligned correctly, and our grid is worked out, I want to make the size and spacing ratios slightly more true to life. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;At this point I spent 15 minutes learning some valuable insights by making some aggressive mistakes&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Thinking how the spacing of my grid will change, I notice that the columns and rows must mirror each other, so I know that. Also, the columns and rows will be written out as a palindrome within each property. This means if I use a row spacing of 5px, 8px, and 10px, my next three rows would be 10px, 8px, and 5px. The entire row property would read 5px 8px 10px 10px 8px 5px. Therefore, I have decided to plan out my spacing and simply write out my row property declaration long form.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;grid-template-columns: 3fr 2.5fr 2.5fr 2fr 1fr 1fr .75fr 3fr 3fr .75fr 1fr 1fr 2fr 2.5fr 2.5fr 3fr;
   grid-template-rows: 3fr 2.5fr 2.5fr 2fr 1fr 1fr .75fr 3fr 3fr .75fr 1fr 1fr 2fr 2.5fr 2.5fr 3fr;

.planet {
   height: 2vmin;
   width: 2vmin;
   margin-top: -1vmin;
   }


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

&lt;/div&gt;



&lt;p&gt;I settled on this spacing. It’s not that pretty written out, but hey. I also cut the default planet size down now that the distance between each planet became a little clogged.&lt;/p&gt;

&lt;p&gt;For each planet, I adjust the height, and width to the same number and change the margin-top to subtract half of that number. &lt;/p&gt;

&lt;p&gt;With all those changes we have this&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--bQfHzo2T--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6z6ve45iaaf889j458hk.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bQfHzo2T--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/6z6ve45iaaf889j458hk.png" alt="Screen Shot 2021-03-09 at 20.05.04" width="500" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;So far this is really responsive, but when the screen is over 1000px it starts to look ridiculous. So I am going to cap the main section at 600px by adding&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: 600px;
max-height: 600px;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But now my planets continue to expand when the grid doesn’t, so I am going to stop each of them from expanding too. This is a bit more cumbersome, but if open my inspector and adjust my screen to 666px by 666px I can hover over each planet and see a pixel amount to cap them at. Using the min() and max() functions for each planet 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;.neptune {
   grid-row: 1/2;
   grid-column: 1/17;
   height: min(3vmin, 20px);
   width: min(3vmin, 20px);
   margin-top: max(-1.5vmin, -10px);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I can ensure they will not expand beyond the cap, and the margin will not push them into outer space even as the grid ceases to expand.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Yu_WWk48--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9lkcubdu0sjdl0xi0nup.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Yu_WWk48--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/9lkcubdu0sjdl0xi0nup.gif" alt="final" width="746" height="708"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;There it is! Hopefully you can learn something about CSS grids, or some other tricks along the way. &lt;/p&gt;

&lt;p&gt;If you’re interested to look at the code &lt;br&gt;
&lt;a href="https://github.com/JDHofmann/css-grids-solar-system"&gt;https://github.com/JDHofmann/css-grids-solar-system&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>CSS Grids Project - A Responsive Solar System - part 1</title>
      <dc:creator>JD Brewer-Hofmann</dc:creator>
      <pubDate>Tue, 09 Mar 2021 16:09:59 +0000</pubDate>
      <link>https://dev.to/jdbrewerhofmann/css-grids-project-a-responsive-solar-system-15cd</link>
      <guid>https://dev.to/jdbrewerhofmann/css-grids-project-a-responsive-solar-system-15cd</guid>
      <description>&lt;p&gt;I'm going to be build this with pure HTML and CSS, using CSS grids.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--izzH8SKl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/guxrtz9pn0dgdkkkiz1z.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--izzH8SKl--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/guxrtz9pn0dgdkkkiz1z.png" alt="Screen Shot 2021-03-09 at 20.05.04" width="500" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Intro
&lt;/h2&gt;

&lt;p&gt;I wanted to write about getting started using CSS grids, but damn if MDN docs just nailed it already. So, if you're interested to get started with CSS grids ( and you should ) please check out &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_Grid_Layout/Basic_Concepts_of_Grid_Layout"&gt;MDN Web Docs guide to CSS grids&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;After I realized the basics are well cover, I was seeking a project to build in CSS grids and the original Space Jam web page was brought up to me ( Credit Jessie Wu ). &lt;a href="https://labs.jensimmons.com/2017/02-015.html"&gt;Recreated here using CSS grids&lt;/a&gt;, It's a great example of how CSS grids is responsive and awesome. From that idea I decided to create a responsive solar system. Using this image for reference &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Ij0VhKj2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dilpkqc3j56tbotrlbm0.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Ij0VhKj2--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/dilpkqc3j56tbotrlbm0.jpg" alt="modal" width="820" height="900"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;My goal is to make a 2D responsive “image” containing 8 planets, plus a sun. I want to retain the lines that represent the orbit path for each body. I will not include the names of each planet. Now, let's get started.&lt;/p&gt;

&lt;h2&gt;
  
  
  Step 1
&lt;/h2&gt;

&lt;p&gt;Opening a blank HTML and CSS document, I will make an empty main element to contain the solar system.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;body {
   padding: 0;
   margin: 0;
   box-sizing: border-box;
   display: grid;
   place-items: center;
   height: 100vh;
}
main {
   width: 90vw;
   height: 90vw;
   margin: 5vh 5vw;
   border: 1px solid #cccccc;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I added a light border so we can see where we are working, and position it in the middle of the screen.&lt;/p&gt;

&lt;h3&gt;
  
  
  Neptune &amp;amp; Orbit
&lt;/h3&gt;

&lt;p&gt;I decided to work from the outer planets inward, I'm sure this could be done working from the center out as well, this is the way I chose to build this design. Adding a div that will represent the first planet, Neptune.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.neptune {
   height: 5vmin;
   width: 5vmin;
   border-radius: 50%;
   border: 2px solid #000000;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We have a planet, sort of, without an orbit it’s just a circle right now, so let’s add a second div that will be Neptune’s orbit&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   &amp;lt;main&amp;gt;
       &amp;lt;div class="neptune"&amp;gt;&amp;lt;/div&amp;gt;
       &amp;lt;div class="neptune-orbit"&amp;gt;&amp;lt;/div&amp;gt;
   &amp;lt;/main&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.neptune-orbit {
   border-radius: 50%;
   border: 2px solid #000000;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I added a border, and border radius 50% to ensure it is a circle, at least eventually. We really need to employ the power of CSS-grids. &lt;/p&gt;

&lt;h3&gt;
  
  
  Neptune’s Grid
&lt;/h3&gt;

&lt;p&gt;The goal is to have a perfect circle, so if we instruct our “neptune-orbit” element to fill the entire grid, while keeping the border-radius at 50%, it should make a perfect circle.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;main {
   width: 90vw;
   height: 90vw;
   margin: 5vh 5vw;
   border: 1px solid #cccccc;
   display: grid;
   grid-template-columns: 1fr 1fr;
   grid-template-rows: 1fr 1fr;
}

.neptune {
   height: 5vmin;
   width: 5vmin;
   border-radius: 50%;
   border: 2px solid #000000;
   grid-row: 1/2;
   grid-column: 1/3;
}

.neptune-orbit {
   border-radius: 50%;
   border: 2px solid #000000;
   grid-row: 1/3;
   grid-column: 1/3;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The “neptune” element is positioned inside the first row, and both columns. If we instruct it to “justify-self” to the center, it should be closer to the orbit we it to match up with.&lt;/p&gt;

&lt;p&gt;Now we are very close. If we push the item up towards the top by half of it’s height, it should be visually aligned with the orbit. Normally I choose to position an item using the relative position property, but that doesn’t apply within CSS-grids, so I will use the uglier but equally effective negative margin. &lt;em&gt;using a margin-bottom in this case causes some real issues within the grid system&lt;/em&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.neptune {
   height: 5vmin;
   width: 5vmin;
   border-radius: 50%;
   border: 2px solid #000000;
   grid-row: 1/2;
   grid-column: 1/3;
   justify-self: center;
   margin-top: -2.5vmin;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Almost perfect, I would rather not see the orbit line run right through our planet. So, I will switch the HTML to create the orbit first, then add a background color of #fffff to the neptune. Perfect!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--9amxpbep--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ahbfcye3o3hk6rownz4n.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9amxpbep--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ahbfcye3o3hk6rownz4n.gif" alt="neptune" width="512" height="514"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Uranus
&lt;/h2&gt;

&lt;p&gt;First things first, I want to abstract out any CSS that I will use for each planet or obit into it’s own class, so I keep my code DRY.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div class="neptune-orbit"&amp;gt;&amp;lt;/div&amp;gt;
&amp;lt;div class="neptune planet"&amp;gt;&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.planet {
   height: 5vmin;
   width: 5vmin;
   border-radius: 50%;
   border: 2px solid #000000;
   background: #ffffff;
}
.orbit {
   border-radius: 50%;
   border: 2px solid #000000;
}
.neptune {
   grid-row: 1/2;
   grid-column: 1/3;
   justify-self: center;
   margin-top: -2.5vmin;
}
.neptune-orbit {
   grid-row: 1/3;
   grid-column: 1/3;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now we can add a planet, or orbit class when we need.&lt;/p&gt;

&lt;p&gt;Thinking ahead with our grid, we need a grid of two columns and two rows to make a circle for the orbit, so if we want to add another orbit inside our current orbit, we will need to add two more columns and two more rows to do so.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;grid-template-columns: 1fr 1fr 1fr 1fr;
grid-template-rows: 1fr 1fr 1fr 1fr;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;But this is already getting ugly, so let’s refactor to account for adding more rows in the future.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;grid-template-columns: repeat(4, 1fr);
grid-template-rows: repeat(4, 1fr);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now let’s adjust Neptune’s grid assignments accordingly&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.neptune {
   grid-row: 1/2;
   grid-column: 1/5;
}
.neptune-orbit {
   grid-row: 1/5;
   grid-column: 1/5;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Almost there, now let’s add CSS to “uranus” so it positions itself in the proper space.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.uranus {
   grid-row: 2/3;
   grid-column: 1/5;
}
.uranus-orbit {
   grid-row: 2/4;
   grid-column: 2/4;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We now have two planets, and a system to go forward.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--ZjhuF7BR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o79azc09b8ew75r9zbto.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ZjhuF7BR--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o79azc09b8ew75r9zbto.png" alt="Screen Shot 2021-03-09 at 10.58.28" width="500" height="500"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I'm going to send this to part 2 now, because this is already getting long.&lt;/p&gt;

</description>
      <category>css</category>
      <category>responsive</category>
      <category>grid</category>
    </item>
    <item>
      <title>CSS Funtime!</title>
      <dc:creator>JD Brewer-Hofmann</dc:creator>
      <pubDate>Mon, 01 Mar 2021 16:08:34 +0000</pubDate>
      <link>https://dev.to/jdbrewerhofmann/css-funtime-ofl</link>
      <guid>https://dev.to/jdbrewerhofmann/css-funtime-ofl</guid>
      <description>&lt;p&gt;In my recent cyber travels I learned a few CSS tools I wanted to share. They are in no way related, except for being cool.&lt;/p&gt;

&lt;h2&gt;
  
  
  Place-items
&lt;/h2&gt;

&lt;p&gt;I was no aware of the "place-items" property before this week, and I’m very happy about this. I’ve been copying this code from project to project for years&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.parent {
  position: relative;
}
.child {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%,-50%);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I realize that I could have been using flex-box or a grid to accomplish this, but just let me feel dumb on my own please. Anyway, here's a really slim way to write this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div class="parent"&amp;gt;
       &amp;lt;div class="child"&amp;gt;
           &amp;lt;p&amp;gt;I'm the child&amp;lt;/p&amp;gt;
       &amp;lt;/div&amp;gt;
   &amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.parent {
   width: 80vw;
   height: 80vh;
   background: #00a0a0;
   margin: 10vh auto;
   color: #ffffff;
   display: grid;
   place-items: center;
}
.child {
   background: #ed0076;
   padding: 5%;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--NNyjXrU_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g9hb53mjsor2n8sn9xqr.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--NNyjXrU_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/g9hb53mjsor2n8sn9xqr.gif" alt="pi" width="498" height="460"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Basically, place-items is a shorthand for align-items and justify-items. &lt;/p&gt;

&lt;p&gt;Let’s add a second child and see what happens.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--bSxiijXt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ltpbsukwetjfc7d6ptbq.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--bSxiijXt--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/ltpbsukwetjfc7d6ptbq.gif" alt="place-items-2" width="498" height="460"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Flex Shorthand Property
&lt;/h2&gt;

&lt;p&gt;Admittedly, I am not a big user of flex, so I’m forcing myself to learn more about it. ( Forthcoming blog... )&lt;br&gt;
The flex shorthand property sets how a flex item will grow or shrink to fit the space available in its flex container.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div class="child first"&amp;gt;
           &amp;lt;p&amp;gt;I'm a child&amp;lt;/p&amp;gt;
       &amp;lt;/div&amp;gt;
       &amp;lt;div class="child"&amp;gt;
           &amp;lt;p&amp;gt;I'm the second child&amp;lt;/p&amp;gt;
       &amp;lt;/div&amp;gt;
       &amp;lt;div class="child"&amp;gt;
           &amp;lt;p&amp;gt;I'm the third child&amp;lt;/p&amp;gt;
       &amp;lt;/div&amp;gt;

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

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.parent {
   width: 90vw;
   height: 90vh;
   background: #00a0a0;
   margin: 5vh auto;
   color: #ffffff;
   display: flex;
   justify-content: center;
   align-content: center;
   overflow: hidden;
}
.child {
   background: #ed0076;
   padding: 5px;
   margin: 10px;
   flex: 1 1 25px;
}
.first {
   flex: 2 1 25px;
}

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

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--PaxX3Roo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/njt0039l4m3hiq0kxefj.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--PaxX3Roo--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/njt0039l4m3hiq0kxefj.gif" alt="flex-2" width="880" height="104"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This is easy to visualize with the elements on one line, so let’s add flex-wrap to our parent and complicate everything&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.parent {
    width: 90vw;
    height: 90vh;
    background: #00a0a0;
    margin: 5vh auto;
    color: #ffffff;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-content: center;
}
.child {
    background: #ed0076;
    padding: 5%;
    flex-basis: 100px; */
    margin: 10px;
}
.first {
    flex: 2 1 100px;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--5iDl4J7y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/obg964xzihwf0anohyaz.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--5iDl4J7y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/obg964xzihwf0anohyaz.gif" alt="flex-1" width="498" height="460"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Clamp Function
&lt;/h2&gt;

&lt;p&gt;The CSS clamp function keeps an elements size between upper and lower limits. Clamp() enables selecting a middle value within a range of values between a defined minimum and maximum.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div class="box"&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.box {
   margin: 10vh auto;
   height: 80vh;
   width: clamp(200px, 50vw, 400px);
   background: #00a0a0;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vzyMa7jw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hx79idb02iaecheiqabw.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vzyMa7jw--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/hx79idb02iaecheiqabw.gif" alt="clamp-1" width="880" height="477"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Browser support
&lt;/h3&gt;

&lt;p&gt;Clamp doesn’t have universal browser support yet ( which means internet explorer doesn’t support it &lt;em&gt;sigh&lt;/em&gt; ). If you’re worried about supporting things for IE you can use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.box {
   margin: 10vh auto;
   height: 80vh;
   min-width: 200px;
   width: 50vw;
   max-width: 400px;
   background: #00a0a0;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Because it’s exactly the same!!!&lt;/p&gt;

&lt;p&gt;Let’s try this with text!&lt;/p&gt;

&lt;p&gt;Here there are two p tags, one clamped and the other is set at 14px&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.clamp {
   font-size: clamp(14px, calc(4vmin), 20px )
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--8G5kXT-n--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jg2sh3121baedf2jtq0f.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--8G5kXT-n--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/jg2sh3121baedf2jtq0f.gif" alt="text-clamp" width="458" height="408"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Everything works just like the our previous clamp example, which is awesome. Notice the calc function set for the middle value. I want to set a responsive value for the example, but if I use the calc function to the viewport minimum I receive back an actual value - that way users can zoom in on the text per WCAG.&lt;/p&gt;

&lt;p&gt;More on clamp from MDN&lt;br&gt;
&lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/clamp()"&gt;https://developer.mozilla.org/en-US/docs/Web/CSS/clamp()&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Hopefully this helps&lt;/p&gt;

</description>
      <category>css</category>
      <category>responsive</category>
    </item>
    <item>
      <title>Accessible Forms</title>
      <dc:creator>JD Brewer-Hofmann</dc:creator>
      <pubDate>Wed, 24 Feb 2021 01:44:49 +0000</pubDate>
      <link>https://dev.to/jdbrewerhofmann/accessible-forms-1k02</link>
      <guid>https://dev.to/jdbrewerhofmann/accessible-forms-1k02</guid>
      <description>&lt;h2&gt;
  
  
  Login Form
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;form&amp;gt;
  &amp;lt;h2&amp;gt;Login&amp;lt;/h2&amp;gt;
  &amp;lt;label for="username"&amp;gt;Username&amp;lt;/label&amp;gt;
  &amp;lt;input id="username" type="text" placeholder="spacemanspiff8"    title="enter your username here"&amp;gt;
  &amp;lt;label for="password"&amp;gt;Password&amp;lt;/label&amp;gt;
  &amp;lt;input id="password" type="password" placeholder="******"&amp;gt;
  &amp;lt;button type="submit"&amp;gt;Login&amp;lt;/button&amp;gt;
&amp;lt;/form&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--v8DyRxSu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nasdd39gaqxpjbtmnlq1.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--v8DyRxSu--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/nasdd39gaqxpjbtmnlq1.png" alt="1*V1t2_xzmuC9QQ3T87pU0qQ" width="700" height="538"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This may be review for some of you, but it’s a good opportunity to go over the basics on something we all use about 30 times a day — a login form. First of all, we have an h2 tag at the top to give our users a solid idea of the purpose of the form. Next we have labels for each input, attaching their “for” attributes to the corresponding “id” for each input.  &lt;em&gt;For JSX users in React, use “htmlFor” instead of “for”.&lt;/em&gt; Standard HTML elements and their attributes have a lot of accessibility built in. Once you link the label to the input, years of others’ hard work will do the rest.&lt;/p&gt;

&lt;p&gt;Many developers wish to omit labels for fear of sacrificing minimalist design principles, however I strongly encourage you to use them in your forms. If you truly detest the look of labels, you can check out this article to learn how to visually hide them without losing functionality.&lt;/p&gt;

&lt;p&gt;Lastly — our submit button. To be fully compliant and reliable, these buttons should take the “type” value of “submit”. That’s easy enough.&lt;/p&gt;

&lt;h2&gt;
  
  
  Survey Time
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;form&amp;gt;
  &amp;lt;h2&amp;gt;Tell us about you&amp;lt;/h2&amp;gt;
  &amp;lt;fieldset&amp;gt;
    &amp;lt;legend&amp;gt;Preferred Drink&amp;lt;/legend&amp;gt;
    &amp;lt;p&amp;gt;
      &amp;lt;input type="radio" name="drink" id="drink_1" value="coffee"&amp;gt;
      &amp;lt;label for="drink_1"&amp;gt;Coffee&amp;lt;/label&amp;gt;
    &amp;lt;/p&amp;gt;
    &amp;lt;p&amp;gt;
      &amp;lt;input type="radio" name="drink" id="drink_2" value="tea"&amp;gt;
      &amp;lt;label for="drink_2"&amp;gt;Tea&amp;lt;/label&amp;gt;
    &amp;lt;/p&amp;gt;
  &amp;lt;/fieldset&amp;gt;
  &amp;lt;fieldset&amp;gt;
    &amp;lt;legend&amp;gt;Preferred Animal&amp;lt;/legend&amp;gt;
    &amp;lt;p&amp;gt;
      &amp;lt;input type="radio" name="animal" id="animal_1" value="cats"&amp;gt;
      &amp;lt;label for="animal_1"&amp;gt;Cats&amp;lt;/label&amp;gt;
    &amp;lt;/p&amp;gt;
    &amp;lt;p&amp;gt;
      &amp;lt;input type="radio" name="animal" id="animal_2" value="dogs"&amp;gt;
      &amp;lt;label for="animal_2"&amp;gt;Dogs&amp;lt;/label&amp;gt;
    &amp;lt;/p&amp;gt;
    &amp;lt;p&amp;gt;
      &amp;lt;input type="radio" name="animal" id="animal_3" value="both"&amp;gt;
      &amp;lt;label for="animal_3"&amp;gt;I like both cats and dogs&amp;lt;/label&amp;gt;
    &amp;lt;/p&amp;gt;
  &amp;lt;/fieldset&amp;gt;
&amp;lt;/form&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--9XlggrNs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/30az0vhz6xfizfv7tng3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9XlggrNs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/30az0vhz6xfizfv7tng3.png" alt="1*Ko67LVDxtzLSl-Pi0F-RPA" width="700" height="820"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Here is where the real fun starts. I love the the look of fieldset tags, but they’re so much more than simply how they look. In the code above, you’ll notice we have two sets of fieldset tags. Each one has nested radio buttons inside, as fieldset elements are an ideal way to create groups of widgets that share the same purpose. The legend tag gives a title to each group of inputs and some assistive technologies will even include the legend when speaking each input option. For example, when reading the first fieldset above, a screen reader will say: “Preferred drink: coffee” for the first input and “Preferred drink: tea” for the second.&lt;/p&gt;

&lt;p&gt;You might also notice each widget, or option, is wrapped in a p tag. Adding HTML elements that aren’t specific to forms will not disrupt assistive technologies, provided you use them correctly. In the example above, the p tags keep our widgets orderly. Then, default CSS will place each p tag on its own line. Pretty nice.&lt;/p&gt;

&lt;p&gt;Labels can also be used to activate their corresponding widget, so that users can click on the text as well as the input, giving them way more surface area to make the correct selection. This is especially helpful for users on mobile devices, those who are visually impaired, or who people who have ginormous thumbs.&lt;/p&gt;

&lt;p&gt;Taking a step back, let us remember, accessibility is only a part of inclusive design. We want our final product to make sense to users, and make sense to all users. It is best practice not to assume that a user has the same skills, abilities, or knowledge that you do.&lt;/p&gt;

&lt;h2&gt;
  
  
  Checklist
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Input elements have a corresponding label element&lt;/li&gt;
&lt;li&gt;Submit buttons have a “type” of “submit”&lt;/li&gt;
&lt;li&gt;Input elements used as radio buttons are nested inside of fieldset tag&lt;/li&gt;
&lt;li&gt;Fieldset elements have a corresponding label element&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This tutorial should get you started with building accessible forms, and I encourage you to check out the more comprehensive resources below.&lt;/p&gt;

&lt;p&gt;If you would like access to this code, &lt;a href="https://github.com/JDHofmann/building-accessible-forms"&gt;feel free to grab it from my github&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Learn/Forms/How_to_structure_a_web_form"&gt;https://developer.mozilla.org/en-US/docs/Learn/Forms/How_to_structure_a_web_form&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://wtfforms.com/"&gt;http://wtfforms.com/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.w3.org/TR/html401/interact/forms.html"&gt;https://www.w3.org/TR/html401/interact/forms.html&lt;/a&gt;&lt;/p&gt;

</description>
      <category>a11y</category>
      <category>inclusion</category>
      <category>form</category>
    </item>
    <item>
      <title>How to Create an Accessible Search Bar Without a Label</title>
      <dc:creator>JD Brewer-Hofmann</dc:creator>
      <pubDate>Tue, 16 Feb 2021 22:49:27 +0000</pubDate>
      <link>https://dev.to/jdbrewerhofmann/how-to-create-an-accessible-search-bar-without-a-label-jhb</link>
      <guid>https://dev.to/jdbrewerhofmann/how-to-create-an-accessible-search-bar-without-a-label-jhb</guid>
      <description>&lt;p&gt;If you’re looking to build a search bar with no label, this is the move&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;form role='search'&amp;gt;
  &amp;lt;label for="searchBar" class="sr-only"&amp;gt;Search Term&amp;lt;/label&amp;gt;
  &amp;lt;input id="searchBar" type="text" placeholder="Search Term"&amp;gt;
  &amp;lt;button&amp;gt;Search&amp;lt;/button&amp;gt;
&amp;lt;/form&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With some added css&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.sr-only {
position: absolute;
left: -10000px;
top: auto;
width: 1px;
height: 1px;
overflow: hidden;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6ICA9O5b--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fkv2hvco00svvty3e0hh.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6ICA9O5b--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/fkv2hvco00svvty3e0hh.png" alt="1*Yyn1T3wm67inK56FqyUdew" width="700" height="116"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Our CSS sets the label way off the screen, which doesn’t bother screen readers, but leaves you with a visually simple search input. Notice how the height and width are set to 1px each, if you were to set each to 0px the screen reader would skip over them entirely, so keep them at 1px. Overflow is hidden so if you wrote a long label title, which you definitely shouldn’t, it wouldn’t end up on the screen. Using a placeholder we can convey our input’s functionality to sighted users, while maintaining all the accessibility that comes standard with semantic html.&lt;/p&gt;

&lt;p&gt;Here is the same option but written in JSX for all the React users&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;form role='search'&amp;gt;
  &amp;lt;label htmlFor="s" className="sr-only"&amp;gt;Search Term&amp;lt;/label&amp;gt;
  &amp;lt;input id="s" type="text" name="search" placeholder="Search Term"/&amp;gt;
  &amp;lt;button&amp;gt;Search&amp;lt;/button&amp;gt;
&amp;lt;/form&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The code is functionally the same in React, but take note of the use of htmlFor=”s”, &lt;strong&gt;for&lt;/strong&gt; is a reserved name in JSX just like class, so remember to use &lt;strong&gt;htmlFor&lt;/strong&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Second option:
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;form role='search'&amp;gt;
  &amp;lt;input id="searchBar" type="text" placeholder="Search Term"   title="Search Term"&amp;gt;
  &amp;lt;button&amp;gt;Search&amp;lt;/button&amp;gt;
&amp;lt;/form&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hKQLMZ6t--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3vg3j9tplzfxg2t2k3jo.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hKQLMZ6t--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/3vg3j9tplzfxg2t2k3jo.png" alt="1*lvEOwc8gBqdVrAkKKdtuaA" width="700" height="144"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The title attribute functions as a label when no label is present, you might not want it, but it comes stock with a tool-tip when you hover over the input for a second.&lt;/p&gt;

&lt;h2&gt;
  
  
  Last option:
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;form role='search'&amp;gt;
  &amp;lt;input id="searchBar" type="text" placeholder="Search Term" aria-label="Search Term"&amp;gt;
  &amp;lt;button&amp;gt;Search&amp;lt;/button&amp;gt;
&amp;lt;/form&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Using an aria-label gets the job done&lt;/p&gt;

&lt;p&gt;Still the best way is to label your inputs, and link the label to the input id with “for”. It’s simple, and maybe boring, but it works, for everyone.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;form role='search'&amp;gt;
  &amp;lt;label for="searchBar" &amp;gt;Search Term&amp;lt;/label&amp;gt;
  &amp;lt;input id="searchBar" type="text"&amp;gt;
  &amp;lt;button&amp;gt;Search&amp;lt;/button&amp;gt;
&amp;lt;/form&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--D7M2c09T--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kod21citv6ubct90vnmt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--D7M2c09T--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/kod21citv6ubct90vnmt.png" alt="1*9mc9zwljG7u7VpYjU791EA" width="700" height="107"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It’s important to note, labels help to set keyboard focus to form control inputs, allowing sighted users the ability to click on the label as well as the input itself. Plus they have universal browser and screen reader support.&lt;/p&gt;

&lt;p&gt;Of course there are many ways to do this, and much better documentation, listed below, but these core concepts will give your search bars and search forms the basics needed for accessibility.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;This blog is the first in a series on accessibility, striving to provide a starting point for building common components with accessibility in mind.&lt;/em&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Resources
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://webaim.org/techniques/forms/advanced"&gt;https://webaim.org/techniques/forms/advanced&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="http://web-accessibility.carnegiemuseums.org/code/search/"&gt;http://web-accessibility.carnegiemuseums.org/code/search/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://designsystem.digital.gov/components/form-controls/"&gt;https://designsystem.digital.gov/components/form-controls/&lt;/a&gt;&lt;/p&gt;

</description>
    </item>
    <item>
      <title>We've made the decision to not move forward at this time</title>
      <dc:creator>JD Brewer-Hofmann</dc:creator>
      <pubDate>Mon, 15 Feb 2021 16:24:10 +0000</pubDate>
      <link>https://dev.to/jdbrewerhofmann/we-ve-made-the-decision-to-not-move-forward-at-this-time-12m9</link>
      <guid>https://dev.to/jdbrewerhofmann/we-ve-made-the-decision-to-not-move-forward-at-this-time-12m9</guid>
      <description>&lt;p&gt;Last week I completed a third interview for a company, a pair programming session with the company's lead developer. I completed the tasks in a reasonable time, and pushed myself to use the syntax the company prefers. All in all, I felt I had an decent interview and I stuck around to chat with the lead developer for ten minutes after the challenge was over. Within one hour I received an email notifying me I would not move on to the next round.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;After trapping myself with my thoughts for a 12 mile run I came to some realizations, along with more questions.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;I completed my coding bootcamp just over two months ago, and I've been aggressively job hunting since the first week of January. I've had trouble knowing how to spend my time, and what exactly I should be focusing on each day.&lt;/p&gt;

&lt;p&gt;In no way did I feel I deserved a job so early in my job hunt, and I was clearly not the best technical candidate for this position, so why did this rejection crush all my hope of finding a job so easily?&lt;/p&gt;

&lt;h2&gt;
  
  
  Is this a job I wanted?
&lt;/h2&gt;

&lt;p&gt;By all standards this was an awesome job opening.  The opening was a full-stack position at an up and coming company, the tech stack is mostly familiar to me, and there was lots of room to grow quickly. I would have been challenged in many ways in this position, and very happy to secure employment for my family's sack.&lt;/p&gt;

&lt;h2&gt;
  
  
  Is a full-stack position what I want?
&lt;/h2&gt;

&lt;p&gt;I would have been thrilled with this position, and happy to apply my knowledge.&lt;/p&gt;

&lt;p&gt;But... Do I enjoy working on backend code for hours on end? No, not really. I enjoy keeping things organized, and solving problems but I rarely open up backend code to play around. Working on backend code is a means to an end for me, and my primary goal is to complete it so I can move on to the frontend. &lt;/p&gt;

&lt;p&gt;When I have free time, I obsess over hex colors, about responsive designs, and font choices. I read about accessibility, and perform assessments on "cool" sites ( news flash - they don't pass many accessibility requirements ) then I rework my portfolio for the twentieth time. Maybe I never entirely kicked design school out of my system? Maybe that's ok.&lt;/p&gt;

&lt;h2&gt;
  
  
  So what do I want?
&lt;/h2&gt;

&lt;p&gt;I want to make sites that are really beautiful, and work really well - for everyone. I want to keep learning about CSS at a super granular level. I want to make sure websites are accessible, and easily understood. I want a job where they want me to become certified in accessibility and value passion for that. I want to take designs and make them into responsive layouts that look good on any screen size. Working on those issues every day sounds like a dream come true. &lt;/p&gt;

&lt;p&gt;I suppose it's time I hang up the idea that I will be a full-stack developer. I clearly love working on the frontend, and I have been too afraid to admit that before. I was really mad that I was good enough for this position, but maybe I was never going to love it. I will continue to search for a job that I can sink my teeth into what I love to do. &lt;/p&gt;

</description>
      <category>interview</category>
      <category>rejection</category>
    </item>
    <item>
      <title>Getting Started in Next.js, part 2 - styling</title>
      <dc:creator>JD Brewer-Hofmann</dc:creator>
      <pubDate>Tue, 09 Feb 2021 19:08:45 +0000</pubDate>
      <link>https://dev.to/jdbrewerhofmann/getting-started-in-next-js-part-2-styling-2bbh</link>
      <guid>https://dev.to/jdbrewerhofmann/getting-started-in-next-js-part-2-styling-2bbh</guid>
      <description>&lt;h2&gt;
  
  
  Review
&lt;/h2&gt;

&lt;p&gt;In part 1 we built a basic Next.js site with some pages, and a navigation bar, but it doesn't look like much yet. In part 2 we will explore the different styling options and how to implement them.&lt;/p&gt;

&lt;h2&gt;
  
  
  Layout Component
&lt;/h2&gt;

&lt;p&gt;Before we apply any styles directly to the existing elements, we can do some refactoring that will save us time in the long run. By using the Next Layout Component, we can share styles, or a general layout, across many pages.&lt;/p&gt;

&lt;p&gt;Add a layout.js file to your components folder&lt;/p&gt;

&lt;p&gt;And this code&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export default function Layout({ children }) {
   return (
       &amp;lt;div&amp;gt;
           &amp;lt;p&amp;gt;layout&amp;lt;/p&amp;gt;
           {children}
       &amp;lt;/div&amp;gt;
   )
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then import Layout into the Posts page, and change the wrapper of the component from a fragment, to a  component.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import Navbar from '../components/navbar.js'
import Layout from '../components/layout'

export default function Posts(){
   return(
       &amp;lt;Layout&amp;gt;
           &amp;lt;Navbar /&amp;gt;
           &amp;lt;div&amp;gt;
               &amp;lt;h1&amp;gt;Posts&amp;lt;/h1&amp;gt;
           &amp;lt;/div&amp;gt;
       &amp;lt;/Layout&amp;gt;
   )
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You should see the word layout at the top of your posts page now. We can utilize the layout component to drop our Navbar component into each page in a cleaner way.&lt;/p&gt;

&lt;p&gt;If we alter layout.js looks like this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import Navbar from '../components/navbar.js'

export default function Layout({ children }) {
   return (
       &amp;lt;div&amp;gt;
           &amp;lt;Navbar /&amp;gt;
           {children}
       &amp;lt;/div&amp;gt;
   )
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And Post.js&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import Layout from '../components/layout'

export default function Posts(){
   return(
       &amp;lt;Layout&amp;gt;
           &amp;lt;div&amp;gt;
               &amp;lt;h1&amp;gt;Posts&amp;lt;/h1&amp;gt;
           &amp;lt;/div&amp;gt;
       &amp;lt;/Layout&amp;gt;
   )
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The post page remains the same, but we are passing our Navbar through our layout wrapper now. Let’s change the other two pages as well. &lt;/p&gt;

&lt;p&gt;Let’s add a footer component as well. Creating a /components/footer.js file and some simple code&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export default function Footer(){
   return (
       &amp;lt;footer&amp;gt;
           &amp;lt;p&amp;gt;Footer action&amp;lt;/p&amp;gt;
       &amp;lt;/footer&amp;gt;
   )
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By adding the footer to the layout component which wraps our other pages, we will now have a footer on every page as well.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import Navbar from '../components/navbar.js'
import Footer from './footer.js'

export default function Layout({ children }) {
   return (

       &amp;lt;div&amp;gt;
           &amp;lt;Navbar /&amp;gt;
           {children}
           &amp;lt;Footer /&amp;gt;
       &amp;lt;/div&amp;gt;
   )
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We’re ready to scale up now, through our layout component we have added the navbar and footer to each page.&lt;/p&gt;

&lt;h2&gt;
  
  
  Global CSS
&lt;/h2&gt;

&lt;p&gt;The first place to start styling would be one main CSS file. In Next.js the styles folder contains the a globals.css file for anytime you want to apply styling to every page. Let's add a hover feature to apply to any links on the page.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a:hover {
 text-decoration: underline;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Add this block and you’ll have hover functionality on all links now.&lt;/p&gt;

&lt;p&gt;The global css file imports to the rest of our project through the pages/_app.js file.&lt;/p&gt;

&lt;h2&gt;
  
  
  CSS Modules
&lt;/h2&gt;

&lt;p&gt;The first option for adding component level CSS is through CSS modules. There are lots of advantages to using modules, and some frustrations as well, it's best to build some files to see for yourself.&lt;/p&gt;

&lt;p&gt;Create a components/layout.module.css file adding this code to it&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.container {
   width: 90vw;
   padding: 0 1vmin;
   margin: 5vh auto;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then we will import the new module into our Layout component as 'style' and apply the 'container' class to the div.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import Navbar from '../components/navbar.js'
import styles from './layout.module.css'

export default function Layout({ children }) {
   return (
       &amp;lt;div className={styles.container}&amp;gt;
           &amp;lt;Navbar /&amp;gt;
           {children}
       &amp;lt;/div&amp;gt;
   )
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, if you take a look at the HTML in your browser’s devtools, you’ll notice that the div rendered by the Layout component has a class name that looks like layout_container__...:&lt;/p&gt;

&lt;p&gt;CSS modules automatically generate unique class names. You can avoid any class name collisions by keeping class names scoped locally. An added feature is Next.js's code splitting. Next will only load the needed CSS for each page, which keeps everything running quickly.&lt;/p&gt;

&lt;p&gt;Now let’s create a style module for the navbar&lt;/p&gt;

&lt;p&gt;Creating a components/navbar.module.css file with the following code&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.header {
   display: flex;
   justify-content: space-around;
}
.navlink {
   color: #006000;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Importing the navbar.module.css to our navbar component and styling the  component with it. We can style our links with a separate class name from the header coming from the same file now.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import Link from 'next/link'
import style from './navbar.module.css'

export default function Navbar(){
   return(
       &amp;lt;header className={style.header}&amp;gt;
           &amp;lt;Link href="/"&amp;gt;&amp;lt;a className={style.navlink}&amp;gt;Home&amp;lt;/a&amp;gt;&amp;lt;/Link&amp;gt;
           &amp;lt;Link href="/posts"&amp;gt;&amp;lt;a className={style.navlink}&amp;gt;Posts&amp;lt;/a&amp;gt;&amp;lt;/Link&amp;gt;
           &amp;lt;Link href="/about"&amp;gt;&amp;lt;a className={style.navlink}&amp;gt;About&amp;lt;/a&amp;gt;&amp;lt;/Link&amp;gt;
       &amp;lt;/header&amp;gt;
   )
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That's the basics of CSS modules. Personally I find modules clunky, and adding multiple class names using interpolation&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;className={`${styles.description} ${styles.yellow}`}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Just rubs me the wrong way. So let’s investigate more options.&lt;/p&gt;

&lt;h2&gt;
  
  
  Styled-jsx
&lt;/h2&gt;

&lt;p&gt;Trying a different route with CSS, we have the Styled JSX framework. The style defined for a component only affects that component and nothing else — not even its children!&lt;/p&gt;

&lt;p&gt;Next.js includes Styled JSX by default, so getting started is as simple as adding a&lt;br&gt;
'style jsx' tag into an existing React element and writing CSS inside of it.&lt;/p&gt;

&lt;p&gt;Let's experiement with the post.js file&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import Head from 'next/head'
import Layout from '../components/layout'

export default function Posts(){
   return(
       &amp;lt;Layout&amp;gt;
           &amp;lt;Head&amp;gt;
               &amp;lt;title&amp;gt;Posts&amp;lt;/title&amp;gt;
           &amp;lt;/Head&amp;gt;
           &amp;lt;div&amp;gt;
               &amp;lt;h1&amp;gt;Posts&amp;lt;/h1&amp;gt;
           &amp;lt;/div&amp;gt;
           &amp;lt;style jsx&amp;gt;{`
               div {
                   background: #00a000;
               }
               h1 {
                   color: #ffffff;
                   text-align: center;
               }
           }
           `}&amp;lt;/style&amp;gt;
       &amp;lt;/Layout&amp;gt;
   )
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--Qn_Dg39m--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/1eu99ozy3t2ppmtvj3ap.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Qn_Dg39m--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/1eu99ozy3t2ppmtvj3ap.gif" alt="ex-stlye-jsx-local-scope" width="574" height="558"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Notice we are using generic selectors, the styles don't affect the same elements or class names in other components. Styled JSX are scoped to this component only (by applying additional unique class names to styled elements).&lt;/p&gt;

&lt;p&gt;Check out the unique class name applied to div we styled:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--R9etueVC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/7dtnvmgp1k6wuea0xawu.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--R9etueVC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/7dtnvmgp1k6wuea0xawu.png" alt="Screen Shot 2021-02-09 at 1.40.29 PM" width="461" height="212"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;The downside of Styled JSX is by using a template string to write CSS rules, you lose IDE and code editor assistance to write them, and commenting code out becomes difficult.&lt;/p&gt;

&lt;p&gt;If Styled JSX intrigues you, there's lots more you can do with it, including adding global styles inside any component file.&lt;/p&gt;

&lt;p&gt;Checkout out &lt;a href="https://nextjs.org/learn/basics/assets-metadata-css/css-styling"&gt;Next's documentation&lt;/a&gt; for more information.&lt;/p&gt;

&lt;h2&gt;
  
  
  Adding SASS
&lt;/h2&gt;

&lt;p&gt;I'm a SASS fan, and luckily Next.js integrates with SASS very easily. Let's switch all this over to SCSS files now, because that's sort of the point of this article. Quick side note - I'm using &lt;a href="https://marketplace.visualstudio.com/items?itemName=ritwickdey.live-sass"&gt;Live Sass Compiler&lt;/a&gt; which makes all things SASS a breeze and I highly, highly recommend it. Seriously.&lt;/p&gt;

&lt;p&gt;First install SASS&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;yarn add sass
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;If we switch our components/navbar.module.css file to components.navbar.scss and compile, we have SASS working for us, but now the files are piling up inside our components folder &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--T8RsG4WH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/9mvkofj10iqhri9bkl7h.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--T8RsG4WH--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/9mvkofj10iqhri9bkl7h.png" alt="Screen Shot 2021-02-09 at 9.35.27 AM" width="167" height="225"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;p&gt;Switching the other CSS files to SASS will triple my files, so let’s refactor this.&lt;/p&gt;

&lt;p&gt;First, we will create a styles/main.scss - this will import all the other SCSS files so we only compile this one file, and keep everything organized. I will copy all the data from styles/global.css and paste it inside. Then in pages/_app.js we will switch our import from&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import '../styles/globals.css'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import '../styles/main.css'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once we compile ( using the live sass compilier ) , that will watch our main.scss file from now on and we don’t have to worry.&lt;/p&gt;

&lt;p&gt;Now let’s move our navbar.module.css and layout.module.css files into our styles folder&lt;/p&gt;

&lt;p&gt;Rename navbar.module.css to &lt;strong&gt;_navbar.scss&lt;/strong&gt; and rename layout.module.css to &lt;strong&gt;_layout.scss&lt;/strong&gt;&lt;br&gt;
Next, import both into main.scss&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@import 'navbar';
@import 'layout';
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Change classNames inside our navbar.js file&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import Link from 'next/link'

export default function Navbar(){
   return(
       &amp;lt;header className='header'&amp;gt;
           &amp;lt;Link href="/"&amp;gt;&amp;lt;a className='navlink'&amp;gt;Home&amp;lt;/a&amp;gt;&amp;lt;/Link&amp;gt;
           &amp;lt;Link href="/posts"&amp;gt;&amp;lt;a className='navlink'&amp;gt;Posts&amp;lt;/a&amp;gt;&amp;lt;/Link&amp;gt;
           &amp;lt;Link href="/about"&amp;gt;&amp;lt;a className='navlink'&amp;gt;About&amp;lt;/a&amp;gt;&amp;lt;/Link&amp;gt;
       &amp;lt;/header&amp;gt;
   )
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;By creating a corresponding SCSS file for each component, we've developed a very scalable file structure going forward. And by importing each component SCSS file into the main.scss file, we only have to compile once, and we can sit back and enjoy all the beauty of styling with SASS.&lt;/p&gt;

&lt;h2&gt;
  
  
  Conclusion
&lt;/h2&gt;

&lt;p&gt;That's a lot of reorganizing files, but for me I have a firm understanding of when I why I would use each of these styling options. I think Styled JSX is a great place to start when building an app, but as things scale up, migrating to SASS and moving everything to the style folder appears to be the best option for myself.&lt;/p&gt;

&lt;p&gt;As always, don't take my word for any of this. There's some amazing tutorials out there, and Next.js's own documentation is stellar.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://nextjs.org/docs/basic-features/built-in-css-support"&gt;Next.js documentation&lt;/a&gt;&lt;/p&gt;

</description>
      <category>css</category>
    </item>
    <item>
      <title>Getting Started in Next.js, part 1 - file setup and basics</title>
      <dc:creator>JD Brewer-Hofmann</dc:creator>
      <pubDate>Tue, 02 Feb 2021 13:35:57 +0000</pubDate>
      <link>https://dev.to/jdbrewerhofmann/getting-started-in-next-js-part-1-536l</link>
      <guid>https://dev.to/jdbrewerhofmann/getting-started-in-next-js-part-1-536l</guid>
      <description>&lt;p&gt;I had been hearing a lot of buzz about Next.js from the dev community lately, so I walked through the basics myself. So far, I have found it to be super powerful, and an excellent, if not necessary addition to React web applications.&lt;/p&gt;

&lt;h2&gt;
  
  
  The Basics
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;Next.js is an open-source React front-end development web framework that enables functionality such as server-side rendering and generating static websites for React based web applications.&lt;/em&gt;  &lt;/p&gt;

&lt;p&gt;It loads really fast because you have the option to generate static pages which don't rely on javascript to exist! Next code splits which allows even faster page loads for the user. Additionally there's a lot of other helpful functionality, but you should already be sold if you've read this far.&lt;/p&gt;

&lt;h2&gt;
  
  
  Let's build something
&lt;/h2&gt;

&lt;p&gt;It's very easy to start&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx create-next-app my-next-app
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Just like that, you have a Next app.&lt;/p&gt;

&lt;p&gt;Inside the app you'll see a different file structure than a 'create-react-app'. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fwtcmagvwnr8lswdsj5sd.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fwtcmagvwnr8lswdsj5sd.png" alt="file-setup"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The files are generally laid out like this to begin.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Pages:&lt;/strong&gt; &lt;br&gt;
Index.js - the home page&lt;br&gt;
_app.js - layout page&lt;br&gt;
&lt;strong&gt;Public:&lt;/strong&gt;&lt;br&gt;
Assets &lt;br&gt;
Images, etc..&lt;br&gt;
&lt;strong&gt;Styles:&lt;/strong&gt;&lt;br&gt;
CSS files&lt;br&gt;
Other styling files&lt;/p&gt;

&lt;p&gt;We will add some additional folders, later as well.&lt;/p&gt;

&lt;p&gt;To start up the app locally run&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Yarn Dev
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Navigate your browser to &lt;a href="http://localhost:3000" rel="noopener noreferrer"&gt;http://localhost:3000&lt;/a&gt; and you will find Next's welcome page with a bunch of wonderful and helpful information. I encourage you to check out their documentation, it's very thorough, but for now let's start fresh. &lt;/p&gt;

&lt;p&gt;Inside the pages/index.js file, edit your file to look like this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export default function Home() {
 return (
   &amp;lt;div&amp;gt;
    &amp;lt;h1&amp;gt;Home&amp;lt;/h1&amp;gt;
   &amp;lt;/div&amp;gt;
 )
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You’ll see Next’s fast refresh kick in and quickly re-render the page. Next, we will build some pages and see how easy Next makes that.&lt;/p&gt;

&lt;h2&gt;
  
  
  Pages
&lt;/h2&gt;

&lt;p&gt;Next uses integrated file system routing, which means routing is much easier to comprehend than React Router. Sorry React Router, I appreciate all that you've done for me...&lt;/p&gt;

&lt;p&gt;Add a new file pages/about.js&lt;/p&gt;

&lt;p&gt;Then add this code inside&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export default function About(){
   return (
       &amp;lt;div&amp;gt;
        &amp;lt;h1&amp;gt;About&amp;lt;/h1&amp;gt;
       &amp;lt;/div&amp;gt;
   )
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Navigating to &lt;a href="http://localhost:3000/about" rel="noopener noreferrer"&gt;http://localhost:3000/about&lt;/a&gt;, you’re now on the about page. You made a new route, just like that. &lt;/p&gt;

&lt;p&gt;In Next.js, a page is a React Component exported from a file in the pages directory. Pages are associated with a route based on their file name, so the component can have any name, but you must &lt;strong&gt;export it as a default export&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;By the same logic, nested files in the pages folder, equal nested routes. &lt;/p&gt;

&lt;p&gt;Make another file in pages called “about/contact.js” and add the following code&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export default function Contact(){
   return (
       &amp;lt;div&amp;gt;Contact&amp;lt;/div&amp;gt;
   )
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now visit &lt;a href="http://localhost:3000/about/contact" rel="noopener noreferrer"&gt;http://localhost:3000/about/contact&lt;/a&gt;, it's a nested route, just as easy. &lt;/p&gt;

&lt;h2&gt;
  
  
  Links
&lt;/h2&gt;

&lt;p&gt;The next thing to do is to start building a navigation bar, so we can use these routes we've created. Next comes with a Link Component to wrap the &lt;code&gt;&amp;lt;a&amp;gt;&lt;/code&gt; tags. &lt;code&gt;&amp;lt;Link&amp;gt;&lt;/code&gt; allows you to do client-side navigation to a different page in the application. First we will import the Link Component into the pages/index.js file, then add a link to the About page.&lt;/p&gt;

&lt;p&gt;Importing the Link Component at the top of the file&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import Link from 'next/link'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then creating the Link inside our Home component.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;Link href="/about"&amp;gt;&amp;lt;a&amp;gt;About&amp;lt;/a&amp;gt;&amp;lt;/Link&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice the Link component receives the &lt;em&gt;href&lt;/em&gt; attribute and the &lt;a&gt; tag remains inside with no necessary attributes. &lt;/a&gt;&lt;/p&gt;

&lt;p&gt;At this point your file should look like this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import Link from 'next/link'

export default function Home() {
 return (
   &amp;lt;div&amp;gt;
     &amp;lt;Link href="/about"&amp;gt;&amp;lt;a&amp;gt;About&amp;lt;/a&amp;gt;&amp;lt;/Link&amp;gt;
     &amp;lt;h1&amp;gt;Home&amp;lt;/h1&amp;gt;
   &amp;lt;/div&amp;gt;
 )
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And now you have a link to your about page. We can do the same thing with our about page and have a link back to our home page, like this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import Link from 'next/link'

export default function About(){
   return (
       &amp;lt;div&amp;gt;
           &amp;lt;Link href="/"&amp;gt;
           &amp;lt;a&amp;gt;Home&amp;lt;/a&amp;gt;
           &amp;lt;/Link&amp;gt;
           &amp;lt;h1&amp;gt;About&amp;lt;/h1&amp;gt;
       &amp;lt;/div&amp;gt;
   )
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is awesome because no routing libraries are required. React Router is cool, but this is much cooler.&lt;br&gt;
And when you need a link to an external site, a regular &lt;code&gt;&amp;lt;a&amp;gt;&lt;/code&gt;tag will still do the trick.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F8n3do0b5033vl2a51ria.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F8n3do0b5033vl2a51ria.gif" alt="ex-about-home-link"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Navigation Component
&lt;/h2&gt;

&lt;p&gt;Now we want to create a reusable navigation component, with our Home, About, and a new link inside to display on each page without rewriting it.&lt;/p&gt;

&lt;p&gt;First let’s create one new page called posts&lt;br&gt;
Remember, just create a posts.js file in the pages folder and add this code to that file&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;export default function posts(){
   return(
       &amp;lt;div&amp;gt;
           &amp;lt;h1&amp;gt;Posts&amp;lt;/h1&amp;gt;
       &amp;lt;/div&amp;gt;
   )
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;We want a reusable component to add to each page we already have, so let’s build a ‘components’ folder in our root directory, and then we will have it for any other components we might need.&lt;/p&gt;

&lt;p&gt;Inside the components folder, we can create a new file for our navbar, navbar.js.&lt;/p&gt;

&lt;p&gt;Paste this code into the new navbar file&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import Link from 'next/link'

export default function Navbar(){
   return(
       &amp;lt;header&amp;gt;
           &amp;lt;Link href="/"&amp;gt;&amp;lt;a&amp;gt;Home&amp;lt;/a&amp;gt;&amp;lt;/Link&amp;gt;
           &amp;lt;Link href="/posts"&amp;gt;&amp;lt;a&amp;gt;Posts&amp;lt;/a&amp;gt;&amp;lt;/Link&amp;gt;
           &amp;lt;Link href="/about"&amp;gt;&amp;lt;a&amp;gt;About&amp;lt;/a&amp;gt;&amp;lt;/Link&amp;gt;
       &amp;lt;/header&amp;gt;
   )
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then we import that file into each file where we need it&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import Navbar from '../components/navbar.js'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then add the Navbar component to each page where we need it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import Navbar from '../components/navbar.js'

export default function Posts(){
   return(
       &amp;lt;&amp;gt;
       &amp;lt;Navbar /&amp;gt;
       &amp;lt;div&amp;gt;
           &amp;lt;h1&amp;gt;Posts&amp;lt;/h1&amp;gt;
       &amp;lt;/div&amp;gt;
       &amp;lt;/&amp;gt;
   )
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Once the Navbar component is imported into each file and returning a Navbar component, your pages should look like this in the browser.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fvviongfs5y7yggjokpl2.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fvviongfs5y7yggjokpl2.gif" alt="ex-navbar"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I’m glad we have some navigation now, but the links are right next to each other. In part 2, we will add some styling options.&lt;/p&gt;

&lt;h2&gt;
  
  
  Additional Resources
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://nextjs.org/docs" rel="noopener noreferrer"&gt;https://nextjs.org/docs&lt;/a&gt;&lt;/p&gt;

</description>
      <category>nextjs</category>
      <category>react</category>
    </item>
    <item>
      <title>Responsive Font-Sizing, part 2</title>
      <dc:creator>JD Brewer-Hofmann</dc:creator>
      <pubDate>Wed, 20 Jan 2021 19:46:02 +0000</pubDate>
      <link>https://dev.to/jdbrewerhofmann/responsive-font-sizing-part-2-3hmi</link>
      <guid>https://dev.to/jdbrewerhofmann/responsive-font-sizing-part-2-3hmi</guid>
      <description>&lt;p&gt;In part one, the primary method we used to achieve responsive sizing was media queries. In part two we will look to viewport units instead.&lt;/p&gt;

&lt;h2&gt;
  
  
  Viewport units
&lt;/h2&gt;

&lt;p&gt;Viewport units are relative to the size of the browsers viewport, therefore they are incredibly responsive.&lt;/p&gt;

&lt;h3&gt;
  
  
  VH
&lt;/h3&gt;

&lt;p&gt;The viewport height unit ( vh ) is equal to 1% of the viewport's height. So what does it look like when we use vh for our font-size?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;h1 {
  font-size: 5vh;
}
h2 {
  font-size: 4vh;
}
p {
  font-size: 2.5vh;
}
button {
  font-size: 3vh;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fghz0ifd5han3cr5mk0b1.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fghz0ifd5han3cr5mk0b1.gif" alt="ex-vh"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That is quite responsive, and no media query is necessary. &lt;/p&gt;

&lt;h3&gt;
  
  
  VW
&lt;/h3&gt;

&lt;p&gt;It makes sense then that the viewport width unit ( vw ) is equal to 1% of the viewport's width.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;h1 {
  font-size: 8vw;
}
h2 {
  font-size: 6vw;
}
p {
  font-size: 4vw;
}
button {
  font-size: 5vw;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F8yypnjzvz6jeo98qmnmf.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F8yypnjzvz6jeo98qmnmf.gif" alt="ex-vw"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once again, a very responsive unit, let's try flipping between portrait and landscape modes.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fu35d9k6b7ycwmufemycx.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fu35d9k6b7ycwmufemycx.gif" alt="ex-vw-flip"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That works pretty well, and there's two other viewport units to examine still.&lt;/p&gt;

&lt;h3&gt;
  
  
  Viewport Minimum
&lt;/h3&gt;

&lt;p&gt;This unit is based on the smaller dimension of the viewport. If the viewport height is smaller than the width, the value of 1vmin will be equal to 1% of the viewport height. Similarly, if the viewport width is smaller than the height, the value of 1vmin will be equal to 1% of the viewport width.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;h1 {
    font-size: 8vmin;
}
h2 {
    font-size: 6vmin;
}
p {
    font-size: 4vmin;
}
button {
    font-size: 5vmin;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fl2rm6lfm1mwh0l0j01sa.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fl2rm6lfm1mwh0l0j01sa.gif" alt="ex-vmin"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That might be even better than vh or vw, because if a user flips their phone from portrait to landscape the font-sizes will remain the same. &lt;/p&gt;

&lt;h3&gt;
  
  
  Viewport Maximum
&lt;/h3&gt;

&lt;p&gt;You would probably guess that viewport maximum (vmax) is based on the larger dimension of the viewport.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;h1 {
    font-size: 4vmax;
  }
  h2 {
    font-size: 3vmax;
  }
  p {
    font-size: 2.25vmax;
  }
  button {
    font-size: 2.5vmax;
  }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F5a8dtft4g6m4z3qguoel.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F5a8dtft4g6m4z3qguoel.gif" alt="ex-vmax"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Vmax functions very similarly to vmin. Between the two, I find it much more sensible to base my responsive sizing off of the smaller dimension of the screen using vmin. &lt;/p&gt;

&lt;h2&gt;
  
  
  Fluid Text with calc()
&lt;/h2&gt;

&lt;p&gt;Here's where things get really interesting. I stumbled upon a formula that expands upon viewport units and adds in minimum and maximum values for font-sizes. The formula looks like this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;min = minimum font-size integer
minPx = minimum font-size 
max = maximum font-size integer
screenMin = minimum screen size integer
screenMinPx = minimum screen size 
screenMax = maximum screen size integer

font-size: calc(minPx + (max - min) * ((100vw - screenMinPx) / (screenMax - screenMin)));

font-size: calc(24px + (32 - 24) * ((100vw - 320px) / (1200 - 320)));
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;There's a lot to unpack here, if you want to understand it better checkout this awesome &lt;a href="https://www.smashingmagazine.com/2016/05/fluid-typography/" rel="noopener noreferrer"&gt;smashing magazine article&lt;/a&gt;. Let's take a look at this in action.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;h1 {
    font-size: calc(24px + (32 - 24) * ((100vw - 320px) / (1200 - 320)));
}
h2 {
    font-size: calc(20px + (26 - 20) * ((100vw - 320px) / (1200 - 320)));
}
p {
    font-size: calc(12px + (16 - 12) * ((100vw - 320px) / (1200 - 320)));
}
button {
    font-size: calc(14px + (18 - 14) * ((100vw - 320px) / (1200 - 320)));
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F3gb9ucvclkl3z5bdvc6c.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F3gb9ucvclkl3z5bdvc6c.gif" alt="ex-fluid"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;That sure is a handful to write, but it gives us an incredibly responsive sizing with guardrails to ensure our text never gets too large or too small. Coupled this technique with viewport sizing for your containers, and you can make some incredible responsive apps with no media queries.&lt;/p&gt;

&lt;h3&gt;
  
  
  Adding SASS or CSS precompilers
&lt;/h3&gt;

&lt;p&gt;Abstracting away having to write this ridiculous calc function for every font-size in your app is the only thing left to do. Using SASS to write a reusable function can end up saving a lot of time. The only tricky part is remembering to add your minimum font size argument with a unit value to it, as well as without.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@mixin fluidText($minPx, $max, $min){
    font-size: calc(#{$minPx} + (#{$max} - #{$min}) * ((100vw - 320px) / (1200 - 320)));
}

h1 {
    @include fluidText(24px, 32, 24);

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

&lt;/div&gt;



&lt;p&gt;I attempted to simplify this, with no success, I had to include two different variables for the same number. While that little bit was annoying, the end result is a life saver for me, and I'll be copying that mixin into many projects from now on.&lt;/p&gt;

&lt;p&gt;I hope this helps anyone who is curious about making a more responsive app, and of course there's a lot more information out there. &lt;/p&gt;

&lt;h2&gt;
  
  
  Additional Resources
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://www.madebymike.com.au/writing/fluid-type-calc-examples/" rel="noopener noreferrer"&gt;https://www.madebymike.com.au/writing/fluid-type-calc-examples/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://www.smashingmagazine.com/2016/05/fluid-typography/" rel="noopener noreferrer"&gt;https://www.smashingmagazine.com/2016/05/fluid-typography/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/text-size-adjust" rel="noopener noreferrer"&gt;https://developer.mozilla.org/en-US/docs/Web/CSS/text-size-adjust&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://webdesign.tutsplus.com/articles/7-css-units-you-might-not-know-about--cms-22573" rel="noopener noreferrer"&gt;https://webdesign.tutsplus.com/articles/7-css-units-you-might-not-know-about--cms-22573&lt;/a&gt;&lt;/p&gt;

</description>
      <category>a11y</category>
    </item>
  </channel>
</rss>
