<?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>Forem: Nelson Caudill</title>
    <description>The latest articles on Forem by Nelson Caudill (@ncaudill27).</description>
    <link>https://forem.com/ncaudill27</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%2F343077%2F000717c2-453f-444e-b26d-a7b33ee16251.jpg</url>
      <title>Forem: Nelson Caudill</title>
      <link>https://forem.com/ncaudill27</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/ncaudill27"/>
    <language>en</language>
    <item>
      <title>Designing Responsive</title>
      <dc:creator>Nelson Caudill</dc:creator>
      <pubDate>Tue, 04 Aug 2020 17:16:54 +0000</pubDate>
      <link>https://forem.com/ncaudill27/designing-responsive-1jho</link>
      <guid>https://forem.com/ncaudill27/designing-responsive-1jho</guid>
      <description>&lt;p&gt;The year is 2020 - the world is in disarray, everything is cake 🍰, and your website &lt;strong&gt;needs&lt;/strong&gt; to be responsive.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why
&lt;/h2&gt;

&lt;p&gt;Let's start with some numbers. According to &lt;a href="https://www.internetworldstats.com/emarketing.htm" rel="noopener noreferrer"&gt;Internet World Stats&lt;/a&gt; as of this June 4.648 &lt;em&gt;billion&lt;/em&gt; people are active internet users. That's 59.6% of the entire planet. Why is this such a big deal? Merely nine years ago it was half that number.&lt;/p&gt;

&lt;p&gt;Well, okay, but what does this have to with responsive design? Consider that &lt;a href="https://backlinko.com/mobile-seo-guide#chapter1" rel="noopener noreferrer"&gt;58%&lt;/a&gt; of all Google searches are made from a phone. If you haven't taken this into account, and a user comes across your shiny new site while riding the train...oh no!&lt;/p&gt;




&lt;p&gt;&lt;a href="https://i.giphy.com/media/mAIFQ0uBigV6LOwmI9/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/mAIFQ0uBigV6LOwmI9/giphy.gif" alt="unresponsive"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;Not to worry though, we have a plan.&lt;/p&gt;

&lt;p&gt;It is very possible to have a website that looks great on a desktop, &lt;em&gt;and&lt;/em&gt; a phone, &lt;em&gt;and&lt;/em&gt; tablet, &lt;em&gt;and&lt;/em&gt; even on that fancy refrigerator screen.&lt;/p&gt;




&lt;p&gt;&lt;a href="https://i.giphy.com/media/26gsl2WC5tRxkemdi/giphy.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://i.giphy.com/media/26gsl2WC5tRxkemdi/giphy.gif" alt="salt bae"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;Let's leverage the aptly named &lt;strong&gt;mobile-first&lt;/strong&gt; approach.&lt;/p&gt;

&lt;p&gt;To follow a mobile first strategy begin by building for a smaller screen width. Then add or rearrange components as device size increases, progressing naturally. Doing so, all of the content you created to make available &lt;em&gt;is&lt;/em&gt; given to your end-user.&lt;/p&gt;

&lt;p&gt;This is also known as &lt;strong&gt;progressive enhancement&lt;/strong&gt;, the industry standard.&lt;/p&gt;

&lt;p&gt;As opposed to designing a beautiful desktop website only to have to "shave off" components accommodate smaller devices. In the olden days this practice was known as &lt;strong&gt;graceful degradation&lt;/strong&gt;.&lt;/p&gt;




&lt;blockquote&gt;
&lt;p&gt;The web’s moved beyond the desktop, and it’s not looking back. The number of devices we’re designing for is growing just as quickly as mobile traffic. - Ethan Marcotte&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  How
&lt;/h2&gt;

&lt;p&gt;As with almost anything related to code or design within &lt;strong&gt;mobile-first&lt;/strong&gt; lies much nuance. With that in mind, know that progressive enhancement begins with good fundamentals.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Clean, semantic HTML&lt;/li&gt;
&lt;li&gt;Responsive CSS&lt;/li&gt;
&lt;li&gt;Accessibility&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We will go over these points, and what they mean, but there is much more out there to learn. This is not meant to be a comprehensive guide.&lt;/p&gt;




&lt;h2&gt;
  
  
  HTML
&lt;/h2&gt;

&lt;p&gt;In this respect nothing new is added, no special tags or attributes.&lt;/p&gt;

&lt;p&gt;However, this is arguably your most important component. The foundation propping up strong, responsive design starts with the HTML tags we should all be familiar with.&lt;/p&gt;

&lt;p&gt;Now, this may sound obvious, but the benefits here can't be understated.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Codebase becomes easier to read and maintain&lt;/li&gt;
&lt;li&gt;Stylesheet organization is simplified&lt;/li&gt;
&lt;li&gt;First steps of accessibility.
Just by keeping content within markup tags that describe it, so much has been achieved.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Some examples of semantic elements:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;article&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;aside&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;section&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;nav&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;header&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;footer&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;blockquote&amp;gt;&lt;/span&gt;

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

&lt;/div&gt;




&lt;h1&gt; - &lt;h6&gt;
&lt;br&gt;
&lt;/h6&gt;
&lt;/h1&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;[HTML elements reference](https://developer.mozilla.org/en-US/docs/Web/HTML/Element) by Mozilla.

Keep in mind that semantic HTML is markup that presents meaning to the web page. In other words, describing *what* the content is not simply how it looks. This will be handled by the styling.
___
## CSS

As we begin to add styling to our HTML we will take full advantage of the cascading behavior of CSS. Beginning with (surprise!) our mobile styling rules first.

Taking it one step further, to set ourselves up for success we can consider defining **all** of our core design features in the first few lines. And later, modify elements as needed.

Here's an example of setting the tone for your mobile-first stylesheet.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;br&gt;
css&lt;br&gt;
body {&lt;br&gt;
  font-size: 16px; /* base font size &lt;em&gt;/&lt;br&gt;
  margin: 0;       /&lt;/em&gt; strip default margins &lt;em&gt;/&lt;br&gt;
  width: 100%;     /&lt;/em&gt; fill entire screen */&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;/* set font rules */&lt;br&gt;
body { font-family: Verdana, sans-serif; }&lt;br&gt;
h1, h2 { font-family: 'Times New Roman', serif; }&lt;/p&gt;

&lt;p&gt;/* ##### begin mobile specific styles ##### */&lt;/p&gt;

&lt;p&gt;/* set base font sizes */&lt;br&gt;
h1 { font-size: 2.5rem; }&lt;br&gt;
h2 { font-size: 1.85rem; }&lt;br&gt;
h3 { font-size: 1.3rem; }&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Wait, wait...there's more to it than that. Ah, yes I almost forgot.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;br&gt;
css&lt;br&gt;
header {&lt;br&gt;
  background-color: #8890ff;&lt;br&gt;
  padding: 2em;&lt;br&gt;
 }&lt;/p&gt;

&lt;p&gt;article {&lt;br&gt;
  margin: 2em auto;&lt;br&gt;
  padding: 2em&lt;br&gt;
}&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Voilà, a basic phone design.
___
![mobile design](https://dev-to-uploads.s3.amazonaws.com/i/psl3eryikf642qljyjlb.png)
___
Granted, this probably won't have investors begging to throw money at us. It will however get us to our first break point, but first let's talk about what this `em` and `rem` stuff is about.

Why not just use `px`?

A big part of creating layouts that respond to various screen widths is using relative lengths to express how space should be occupied.

By expressing sizes in relative, instead of fixed, length we allow our design some breathing room and flexibility. Fixed measurements can certainly be useful given the right circumstance, but overuse can create more work.

___
&amp;gt; Design is a funny word. Some people think design means how it looks. But of course, if you dig deeper, it’s really how it works. - Steve Jobs

___
Inevitably there will come a certain screen width falls apart. Usually quite literally as your content becomes stretched across the screen.
___
![stretch](https://media.giphy.com/media/3orieTDfIEkjp8Ti9y/giphy.gif)
___
Aha! The moment we've been waiting for has arrived. By this point, we've built out well-structured, semantic HTML. We have tackled our baseline styles. Now, we add our first breakpoint.

A breakpoint is a rule we set to let the browser know how to handle certain scenarios, such as wider screens. We create breakpoints when our *design* fails, for whatever reason. This distinction is important. We are building around the design **not** the device.

To accomplish this goal we declare media queries by using the `@media` rule. Here's an example:
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;br&gt;
css&lt;br&gt;
&lt;a class="mentioned-user" href="https://dev.to/media"&gt;@media&lt;/a&gt; (min-width: 800px) {&lt;/p&gt;

&lt;p&gt;#description { text-align: center; }&lt;/p&gt;

&lt;p&gt;article { display: flex; }&lt;/p&gt;

&lt;p&gt;p { margin: 1em; }&lt;/p&gt;

&lt;p&gt;}&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Nothing award-winning but our showcase does display the power of media queries.
___
![media query](https://dev-to-uploads.s3.amazonaws.com/i/67nz1z6j9kv6q8hb8dx5.png)
___
Once more for the people in the back. The purpose of setting up our design like this isn't merely to create multiple designs for multiple devices. We're building for the public while keeping ourselves and other developers in mind.

By following the pattern of our design, we avoid creating arbitrary breakpoints to oblige the latest device on the market.
___
## Meta Tags

Giving the browser information on the code it is receiving is a vital step in communication to ensure our designs fall into place.

Without a couple simple tags parts of our page can possibly render quite differently than we expect.

Without going too much into pixels and retina displays. The most common way to instruct your browser to define width is by setting the viewport.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;br&gt;
html&lt;br&gt;
&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Mozilla delivers a [good explanation](https://developer.mozilla.org/en-US/docs/Mozilla/Mobile/Viewport_meta_tag) on why this is crucial.

Also, be sure to help out your browser and declare your charset.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;br&gt;
css&lt;br&gt;
@charset "UTF-8";&lt;/p&gt;



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

Check out this [article](https://bitsofco.de/meta-charset/) for more info.

## In Closing
Keep in mind there is much more to consider with designing a responsive website.
* Proper copy sizing
* Managing link sizes
* Bandwidth limits
* Responsive images
* **The entire world of JavaScript**

Examples were kept overly-simple to push that implication and encourage research.

If you are working with JavaScript there are several libraries and frameworks, like **[Pure.css](https://purecss.io/)**, or **[Bootstrap](https://getbootstrap.com/)** that can assist you with responsive elements. These are very powerful tools that can benefit extremely with a fundamental knowledge of the **mobile-first** approach.

For anyone looking for a quick start with some pre-made code I've added the [github repo](https://github.com/ncaudill27/responsive-example) to our above example. Feel free to use it how you see fit. Happy hacking!
___
You can't use up creativity. The more you use, the more you have. - Maya Angelou
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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