<?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: Maria del Carmen Santiago</title>
    <description>The latest articles on DEV Community by Maria del Carmen Santiago (@santiagocodes).</description>
    <link>https://dev.to/santiagocodes</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%2F412646%2Fe3d174f2-d7ac-46ed-ad4d-8b20af6e76f3.jpg</url>
      <title>DEV Community: Maria del Carmen Santiago</title>
      <link>https://dev.to/santiagocodes</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/santiagocodes"/>
    <language>en</language>
    <item>
      <title>How to avoid infinite loops onIonChange.  </title>
      <dc:creator>Maria del Carmen Santiago</dc:creator>
      <pubDate>Fri, 18 Feb 2022 17:54:13 +0000</pubDate>
      <link>https://dev.to/santiagocodes/how-to-avoid-infinite-loops-onionchange-2fjh</link>
      <guid>https://dev.to/santiagocodes/how-to-avoid-infinite-loops-onionchange-2fjh</guid>
      <description>&lt;p&gt;&lt;strong&gt;Backstory&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;I encountered a problem at work while creating a search page with several filters using an &lt;a href="https://ionicframework.com/docs/api/select"&gt;IonSelect&lt;/a&gt; for each. The problem came when I added a 'clear all' button to clear the filters, which threw me into a neverending loop.&lt;/em&gt; 😱&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;My solution&lt;/strong&gt; &lt;/p&gt;

&lt;p&gt;1) Imported the &lt;a href="https://reactjs.org/docs/hooks-state.html"&gt;useState Hook&lt;/a&gt; and declared a state variable like the one below.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;isResetting&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;setIsResetting&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;useState&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;2) Created a reset button which would change the state variable to &lt;code&gt;true&lt;/code&gt; when clicked.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;onClick&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;setIsResetting&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;)}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;3) Imported the &lt;a href="https://reactjs.org/docs/hooks-effect.html"&gt;useEffect hook&lt;/a&gt; and set it to run only when &lt;code&gt;isResetting&lt;/code&gt; changes. What I wanted to achieve here was for the &lt;code&gt;resetAllFilters&lt;/code&gt; function (step 4) to run only when &lt;code&gt;isResetting&lt;/code&gt; is set to &lt;code&gt;true&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="nx"&gt;useEffect&lt;/span&gt;&lt;span class="p"&gt;(()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;isResetting&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="nx"&gt;resetAllFilters&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;isResetting&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;4) Created the &lt;code&gt;resetAllFilters&lt;/code&gt; function, which should change the value of all the filters. The last line on this function should be to change the state variable &lt;code&gt;isResetting&lt;/code&gt; back to &lt;code&gt;false&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;resetAllFilters&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// insert your code &lt;/span&gt;
    &lt;span class="nx"&gt;setIsResetting&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kc"&gt;false&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;5) Last but not least, I made sure that when the state variable &lt;code&gt;isResetting&lt;/code&gt; is set to &lt;code&gt;true&lt;/code&gt; the &lt;code&gt;IonSelect&lt;/code&gt; does not change its value, thereby avoiding going into an infinite loop.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="o"&gt;&amp;lt;&lt;/span&gt;&lt;span class="nx"&gt;IonSelect&lt;/span&gt;
    &lt;span class="nx"&gt;multiple&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nx"&gt;placeholder&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Select tags&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
    &lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;filters&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;tags&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="nx"&gt;placeholder&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Select tags&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
    &lt;span class="nx"&gt;onIonChange&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="nx"&gt;isResetting&lt;/span&gt; &lt;span class="p"&gt;?&lt;/span&gt; &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;reset at work&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;applyFilter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;tags&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;detail&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;)}&lt;/span&gt;                                     &lt;span class="o"&gt;&amp;gt;&lt;/span&gt;

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

&lt;/div&gt;



&lt;p&gt;And voila! With these 5 steps I solved my problem at work. &lt;/p&gt;

&lt;p&gt;I didn't find any other solutions online, but would love to hear if anyone else has encounted this problem and solved it in a different way.  &lt;/p&gt;




&lt;p&gt;If you liked what you read hit that ❤️ on the left or wherever it is. If you really liked it don’t forget to share it with the community by hitting that dot-dot-dot icon near the heart. &lt;/p&gt;

&lt;p&gt;💻 &lt;strong&gt;article.close()&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>ionic</category>
      <category>react</category>
      <category>loop</category>
      <category>hooks</category>
    </item>
    <item>
      <title>Filtering Component using Vanilla JS and HTML Content Template Element.</title>
      <dc:creator>Maria del Carmen Santiago</dc:creator>
      <pubDate>Tue, 24 Nov 2020 17:46:14 +0000</pubDate>
      <link>https://dev.to/santiagocodes/filtering-component-using-vanilla-js-and-html-content-template-template-element-2iia</link>
      <guid>https://dev.to/santiagocodes/filtering-component-using-vanilla-js-and-html-content-template-template-element-2iia</guid>
      <description>&lt;p&gt;&lt;em&gt;Create your own filtering component using TailwindCSS, HTML content &lt;code&gt;&amp;lt;template&amp;gt;&lt;/code&gt; element, and JavaScript (yeap, no JS framework needed). Not all projects require the use of frameworks and this is a solution for those simpler projects.&lt;/em&gt;&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;FYI You can skip the explanation and take a look at the whole code in the CodePen at the end of this article. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Creating a filtering component can be done by writing hundreds of lines of HTML code and controlling the material shown by changing the 'display' property from 'none' to 'block'. &lt;/p&gt;

&lt;p&gt;That's fine, but you can also use the power of JavaScript so as to not repeat the same HTML code over and over again. All you need to do to get started is to create one single template in your HTML and learn how to copy said template and manipulate it using JavaScript.   &lt;/p&gt;

&lt;h2&gt;
  
  
  TailWindCSS
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://tailwindcss.com/"&gt;TailWind CSS&lt;/a&gt; is a utility-first CSS framework that helps you design directly on your markup. Installation can be a little tricky, but you can always just add the CDN link &lt;code&gt;&amp;lt;link href="https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css" rel="stylesheet"&amp;gt;&lt;/code&gt; at the &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt; of your HTML document to get you started quickly. &lt;/p&gt;

&lt;p&gt;For those of you that already know Tailwind, have you checked out version 2.0? They have added some really cool features like dark mode and animations. I'll be having a deeper look at it myself this weekend. #funcoding&lt;/p&gt;

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

&lt;p&gt;In your HTML you want to look into creating your own &lt;a href="https://www.w3schools.com/tags/tag_template.asp"&gt;&lt;code&gt;&amp;lt;template&amp;gt;&lt;/code&gt; tag&lt;/a&gt;. The content held within the template tag will be hidden when the page loads. You have to use JavaScript in order to create a clone of this template and attach it to the body of your document for it to be displayed.  &lt;/p&gt;

&lt;p&gt;For this mini-project example, we will have a few buttons at the top of the page and below them, we will display a few cards with information on them. No need to know what the information is right now, just the structure of it.  &lt;/p&gt;

&lt;p&gt;You can give this project whatever style you want, but what's important is to add a &lt;code&gt;btnFilter&lt;/code&gt; class to all the filtering buttons. The buttons will also need their own identifying IDs. The section(or div) element that will contain all the copies/clones of the template will need an ID (&lt;code&gt;resourcesContainer&lt;/code&gt;) as well as the elements we want to manipulate with JavaScript that are found within the template (&lt;code&gt;resource&lt;/code&gt;, &lt;code&gt;title&lt;/code&gt;, &lt;code&gt;description&lt;/code&gt;, and &lt;code&gt;tagsContainer&lt;/code&gt;).&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="c"&gt;&amp;lt;!-- buttons section --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;section&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"mt-10 text-center"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"all"&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"btnFilter text-gray-100 font-bold py-1 px-3 my-4 rounded-full border-2 shadow-2xl bg-gradient-to-b from-blue-700 to-teal-400 md:my-0 md:mx-2 hover:from-blue-600 hover:to-teal-300 hover:border-teal-400 focus:outline-none focus:shadow-outline"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
        All
      &lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"html"&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"btnFilter text-gray-100 font-bold py-1 px-3 my-4 rounded-full border-2 shadow-2xl bg-gradient-to-b from-blue-700 to-teal-400 md:my-0 md:mx-2 hover:from-blue-600 hover:to-teal-300 hover:border-teal-400 focus:outline-none focus:shadow-outline"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
        HTML
      &lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"css"&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"btnFilter text-gray-100 font-bold py-1 px-3 my-4 rounded-full border-2 shadow-2xl bg-gradient-to-b from-blue-700 to-teal-400 md:my-0 md:mx-2 hover:from-blue-600 hover:to-teal-300 hover:border-teal-400 focus:outline-none focus:shadow-outline"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
        CSS
      &lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"js"&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"btnFilter text-gray-100 font-bold py-1 px-3 my-4 rounded-full border-2 shadow-2xl bg-gradient-to-b from-blue-700 to-teal-400 md:my-0 md:mx-2 hover:from-blue-600 hover:to-teal-300 hover:border-teal-400 focus:outline-none focus:shadow-outline"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
        JavaScript
      &lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/section&amp;gt;&lt;/span&gt;

&lt;span class="c"&gt;&amp;lt;!-- RESOURCES CONTAINER section div --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;section&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"resourcesContainer"&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"w-full flex flex-wrap content-center justify-around mx-auto px-2 py-5 md:px-4 lg:px-10"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;

  &lt;span class="c"&gt;&amp;lt;!-- TEMPLATE resource card --&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;template&amp;gt;&lt;/span&gt;
    &lt;span class="c"&gt;&amp;lt;!-- CARD --&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;article&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"resource"&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"flex flex-col overflow-hidden rounded-lg shadow-2xl w-64 m-4 bg-teal-400 text-center lg:w-3/12 lg:m-8"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"rounded-md bg-blue-100 text-blue-600 m-4 p-2 flex-grow flex flex-col justify-between"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="nt"&gt;&amp;lt;header&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"font-bold text-lg text-blue-700 underline"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;h2&amp;gt;&lt;/span&gt;
              &lt;span class="nt"&gt;&amp;lt;a&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"title"&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"#"&lt;/span&gt; &lt;span class="na"&gt;target=&lt;/span&gt;&lt;span class="s"&gt;"_blank"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
              &lt;span class="nt"&gt;&amp;lt;/a&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;/h2&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;p&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"description"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
          &lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
          &lt;span class="c"&gt;&amp;lt;!-- TAGS --&amp;gt;&lt;/span&gt;
          &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;'tagsContainer'&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"pt-4 flex justify-around flex-wrap"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt; 
          &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
          &lt;span class="c"&gt;&amp;lt;!-- TAGS end --&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;/article&amp;gt;&lt;/span&gt;
      &lt;span class="c"&gt;&amp;lt;!-- CARD end --&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/template&amp;gt;&lt;/span&gt;
  &lt;span class="c"&gt;&amp;lt;!-- TEMPLATE resource card end --&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;/section&amp;gt;&lt;/span&gt;
&lt;span class="c"&gt;&amp;lt;!-- RESOURCES CONTAINER section div end --&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I won't explain the classes as, aside from &lt;code&gt;btnFilter&lt;/code&gt;, all are TailWind CSS classes. These help style my component without adding a single line of CSS code, but for the sake of explaining a few: &lt;code&gt;mt-10&lt;/code&gt; just means &lt;code&gt;margin-top: 2.5rem;&lt;/code&gt;, &lt;code&gt;md:my-0&lt;/code&gt; means at medium-sized screens &lt;code&gt;margin-top&lt;/code&gt; and &lt;code&gt;margin-bottom&lt;/code&gt; are set to &lt;code&gt;0px&lt;/code&gt;, and &lt;code&gt;hover:border-teal-400&lt;/code&gt; means that on hover the element's border will be a shade of the color teal. Most can be quite self-explanatory. &lt;/p&gt;

&lt;p&gt;With TailWind, I recommend starting the design for mobile screens and add extra classes for bigger screens after that.    &lt;/p&gt;

&lt;h2&gt;
  
  
  JavaScript
&lt;/h2&gt;

&lt;p&gt;Now comes the fun part! Let's start this part by collecting a few initial resources (or any dummy data) and adding them to our &lt;code&gt;dataResources&lt;/code&gt; array.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;dataResources&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;title&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;FlexBox Froggy&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;link&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https://flexboxfroggy.com/&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;description&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;A game where you help Froggy and friends by writing CSS code!&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;tags&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;all&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;css&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;game&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;title&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;freeCodeCamp&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;link&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https://www.freecodecamp.org/&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;description&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Learn to code at home. Build projects. Earn certifications.&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;tags&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;all&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;html&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;css&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;js&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;certification&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
  &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;title&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;State of JavaScript&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;link&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;https://stateofjs.com/&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;description&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Find out which libraries developers want to learn next, satisfaction ratings, and much more.&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;tags&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;all&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;js&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;survey&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;]&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now for our first function, we are going to filter the dataResources array to match the category with the tags in each resource. If any of the tags match the category chosen then we will clone the template of the card and use the data of said resource on it. Then we will take this newly cloned card and append/attach it to the resources div/section container. The same will be repeated for all the resources that match to create a new card for each. For those that don't match the category, nothing will happen.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;resources&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#resourcesContainer&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;category&lt;/span&gt;&lt;span class="o"&gt;=&lt;/span&gt;&lt;span class="dl"&gt;""&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;filteredDataResources&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[];&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;filterResources&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;category&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// filter data&lt;/span&gt;
  &lt;span class="nx"&gt;filteredDataResources&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;dataResources&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;filter&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nx"&gt;resourceData&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;resourceData&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;tags&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;includes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;category&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
       &lt;span class="c1"&gt;// clone new card&lt;/span&gt;
       &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;resourceCard&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;copyTemplateCard&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;resourceData&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
       &lt;span class="c1"&gt;// attach new card to container&lt;/span&gt;
       &lt;span class="nx"&gt;resources&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;appendChild&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;resourceCard&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; 
  &lt;span class="p"&gt;})&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c1"&gt;// call filterResources function to display all cards with an `all` tag on their tag list.&lt;/span&gt;

&lt;span class="nf"&gt;filterResources&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;all&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;How are the new cards getting cloned from the template? For that let's dive into our second function, which got called each time a resource would pass through the filter from our filterResources function.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;template&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;template&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; 
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;copyTemplateCard&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;resourceData&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// clone template&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;resourceTemplate&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;importNode&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;template&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;content&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;card&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;resourceTemplate&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#resource&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="c1"&gt;// insert title information from array&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;title&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;card&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#title&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;title&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;innerText&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;resourceData&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;title&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nx"&gt;title&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;href&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;resourceData&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;link&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="c1"&gt;// insert description information from array&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;description&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;card&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#description&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nx"&gt;description&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;innerText&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;resourceData&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;description&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="c1"&gt;// insert tag information from array  &lt;/span&gt;
  &lt;span class="nx"&gt;tagsContainer&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;card&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#tagsContainer&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="c1"&gt;// map though tags to create a tag element for each tag in the array&lt;/span&gt;
  &lt;span class="nx"&gt;resourceData&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;tags&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;map&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;resourceDataTag&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;individualTag&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createElement&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;span&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="c1"&gt;// create a tag for all tags except the first one called 'all'&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nx"&gt;resourceDataTag&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;all&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="c1"&gt;// add styles&lt;/span&gt;
      &lt;span class="nx"&gt;individualTag&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;classList&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;inline-block bg-teal-400 text-blue-100 rounded-full px-3 py-1 mb-1 text-sm font-semibold&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;
    &lt;span class="c1"&gt;// add text&lt;/span&gt;
    &lt;span class="nx"&gt;individualTag&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;innerHTML&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;`#&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;resourceDataTag&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;
    &lt;span class="c1"&gt;// append/atach tag to tags container&lt;/span&gt;
    &lt;span class="nx"&gt;tagsContainer&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;appendChild&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;individualTag&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; 
  &lt;span class="p"&gt;})&lt;/span&gt;
  &lt;span class="c1"&gt;// return the new cloned card with the information from the array inserted into it.&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;card&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Almost done with our functions. Now we want to be able to change the category of the filtered items shown. We can do that with a short function. Within it, we will clear the container holding all the cards. You want to do this because otherwise every time you select a new category new cards will be cloned without getting rid of the previous cards. &lt;/p&gt;

&lt;p&gt;After that, we will change our &lt;code&gt;category&lt;/code&gt; variable to equal the ID of the button pressed (which is why it was important for each button to have its own unique ID). With the category changed we can call the filterResourses function with the new category as a parameter, so as to filter the dataResources array once more and create our new cards according to this new category.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;fillResourcesContainer&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;resources&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;innerHTML&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;""&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nx"&gt;category&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;this&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;id&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nx"&gt;resources&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nf"&gt;filterResources&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;category&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now just add an event listener to each button and there you go!&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;btnFilter&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelectorAll&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;.btnFilter&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="nx"&gt;btnFilter&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;forEach&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;btn&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;btn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;click&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;fillResourcesContainer&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Demo
&lt;/h2&gt;

&lt;p&gt;Feel free to fork and play with this CodePen and add as many different features to it as you see fit. An example that I did elsewhere was to change the color of the tags according to their category using &lt;code&gt;switch statement&lt;/code&gt;.&lt;/p&gt;

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




&lt;p&gt;If you liked what you read hit that ❤️ on the left or wherever it is. If you really liked it don’t forget to share it with the community by hitting that dot-dot-dot icon near the heart. &lt;/p&gt;

&lt;p&gt;💻 &lt;strong&gt;article.close()&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>webdev</category>
      <category>tutorial</category>
      <category>wecoded</category>
    </item>
    <item>
      <title>The 3Gs of CSS3: Grid Edition</title>
      <dc:creator>Maria del Carmen Santiago</dc:creator>
      <pubDate>Thu, 24 Sep 2020 15:22:12 +0000</pubDate>
      <link>https://dev.to/santiagocodes/the-3gs-of-css3-grid-edition-7k5</link>
      <guid>https://dev.to/santiagocodes/the-3gs-of-css3-grid-edition-7k5</guid>
      <description>&lt;p&gt;&lt;em&gt;A Collection of &lt;strong&gt;G&lt;/strong&gt;uides, &lt;strong&gt;G&lt;/strong&gt;ames, and &lt;strong&gt;G&lt;/strong&gt;enerators useful for your everyday CSS needs. The idea behind this collection is to help you become a better CSS developer by providing resources to help you understand the concepts and generators that will make you more efficient.&lt;/em&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  &lt;strong&gt;Grid&lt;/strong&gt;
&lt;/h1&gt;

&lt;p&gt;CSS Grid is a tool you can use to create wonderfully responsive layouts without having to rely on using queries. For one-dimensional layouts (rows OR columns), take a look at my 3Gs of &lt;a href="https://dev.to/santiagocodes/the-3gs-of-css-flexbox-edition-4b64"&gt;FlexBox&lt;/a&gt; article. For two-dimensional layouts (rows AND columns), Grid is the solution for you.   &lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;G&lt;/strong&gt;uide
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://css-tricks.com/snippets/css/complete-guide-grid/"&gt;CSS Tricks&lt;/a&gt; has a complete CSS Grid Guide with illustrations focusing on all the settings available for the parent container and its child elements. You can even buy a poster from them to hang on your wall (to go with your FlexBox one).&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--BX_eiqvO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/gaf1vzsio4vk4agna4l7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--BX_eiqvO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/gaf1vzsio4vk4agna4l7.png" alt="ScreenShoot of CSS Tricks' Grid Guide"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Alternative: &lt;a href="https://learncssgrid.com/"&gt;Learn CSS Grid&lt;/a&gt; by &lt;a href="https://twitter.com/jonsuh"&gt;jonsuh&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;G&lt;/strong&gt;ames
&lt;/h2&gt;

&lt;h3&gt;
  
  
  GridGarden
&lt;/h3&gt;

&lt;p&gt;Water your carrot garden with &lt;a href="http://cssgridgarden.com"&gt;CSS GridGarden&lt;/a&gt;. With this simple game, you get to practice your CSS Grid skills.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--88lUmsvX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/amm1yvdj9hfrprdxbnuw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--88lUmsvX--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/amm1yvdj9hfrprdxbnuw.png" alt="Screenshot of CSS Grid Garden"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  GridCritters
&lt;/h3&gt;

&lt;p&gt;For an adventure-filled game, take a look at Mastery Games' &lt;a href="https://gridcritters.com/"&gt;GridCritters&lt;/a&gt;. Price: &lt;del&gt;$179&lt;/del&gt; $99&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--U0KqBfSz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/qdhyf6vpxh2vqr67zf69.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--U0KqBfSz--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/qdhyf6vpxh2vqr67zf69.png" alt="Screenshot of Grid Critters"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  CSS Diner
&lt;/h3&gt;

&lt;p&gt;Not a Grid game, but useful for it nonetheless. &lt;a href="https://flukeout.github.io/"&gt;CSS Diner&lt;/a&gt; is the game to play if you want to learn the ins-and-outs of CSS selectors. You can later use this to select the elements you want to apply Grid to.  &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s---vGKWLGV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/t22qmgxgridzl38m063v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s---vGKWLGV--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/t22qmgxgridzl38m063v.png" alt="Screenshot of CSS Diner"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;G&lt;/strong&gt;enerator
&lt;/h2&gt;

&lt;p&gt;In the spirit of not memorizing every concept, use one of the many generators available online. &lt;a href="https://grid.layoutit.com/"&gt;LayOutIt!&lt;/a&gt; stood out for me from the rest as you are but a click away from taking your generated grid into CodePen (how cool is that?! 😃 ). &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--6O6YxFx9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/7s2jl3s7r4b1aq6dceax.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6O6YxFx9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/7s2jl3s7r4b1aq6dceax.png" alt="Screenshot of Layoutit"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Alternatives: &lt;a href="https://alialaa.github.io/css-grid-cheat-sheet/"&gt;CSS Grid Cheat Sheet&lt;/a&gt; by alialaa and &lt;a href="https://cssgrid-generator.netlify.app/"&gt;CSS Grid Generator&lt;/a&gt; by sarah_edo.&lt;/p&gt;

&lt;h2&gt;
  
  
  Bonus: Video Tutorials
&lt;/h2&gt;

&lt;p&gt;For a quick look at CSS Grids, check out Jenn Lukas' &lt;a href="https://www.youtube.com/watch?v=FwiSbmyNQ18"&gt;How to use CSS grid layout in 60 seconds!&lt;/a&gt; video on the Women Techmakers' youtube channel. &lt;/p&gt;

&lt;p&gt;Want a more in-depth look? Wes Bos has an amazing (and free!) 4-hour course on CSS Grid. You can find the 25 videos on &lt;a href="https://cssgrid.io/"&gt;cssgrid.io&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--vi58F56I--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ad02cwskdmeck2z671ik.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vi58F56I--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/ad02cwskdmeck2z671ik.png" alt="25 videos of Grid"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;If you liked what you read hit that ❤️ on the left or wherever it is. If you really liked it don’t forget to share it with the community by hitting that dot-dot-dot icon near the heart. &lt;/p&gt;

&lt;p&gt;💻 &lt;strong&gt;article.close()&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>css</category>
      <category>codenewbie</category>
      <category>beginners</category>
      <category>webdev</category>
    </item>
    <item>
      <title>The 3Gs of CSS3: FlexBox Edition</title>
      <dc:creator>Maria del Carmen Santiago</dc:creator>
      <pubDate>Thu, 10 Sep 2020 14:31:53 +0000</pubDate>
      <link>https://dev.to/santiagocodes/the-3gs-of-css-flexbox-edition-4b64</link>
      <guid>https://dev.to/santiagocodes/the-3gs-of-css-flexbox-edition-4b64</guid>
      <description>&lt;p&gt;&lt;em&gt;A Collection of &lt;strong&gt;G&lt;/strong&gt;uides, &lt;strong&gt;G&lt;/strong&gt;ames, and &lt;strong&gt;G&lt;/strong&gt;enerators useful for your everyday CSS needs. The idea behind this collection is to help you become a better CSS developer by providing resources to help you understand the concepts and generators that will help you become more efficient.&lt;/em&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  &lt;strong&gt;Flexbox&lt;/strong&gt;
&lt;/h1&gt;

&lt;p&gt;Flexbox is a powerful layout tool that lets you solve responsive web design problems without needing to use media queries. &lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;G&lt;/strong&gt;uide
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://css-tricks.com/snippets/css/a-guide-to-flexbox/"&gt;CSS Tricks&lt;/a&gt; has a complete guide with illustrations that will help you visualize the power of flexbox. You can even buy a poster from them to hang on your wall.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--kBYINYve--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/eqp2n36kavc4nl1qbmpf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--kBYINYve--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/eqp2n36kavc4nl1qbmpf.png" alt="Flexbox guide Preview"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;G&lt;/strong&gt;ames
&lt;/h2&gt;

&lt;p&gt;Move the froggy to the lilypad with &lt;a href="http://flexboxfroggy.com/"&gt;FlexBox Froggy&lt;/a&gt;. A very simple kid-like game that will help you understand flexbox.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--fAXHu5H1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/5997hgelxhgz9z5jwhi7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fAXHu5H1--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/5997hgelxhgz9z5jwhi7.png" alt="FlexBox Froggy screenshot"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Kiddy games not your thing? How about a war-like game? With &lt;a href="http://www.flexboxdefense.com/"&gt;FlexBox Defense&lt;/a&gt; you have to stop the enemies from getting past your defense using the power of flexbox! &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--WLI2C3qO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/lkgzgslgaqtekwpezvh7.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--WLI2C3qO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/lkgzgslgaqtekwpezvh7.png" alt="Flexbox Defense screenshot"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You can kill zombies with &lt;a href="https://flexboxzombies.com/p/flexbox-zombies"&gt;FlexBox Zombies&lt;/a&gt;. This one follows a storyline so don’t forget that you are actually coding when playing this game. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--37uiaVZq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/rcorgamn4xm3zwjhrwpr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--37uiaVZq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/rcorgamn4xm3zwjhrwpr.png" alt="Flexbox Zombies screenshot"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;G&lt;/strong&gt;enerator
&lt;/h2&gt;

&lt;p&gt;Just because you understand a concept doesn’t mean you need to memorize everything. &lt;a href="https://the-echoplex.net/flexyboxes"&gt;Flexy Boxes&lt;/a&gt; is an amazing tool to have when solving your layout problems. Add as many items as you need and see in real-time what each property will do to each of them.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--hyEYzu9a--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/o8ybi0d0iw2kalo4smsb.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hyEYzu9a--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/o8ybi0d0iw2kalo4smsb.gif" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Alternative: &lt;a href="https://bennettfeely.com/flexplorer/"&gt;flexplorer&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Bonus: VS Code Extension
&lt;/h2&gt;

&lt;p&gt;I was not going to add this, but this extension got better with the last update and it is now more interactive! Check out &lt;a href="https://marketplace.visualstudio.com/items?itemName=dzhavat.css-flexbox-cheatsheet"&gt;CSS Flexbox Cheatsheet&lt;/a&gt; VS code extension. If you don’t know how to install this, you can take a look at my previous article on &lt;a href="https://dev.to/santiagocodes/top-10-essential-vs-code-extensions-e37"&gt;VS Code Extensions&lt;/a&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--WNhjLKSr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/8duhax3gqksi4q6razyo.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--WNhjLKSr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_66%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/8duhax3gqksi4q6razyo.gif" alt="CSS Flexbox Cheatsheet"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;If you liked what you read hit that ❤️ on the left or wherever it is. If you really liked it don’t forget to share it with the community by hitting that dot-dot-dot icon near the heart. &lt;/p&gt;

&lt;p&gt;💻 &lt;strong&gt;article.close()&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>css</category>
      <category>codenewbie</category>
      <category>webdev</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Exploring Github: Developer RoadMaps, Octocats, and more!</title>
      <dc:creator>Maria del Carmen Santiago</dc:creator>
      <pubDate>Tue, 25 Aug 2020 12:24:07 +0000</pubDate>
      <link>https://dev.to/santiagocodes/exploring-github-developer-roadmaps-octocats-and-more-3gi3</link>
      <guid>https://dev.to/santiagocodes/exploring-github-developer-roadmaps-octocats-and-more-3gi3</guid>
      <description>&lt;p&gt;&lt;em&gt;Github is more than just a place to store your code. Explore Github and use it as a tool for your open-source education and more.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;With its first commit in October 2007, Github has provided hosting and version control for developers all around the globe. But I wonder, have you explored all Github has to offer? &lt;/p&gt;

&lt;h2&gt;
  
  
  Learn to Code
&lt;/h2&gt;

&lt;p&gt;I encourage you to go to the 'explore' section and take a look at all this site has to offer. For example, go to &lt;a href="https://github.com/collections/learn-to-code"&gt;github.com/collections/learn-to-code&lt;/a&gt; for a collection of resources that can help you further your coding education. &lt;/p&gt;

&lt;p&gt;Here you can find some good material for your learning journey, including a very comprehensive Developer RoadMap for this year. &lt;/p&gt;


&lt;div class="ltag-github-readme-tag"&gt;
  &lt;div class="readme-overview"&gt;
    &lt;h2&gt;
      &lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--vJ70wriM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://practicaldev-herokuapp-com.freetls.fastly.net/assets/github-logo-ba8488d21cd8ee1fee097b8410db9deaa41d0ca30b004c0c63de0a479114156f.svg" alt="GitHub logo"&gt;
      &lt;a href="https://github.com/kamranahmedse"&gt;
        kamranahmedse
      &lt;/a&gt; / &lt;a href="https://github.com/kamranahmedse/developer-roadmap"&gt;
        developer-roadmap
      &lt;/a&gt;
    &lt;/h2&gt;
    &lt;h3&gt;
      Roadmap to becoming a web developer in 2020
    &lt;/h3&gt;
  &lt;/div&gt;
  &lt;div class="ltag-github-body"&gt;
    
&lt;div id="readme" class="md"&gt;
&lt;p&gt;&lt;a rel="noopener noreferrer" href="https://camo.githubusercontent.com/f22bb956aacd059ef8819c40c55e49e700b0ea49/68747470733a2f2f692e696d6775722e636f6d2f4e4e796339514d2e706e67"&gt;&lt;img src="https://camo.githubusercontent.com/f22bb956aacd059ef8819c40c55e49e700b0ea49/68747470733a2f2f692e696d6775722e636f6d2f4e4e796339514d2e706e67" alt="Web Developer Roadmap - 2020"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Roadmap to becoming a web developer in 2020&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;&lt;a href="http://roadmap.sh" rel="nofollow"&gt;&lt;img src="https://camo.githubusercontent.com/7bc9822560f33da24c0b27e86af27215d0ead1b3/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f2d526f61646d6170732532302d3061306130612e7376673f7374796c653d666c617426636f6c6f72413d306130613061" alt=""&gt;&lt;/a&gt;
&lt;a href="http://roadmap.sh/guides" rel="nofollow"&gt;&lt;img src="https://camo.githubusercontent.com/e7d4cd2002f6e5048a3afa36e77d45aed1a1e805/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f2d4775696465732d3061306130612e7376673f7374796c653d666c617426636f6c6f72413d306130613061" alt=""&gt;&lt;/a&gt;
&lt;a href="https://raw.githubusercontent.com/kamranahmedse/developer-roadmap/master/./translations"&gt;&lt;img src="https://camo.githubusercontent.com/55bcc2511dba49533401cd51e101f97c1aefa04e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f2d5472616e736c6174696f6e732d3061306130612e7376673f7374796c653d666c617426636f6c6f72413d306130613061" alt=""&gt;&lt;/a&gt;
&lt;a href="https://www.youtube.com/channel/UCA0H2KIWgWTwpTFjSxp0now?sub_confirmation=1" rel="nofollow"&gt;&lt;img src="https://camo.githubusercontent.com/371a3bb617bb1ab8222c37b68fefaf3f1ed6bb56/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f2545322539442541342d596f75547562652532304368616e6e656c2d3061306130612e7376673f7374796c653d666c617426636f6c6f72413d306130613061" alt=""&gt;&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Below you find a set of charts demonstrating the paths that you can take and the technologies that you would want to adopt in order to become a frontend, backend or a devops. I made these charts for an old professor of mine who wanted something to share with his college students to give them a perspective; sharing them here to help the community.&lt;/p&gt;

&lt;p&gt;
        &lt;sup&gt;Special Announcement:&lt;/sup&gt;
        &lt;br&gt;
        &lt;a href="https://www.youtube.com/channel/UCA0H2KIWgWTwpTFjSxp0now?sub_confirmation=1" rel="nofollow"&gt;
            &lt;img width="70px" src="https://camo.githubusercontent.com/9424cd9f750ed610e923c2e9500d05e4103ea33e/68747470733a2f2f726f61646d61702e73682f73706f6e736f72732f796f75747562652e737667"&gt;
        &lt;/a&gt;
        &lt;br&gt;
        &lt;b&gt;We now have a YouTube Channel&lt;/b&gt;
        &lt;br&gt;
        I plan on covering the roadmaps and put more content there&lt;br&gt;&lt;a href="https://www.youtube.com/channel/UCA0H2KIWgWTwpTFjSxp0now?sub_confirmation=1" rel="nofollow"&gt;Subscribe to the channel&lt;/a&gt;.
&lt;/p&gt;




&lt;h3&gt;
&lt;strong&gt;Purpose of these Roadmaps&lt;/strong&gt;
&lt;/h3&gt;


&lt;blockquote&gt;

&lt;p&gt;The purpose of these roadmaps is to give you an idea about the landscape and to guide you if you are confused about what to learn next and not to encourage you to pick what is hip and trendy. You should grow some understanding of why one tool would be…&lt;/p&gt;


&lt;/blockquote&gt;
&lt;/div&gt;
&lt;br&gt;
  &lt;/div&gt;
&lt;br&gt;
  &lt;div class="gh-btn-container"&gt;&lt;a class="gh-btn" href="https://github.com/kamranahmedse/developer-roadmap"&gt;View on GitHub&lt;/a&gt;&lt;/div&gt;
&lt;br&gt;
&lt;/div&gt;
&lt;br&gt;


&lt;h2&gt;
  
  
  Trending
&lt;/h2&gt;

&lt;p&gt;Everyone in this community knows there are new things coming out all the time. If you want to stay relevant it is a good idea to keep an eye out on what's trending on Github. Choose the language you want to follow and see what your community is getting excited about these days. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--qP6K8MSq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/errlmv6hxippnvys7c7a.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qP6K8MSq--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/errlmv6hxippnvys7c7a.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Front End Libraries and Frameworks
&lt;/h2&gt;

&lt;p&gt;Luckily for us, this community is big on sharing, so you can also take a look at the code for some of the biggest libraries and frameworks out there. For front-end developers, visit &lt;a href="https://github.com/collections/front-end-javascript-frameworks"&gt;github.com/collections/front-end-javascript-frameworks&lt;/a&gt; and take a look around. &lt;/p&gt;

&lt;p&gt;There is a lot of good code (usually in their &lt;code&gt;src&lt;/code&gt; folder) that you can learn from. Find a functionality or feature you find interesting, go to the source code and try to understand what is going on. Remember, this is code that has been revised time and time again by many developers so you can learn patterns and concepts that work.  &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--OUxv8dw5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/66p4uzwp014uyixyh3jp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--OUxv8dw5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/66p4uzwp014uyixyh3jp.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Social Impact
&lt;/h2&gt;

&lt;p&gt;We all know that a lot has been going on this year. You can see some of the things this community has done to improve the world we live in by visiting &lt;a href="https://github.com/collections/social-impact"&gt;github.com/collections/social-impact&lt;/a&gt;. Who knows, maybe you'll get inspired and build your own socially impacting open source project.  &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--wsZuNzMg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/kd55bau45es35zqy1h48.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--wsZuNzMg--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/kd55bau45es35zqy1h48.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Events
&lt;/h2&gt;

&lt;p&gt;A good way to connect with other developers is to participate in &lt;a href="https://github.com/events"&gt;events&lt;/a&gt;. The next one being 'Demo Days - Using Dependabot to keep your dependencies secure &amp;amp; updated' on the 28th of August. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--59EL021d--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/yxa4qu3qcsph6cchhx8j.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--59EL021d--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/yxa4qu3qcsph6cchhx8j.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Bonus
&lt;/h2&gt;

&lt;p&gt;Not on the Github page, but worth mentioning. &lt;/p&gt;

&lt;h3&gt;
  
  
  Hackathon
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://hacktoberfest.digitalocean.com/"&gt;Hacktoberfest&lt;/a&gt; is coming up! This is a month-long open-source hackathon sponsored by Github.   &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--XKn5SWNO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/qx4wsfe7iotkp05gdtpf.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XKn5SWNO--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/qx4wsfe7iotkp05gdtpf.png" alt="Alt Text"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Presentations
&lt;/h3&gt;

&lt;p&gt;Need a tool to pitch your new ideas? GitPitch is a great way to create your presentation in an engaging way. You can share your slides online as public, private, or password-protected. Since it is an open-source project maintained on GitHub you can fork and modify the repo in order to fit your own particular needs too.&lt;/p&gt;

&lt;p&gt;&lt;iframe height="450" src="https://gitpitch.com/gitpitch/in-60-seconds"&gt;
&lt;/iframe&gt;
&lt;/p&gt;

&lt;h3&gt;
  
  
  Build your own Octocat!
&lt;/h3&gt;

&lt;p&gt;There is an &lt;a href="https://myoctocat.com/build-your-octocat/"&gt;octocat generator&lt;/a&gt; available on the internet! What is an octocat you say? Well, it's Github's mascot of course! &lt;/p&gt;

&lt;p&gt;Since purple is my color of choice I made this one and have been adding it to the README.md files of all my new repositories as a fun little personal touch. &lt;/p&gt;

&lt;p&gt; &lt;a href="https://myoctocat.com/build-your-octocat/"&gt;&lt;img width="200px" src="https://res.cloudinary.com/practicaldev/image/fetch/s--Zr3BRyaD--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://santiagocodes.github.io/santiagocodes/images/octocat-santiagocodes.png" alt="santiagocodes octocat"&gt;&lt;/a&gt; &lt;/p&gt;




&lt;p&gt;If you liked what you read hit that ❤️ on the left or wherever it is. If you really liked it don’t forget to share it with the community by hitting that dot-dot-dot icon near the heart. &lt;/p&gt;

&lt;p&gt;💻 &lt;strong&gt;article.close()&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>github</category>
      <category>codenewbie</category>
      <category>githunt</category>
      <category>webdev</category>
    </item>
    <item>
      <title>In case you missed it... Github Profile Readme.</title>
      <dc:creator>Maria del Carmen Santiago</dc:creator>
      <pubDate>Mon, 10 Aug 2020 10:06:54 +0000</pubDate>
      <link>https://dev.to/santiagocodes/in-case-you-missed-it-github-profile-readme-496c</link>
      <guid>https://dev.to/santiagocodes/in-case-you-missed-it-github-profile-readme-496c</guid>
      <description>&lt;p&gt;&lt;em&gt;Take your Github Profile to the next level by giving your page a bit more life!&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This is a "secret" feature that can help you boost your Github Profile page and make it stand out from the pack! All you need to do is create a new public repository named after your own username. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fm5a2901yl7n2v500qzz1.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fm5a2901yl7n2v500qzz1.jpg" alt="Creating a Repository" width="800" height="754"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Once that is done, edit the README.md file using markdown to add information about yourself or anything else you want to bring attention to. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fng6cgi4fmgie8fijwid6.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fng6cgi4fmgie8fijwid6.jpg" alt="Edit README.md file" width="800" height="571"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Don't know markdown? For a good open-source reference guide that includes the basics and extended syntax go to &lt;a href="https://www.markdownguide.org/getting-started/"&gt;markdownguide.org&lt;/a&gt;. &lt;/p&gt;

&lt;p&gt;You can use some HTML, but what works is limited. A useful example of this is using the &lt;code&gt;&amp;lt;img&amp;gt;&lt;/code&gt; element to manipulate the alignment, width, and height of an image. (No &lt;code&gt;align="center"&lt;/code&gt; though... sorry).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;img&lt;/span&gt; &lt;span class="na"&gt;align=&lt;/span&gt;&lt;span class="s"&gt;"right"&lt;/span&gt; &lt;span class="na"&gt;width=&lt;/span&gt;&lt;span class="s"&gt;"100"&lt;/span&gt; &lt;span class="na"&gt;height=&lt;/span&gt;&lt;span class="s"&gt;"100"&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"http://www.picture.com/100/100"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Want to add some motion? GIFs are easy to add. Visit &lt;a href="https://giphy.com/"&gt;giphy.com&lt;/a&gt; to get some or to make your own.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;&lt;span class="p"&gt;![&lt;/span&gt;&lt;span class="nv"&gt;Alt Text&lt;/span&gt;&lt;span class="p"&gt;](&lt;/span&gt;&lt;span class="sx"&gt;https://media.giphy.com/media/123/giphy.gif&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;

&lt;span class="c"&gt;&amp;lt;!-- or --&amp;gt;&lt;/span&gt;

&lt;span class="nt"&gt;&amp;lt;img&lt;/span&gt; &lt;span class="na"&gt;align=&lt;/span&gt;&lt;span class="s"&gt;'right'&lt;/span&gt; &lt;span class="na"&gt;width=&lt;/span&gt;&lt;span class="s"&gt;"230"&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"https://media.giphy.com/media/123/giphy.gif"&lt;/span&gt; &lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Emoticons are easier to add on markdown. Browse through the list of &lt;a href="https://gist.github.com/rxaviers/7360908"&gt;github markdown emoji markup&lt;/a&gt; and pick the one you need.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;Example: For 😄 type :smile:
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Want to add badges with your contact info? Take a look at &lt;a href="https://shields.io/"&gt;shields.io&lt;/a&gt;. No need to install anything. Just copy the correct code to your repository and you're done.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight markdown"&gt;&lt;code&gt;&lt;span class="c"&gt;&amp;lt;!-- Twitter badge code example --&amp;gt;&lt;/span&gt; 

&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nv"&gt;![twitter badge&lt;/span&gt;&lt;span class="p"&gt;](&lt;/span&gt;&lt;span class="sx"&gt;https://img.shields.io/badge/twitter.com-@username-blue?style=flat&amp;amp;logo=twitter&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt;](https://twitter.com/username) 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here is a look at my new Github profile page (for now)... &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F009gitrveeyjzbi20usp.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2F009gitrveeyjzbi20usp.png" alt="santiagocodes Github Profile" width="800" height="477"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Now, don't be shy. Share your profiles or any cool ones you stumble upon in the comment section. As limiting as markdown can be (no CSS 😞), you can still make your page look awesome. &lt;/p&gt;

&lt;p&gt;Don't believe me? Have a look at abhisheknaiidu's &lt;a href="https://github.com/abhisheknaiidu/awesome-github-profile-readme"&gt;awesome-github-profile-readme&lt;/a&gt; repository or visit &lt;a href="https://awesome-github-readme-profile.netlify.app/"&gt;awesome-github-readme-profile.netlify.app&lt;/a&gt; to get some inspiration!  &lt;/p&gt;




&lt;p&gt;If you liked what you read hit that ❤️ on the left or wherever it is. If you really liked it don’t forget to share it with the community by hitting that dot-dot-dot icon near the heart. &lt;/p&gt;

&lt;p&gt;💻 &lt;strong&gt;article.close()&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>github</category>
      <category>markdown</category>
      <category>codenewbie</category>
      <category>wecoded</category>
    </item>
    <item>
      <title>Speed up your Website: Tools and Tricks for Visual Media Files</title>
      <dc:creator>Maria del Carmen Santiago</dc:creator>
      <pubDate>Thu, 06 Aug 2020 20:46:37 +0000</pubDate>
      <link>https://dev.to/santiagocodes/speed-up-your-website-tools-and-tricks-for-visual-media-files-4708</link>
      <guid>https://dev.to/santiagocodes/speed-up-your-website-tools-and-tricks-for-visual-media-files-4708</guid>
      <description>&lt;p&gt;&lt;em&gt;You can incredibly increase your page speed by setting up your media files appropriately. This article is a collection of tools and tricks that will help you optimize your page easily, along with other things related to visual media files.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;First, let's take a look at the free tools found online. Then we will see some simple HTML5 code snippets that can make a huge difference at speed and user experience. Finally, we will see a couple of tools that can analyze your webpage speed.&lt;/p&gt;

&lt;h1&gt;
  
  
  Free Tools
&lt;/h1&gt;

&lt;blockquote&gt;
&lt;p&gt;Disclaimer: All of the tools shared in this article are free, but if you like them and have the money for it I encourage you to donate money to its creator(s). &lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Reduce File Size
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://tinypng.com/"&gt;tinypng.com&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://tinypng.com/"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Ei8-MnKm--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.postimg.cc/9FZdmQn4/tinypng.png" alt="tinypng.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When it comes to the speed of your webpage, the size of your media files is one of the first things you should look into. TinyPNG.com reduces the file size of your images while having basically no effect on the look of the original. By doing this your images will load faster, thereby making your webpage faster as well. &lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://www.videosmaller.com/"&gt;videosmaller.com&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://www.videosmaller.com/"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--6OWfNaSC--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.postimg.cc/WpSXknmG/video-smaller.png" alt="video-smaller.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Upload your videos (up to 500mb) to this service to reduce video file size without losing quality. You have several features like removing the audio and you also have the assurance from them that even if you don’t delete the video yourself, they will remove it from their servers after a few hours. &lt;/p&gt;

&lt;h2&gt;
  
  
  Remove Background
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://www.remove.bg/"&gt;remove.bg&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://www.remove.bg/"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--fhgT9FXx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.postimg.cc/hPn8p3gz/bg-remove.png" alt="bg-remove.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Couldn’t be easier. Drag the image into remove.bg, download the new image, and done. With the help of AI technology, remove.bg can remove your image’s background in seconds with no editing on your part. You can also replace that transparent background using this tool.  &lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://www.unscreen.com/"&gt;unscreen.com&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://www.unscreen.com/"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--qH16WL_y--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.postimg.cc/DwBvBb2G/unscreen.png" alt="unscreen.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Using the same upload or drag and drop system as with remove.bg, this tool will remove the background of any gif or video using AI technology. &lt;/p&gt;

&lt;h2&gt;
  
  
  Free Stock Photos and Videos
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://pixabay.com/"&gt;pixabay.com&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://pixabay.com/"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--MyYygiql--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.postimg.cc/T1N0M77r/pixabay.png" alt="pixabay.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Pixabay has over 1.8 million royalty-free stock images and videos. Highly recommended for those side projects where you need images and/or videos, but you have no budget (or the artistic ability to produce high-quality media yourself!). &lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://www.pexels.com/"&gt;pexels.com&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://www.pexels.com/"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Ce3xXdVe--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.postimg.cc/yx8jG4P1/pexels.png" alt="pexels.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Has Pixabay’s selection left you wanting more? Head over to Pexels and take a look at their free stock of photos and videos. &lt;/p&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://giphy.com/"&gt;giphy.com&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://giphy.com/"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--ViJ_BfrB--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.postimg.cc/7hbzrxTL/giphy.png" alt="giphy.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;With GIPHY you can search, share, discover, and create GIFs. When it comes to creating your own GIF you can use your own videos or set of pictures. You can also pick one of their popular GIFs and edit it by adding things like stickers and your own text. Finally, you can download and/or get a link to your new GIF so you can use it on your projects.  &lt;/p&gt;

&lt;h2&gt;
  
  
  Placeholder
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;a href="http://lorempixel.com/"&gt;lorempixel.com&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://postimg.cc/LhgtNMPY"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--buEdoNZ9--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.postimg.cc/VsDKsfLR/lorem-pic.png" alt="lorem-pic.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Named after the famous dummy text, this tool will provide you with a link from which you can essentially get dummy images. You can also use the placeholder generator in cases where you want a more specific image to appear, and even add text to said images! &lt;/p&gt;

&lt;p&gt;A basic example of this tool in use would be &lt;code&gt;&amp;lt;img src=”http://lorempixel.com/400/200” /&amp;gt;&lt;/code&gt; to get a random picture of 400 x 200 pixels. &lt;/p&gt;

&lt;h2&gt;
  
  
  Train your brain
&lt;/h2&gt;

&lt;h3&gt;
  
  
  &lt;a href="https://www.pixact.ly/"&gt;pixact.ly&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://www.pixact.ly/"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--UMg03cGh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.postimg.cc/XYnCnc5h/pixactly.png" alt="pixactly.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;When dealing with media files you will probably have to deal with pixels at some point. This game will train your brain by giving you a series of measurements in pixels. You guess how much space those pixels should occupy on your screen, and get scores depending on how close your guess was. &lt;/p&gt;

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

&lt;h3&gt;
  
  
  &lt;a href="https://postimages.org/"&gt;postimages.org&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://postimages.org/"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--MEcAJU5_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.postimg.cc/3w3v1j97/postimages-2.png" alt="postimages-2.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Have your own image and can’t (I’m looking at you codepen!) or don’t want to upload the image to a project? Get permanent links for your images with postimages.org.&lt;/p&gt;

&lt;h1&gt;
  
  
  HTML Tricks for Web Optimization
&lt;/h1&gt;

&lt;p&gt;HTML tricks that go a long way when dealing with heavy media files. &lt;/p&gt;

&lt;h2&gt;
  
  
  GIFs
&lt;/h2&gt;

&lt;p&gt;GIF video files are quite heavy and can make your page significantly slower. You can bypass this problem by ‘faking’ a GIF using the following code:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;video&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"file.mp4"&lt;/span&gt; &lt;span class="na"&gt;autoplay&lt;/span&gt; &lt;span class="na"&gt;loop&lt;/span&gt; &lt;span class="na"&gt;muted&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;autoplay&lt;/code&gt; boolean attribute will make the video automatically play itself even before all the data has loaded. The &lt;code&gt;loop&lt;/code&gt; boolean attribute will make the browser automatically replay the video once it ends. And the &lt;code&gt;muted&lt;/code&gt; boolean attribute will set the video's audio to mute by default. &lt;/p&gt;

&lt;p&gt;Other video attributes you can use are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Controls: this display controls to allow the user to control the video’s playback.&lt;/li&gt;
&lt;li&gt;height: to adjust the height (in pixels) of the video’s display area.&lt;/li&gt;
&lt;li&gt;width: to adjust the width (in pixels) of the video’s display area.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Video
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;&amp;lt;video&amp;gt;&lt;/code&gt; element has several attributes that could help with your page’s performance and with user experience, when used correctly.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;video&lt;/span&gt; 
   &lt;span class="na"&gt;controls&lt;/span&gt; &lt;span class="na"&gt;width=&lt;/span&gt;&lt;span class="s"&gt;"500"&lt;/span&gt; &lt;span class="na"&gt;height=&lt;/span&gt;&lt;span class="s"&gt;"400"&lt;/span&gt;
   &lt;span class="na"&gt;poster=&lt;/span&gt;&lt;span class="s"&gt;"images/movie-poster.png"&lt;/span&gt;
   &lt;span class="na"&gt;preload=&lt;/span&gt;&lt;span class="s"&gt;"auto|metadata|none"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;source&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"videos/movie.webm"&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"video/webm"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;source&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"videos/movie.mp4"&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"video/mp4"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    Your browser does not support the video tag. 
        Instead, you can watch it on &lt;span class="nt"&gt;&amp;lt;a&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"youtube.com/movie"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;youtube&lt;span class="nt"&gt;&amp;lt;/a&amp;gt;&lt;/span&gt;. 
&lt;span class="nt"&gt;&amp;lt;/video&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;Videos may take a while to load. Adding a &lt;code&gt;poster&lt;/code&gt; attribute with a &lt;code&gt;src&lt;/code&gt; to a selected image will enhance the user experience as the browser will display this image when the video isn’t being played yet. &lt;/p&gt;

&lt;p&gt;The &lt;code&gt;preload&lt;/code&gt; attribute lets us control when the video data is loaded. This attribute will be ignored if the &lt;code&gt;autoplay&lt;/code&gt; attribute (seen in the GIFs section) is included as well. When set to &lt;code&gt;auto&lt;/code&gt; the video will load when the page loads, &lt;code&gt;metadata&lt;/code&gt; will load only the metadata when the page loads, and &lt;code&gt;none&lt;/code&gt; won't load the video when the page loads. &lt;/p&gt;

&lt;p&gt;There are browsers that don’t support all video formats, but including several &lt;code&gt;&amp;lt;source&amp;gt;&lt;/code&gt; tags will solve that issue. The browser will go from top to bottom and display the first video it recognizes. You should always include a fallback text with a  link to where the user can watch/download the video in case any of the other formats fail to load. &lt;/p&gt;

&lt;p&gt;To get the full list of &lt;code&gt;&amp;lt;video&amp;gt;&lt;/code&gt;  attributes take a look at the &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/video"&gt;MDN web docs&lt;/a&gt;’s documentation. If accessibility is a concern for you (as it should be!) and you want to add captions and subtitles, take a look at this MDN web doc's article on &lt;a href="https://developer.mozilla.org/en-US/docs/Web/Guide/Audio_and_video_delivery/Adding_captions_and_subtitles_to_HTML5_video"&gt;Adding captions and subtitles to HTML5 video&lt;/a&gt; &lt;/p&gt;

&lt;h2&gt;
  
  
  Images
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Img || Picture || Figure
&lt;/h3&gt;

&lt;p&gt;The &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/img"&gt;&lt;code&gt;&amp;lt;img&amp;gt;&lt;/code&gt;&lt;/a&gt; element should always have an &lt;code&gt;alt&lt;/code&gt; attribute. This will ensure that there is a descriptive alternative text available to be used by search engine bots, in the case of an error loading the image or when needed for accessibility purposes. It is recommended to set a &lt;code&gt;width&lt;/code&gt; and &lt;code&gt;height&lt;/code&gt; so that the element always takes the same space and doesn't mess with the layout of the page later.&lt;/p&gt;

&lt;p&gt;A useful attribute regarding page performance is &lt;code&gt;loading&lt;/code&gt;. When set to &lt;code&gt;lazy&lt;/code&gt; the loading of the image is deferred until it reaches a calculated distance from the viewport. There's no need to load, for example, the images in the footer of the page until we are close to displaying that part of the page in our screen, right?&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;img&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"images/dog.png"&lt;/span&gt; &lt;span class="na"&gt;loading=&lt;/span&gt;&lt;span class="s"&gt;"lazy"&lt;/span&gt; &lt;span class="na"&gt;alt=&lt;/span&gt;&lt;span class="s"&gt;"A dorky looking dog image."&lt;/span&gt; &lt;span class="na"&gt;width=&lt;/span&gt;&lt;span class="s"&gt;"200"&lt;/span&gt; &lt;span class="na"&gt;height=&lt;/span&gt;&lt;span class="s"&gt;"200"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The &lt;a href="https://html.spec.whatwg.org/multipage/embedded-content.html#embedded-content"&gt;&lt;code&gt;&amp;lt;picture&amp;gt;&lt;/code&gt;&lt;/a&gt; element is not that different from the &lt;code&gt;&amp;lt;img&amp;gt;&lt;/code&gt; element. It is meant as a way to have multiple &lt;code&gt;&amp;lt;img src="#" &amp;gt;&lt;/code&gt; sources for responsive sites and to help with speed on mobile. Think about it this way: larger image = larger file size = slower website.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;picture&amp;gt;&lt;/span&gt;
   &lt;span class="nt"&gt;&amp;lt;source&lt;/span&gt; &lt;span class="na"&gt;media=&lt;/span&gt;&lt;span class="s"&gt;"(min-width: 500w)"&lt;/span&gt; &lt;span class="na"&gt;srcset=&lt;/span&gt;&lt;span class="s"&gt;"images/dog-500.png"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
   &lt;span class="nt"&gt;&amp;lt;source&lt;/span&gt; &lt;span class="na"&gt;media=&lt;/span&gt;&lt;span class="s"&gt;"(min-width: 800w)"&lt;/span&gt; &lt;span class="na"&gt;srcset=&lt;/span&gt;&lt;span class="s"&gt;"images/dog-800.png"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
   &lt;span class="nt"&gt;&amp;lt;source&lt;/span&gt; &lt;span class="na"&gt;media=&lt;/span&gt;&lt;span class="s"&gt;"(min-width: 1000w)"&lt;/span&gt; &lt;span class="na"&gt;srcset=&lt;/span&gt;&lt;span class="s"&gt;"images/dog-1000.png"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
   &lt;span class="nt"&gt;&amp;lt;source&lt;/span&gt; &lt;span class="na"&gt;media=&lt;/span&gt;&lt;span class="s"&gt;"(min-width: 1400w) and (orientation: landscape)"&lt;/span&gt; &lt;span class="na"&gt;srcset=&lt;/span&gt;&lt;span class="s"&gt;"images/dog-1400L.png"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
   &lt;span class="nt"&gt;&amp;lt;source&lt;/span&gt; &lt;span class="na"&gt;media=&lt;/span&gt;&lt;span class="s"&gt;"(min-width: 1400w) and (orientation: portrait)"&lt;/span&gt; &lt;span class="na"&gt;srcset=&lt;/span&gt;&lt;span class="s"&gt;"images/dog-1400P.png"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
   &lt;span class="nt"&gt;&amp;lt;img&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"images/dog.png"&lt;/span&gt; &lt;span class="na"&gt;alt=&lt;/span&gt;&lt;span class="s"&gt;"A dorky looking dog image."&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/picture&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The browser will go through this element from top to bottom and display the appropriate image, depending on the specifications in the &lt;code&gt;media&lt;/code&gt; attribute. An &lt;code&gt;&amp;lt;img&amp;gt;&lt;/code&gt; element is needed as a last child element of the &lt;code&gt;&amp;lt;picture&amp;gt;&lt;/code&gt; element. This will serve as a fallback for when none of the other &lt;code&gt;&amp;lt;source&amp;gt;&lt;/code&gt; tags match the current screen size. &lt;/p&gt;

&lt;p&gt;Of course, you could do the same using the &lt;code&gt;&amp;lt;img&amp;gt;&lt;/code&gt; element as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight html"&gt;&lt;code&gt; &lt;span class="nt"&gt;&amp;lt;img&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"images/dog.jpeg"&lt;/span&gt;
    &lt;span class="na"&gt;alt=&lt;/span&gt;&lt;span class="s"&gt;"A dorky looking dog image."&lt;/span&gt;
    &lt;span class="na"&gt;sizes=&lt;/span&gt;&lt;span class="s"&gt;"(max-width: 500px) 100vw, 800px"&lt;/span&gt; 
    &lt;span class="na"&gt;srcset=&lt;/span&gt;&lt;span class="s"&gt;"images/dog-500.jpeg 500w, images/dog-1000.jpeg 1000w"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;So what can you do with the &lt;code&gt;&amp;lt;picture&amp;gt;&lt;/code&gt; element that you can’t with the &lt;code&gt;&amp;lt;img&amp;gt;&lt;/code&gt; element? Well, you can use this element to include different image formats. The user’s browser will use the first format it recognizes and ignores the rest.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;picture&amp;gt;&lt;/span&gt;
   &lt;span class="nt"&gt;&amp;lt;source&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"image/webp"&lt;/span&gt; &lt;span class="na"&gt;srcset=&lt;/span&gt;&lt;span class="s"&gt;"dog.webp"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
   &lt;span class="nt"&gt;&amp;lt;source&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"image/png"&lt;/span&gt; &lt;span class="na"&gt;srcset=&lt;/span&gt;&lt;span class="s"&gt;"dog.png"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
   &lt;span class="nt"&gt;&amp;lt;img&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"dog.jpg"&lt;/span&gt; &lt;span class="na"&gt;alt=&lt;/span&gt;&lt;span class="s"&gt;"A dorky looking dog image."&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/picture&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;WebP image files are around 30% smaller than the more common PNG and JPEG files, with no loss of quality. The downside is that WebP files are not supported by all browsers. That is why we include a fallback image to cover all of our bases. &lt;/p&gt;

&lt;p&gt;The &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Element/figure"&gt;&lt;code&gt;&amp;lt;figure&amp;gt;&lt;/code&gt;&lt;/a&gt; element can contain images, illustrations, charts, diagrams, tables, code snippets, and the like. It is usually used when you want to display an image with a caption.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;figure&amp;gt;&lt;/span&gt;
   &lt;span class="nt"&gt;&amp;lt;img&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"dog.jpg"&lt;/span&gt; &lt;span class="na"&gt;alt=&lt;/span&gt;&lt;span class="s"&gt;"A dorky looking dog image."&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
   &lt;span class="nt"&gt;&amp;lt;figcaption&amp;gt;&lt;/span&gt;A dorky looking dog.&lt;span class="nt"&gt;&amp;lt;/figcaption&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/figure&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;&amp;lt;figure&amp;gt;&lt;/code&gt; element serves as a way to semantically add captions to an &lt;code&gt;&amp;lt;img&amp;gt;&lt;/code&gt; or a &lt;code&gt;&amp;lt;picture&amp;gt;&lt;/code&gt; element (and others). An &lt;code&gt;&amp;lt;img&amp;gt;&lt;/code&gt; element is essential when wanting to display an image and should always have an &lt;code&gt;alt&lt;/code&gt; attribute. A &lt;code&gt;&amp;lt;picture&amp;gt;&lt;/code&gt; element is useful when we have more than one image format available. Both &lt;code&gt;&amp;lt;img&amp;gt;&lt;/code&gt; and &lt;code&gt;&amp;lt;picture&amp;gt;&lt;/code&gt; can be used for responsiveness (by instructing the browser to load the appropriate image size). &lt;/p&gt;

&lt;h1&gt;
  
  
  Performance
&lt;/h1&gt;

&lt;p&gt;Check your page’s performance score with tools like &lt;a href="https://gtmetrix.com/"&gt;GTmetrix&lt;/a&gt; and &lt;a href="https://developers.google.com/speed/pagespeed/insights/?hl=en"&gt; PageSpeed Insights&lt;/a&gt;.&lt;/p&gt;




&lt;p&gt;If you liked what you read hit that ❤️ on the left or wherever it is. If you really liked it don’t forget to share it with the community by hitting that dot-dot-dot icon near the heart. &lt;/p&gt;

&lt;p&gt;Feel free to add more tricks and tools on the comment section below! As for me, I will keep updating this article as I stumble upon new or better tools and tricks. &lt;/p&gt;

&lt;p&gt;💻 &lt;strong&gt;article.close()&lt;/strong&gt;&lt;/p&gt;

</description>
      <category>html</category>
      <category>todayisearched</category>
      <category>codenewbie</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Top 10 Essential VS Code Extensions</title>
      <dc:creator>Maria del Carmen Santiago</dc:creator>
      <pubDate>Wed, 29 Jul 2020 14:52:55 +0000</pubDate>
      <link>https://dev.to/santiagocodes/top-10-essential-vs-code-extensions-e37</link>
      <guid>https://dev.to/santiagocodes/top-10-essential-vs-code-extensions-e37</guid>
      <description>&lt;p&gt;&lt;em&gt;A list of essential Visual Studio Code extensions to help you become a more efficient web developer.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;If your code editor is Visual Studio Code, this is the article for you. VS Code is awesome by itself, but you can take advantage of its extensive list of extensions to support your workflow.&lt;/p&gt;

&lt;p&gt;If you haven’t yet, &lt;a href="https://code.visualstudio.com/download"&gt;download&lt;/a&gt; VS Code for free. Within VS Code you can browse and install extensions by clicking on the &lt;em&gt;Extensions&lt;/em&gt; icon in the &lt;em&gt;Activity Bar&lt;/em&gt; on the left side of the editor, or by using the command &lt;code&gt;Ctrl + Shift + X&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--AllCmSFx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.postimg.cc/76zkjgQt/vscode-install.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--AllCmSFx--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.postimg.cc/76zkjgQt/vscode-install.png" alt="vscode-install.png"&gt;&lt;/a&gt;&lt;/p&gt;




&lt;p&gt;Here are my top 10 suggested VS Code extensions for Newbies (and the rest):&lt;/p&gt;

&lt;h2&gt;
  
  
  1. &lt;a href="https://marketplace.visualstudio.com/items?itemName=ritwickdey.LiveServer"&gt;Live Server&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://marketplace.visualstudio.com/items?itemName=ritwickdey.LiveServer"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--9j5ZH-3---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.postimg.cc/3wYswsNh/vscode-liveserverlogo.png" alt="vscode-liveserverlogo.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;A must-have for any developer creating webpages using HTML and CSS. Once installed all you have to do is open your project, look for the &lt;code&gt;Go Live&lt;/code&gt; button on the status bar at the bottom, or use the command &lt;code&gt;Alt+L Alt+O&lt;/code&gt; in order to launch a quick development live server so you can view your current project live on any browser.&lt;/p&gt;

&lt;h2&gt;
  
  
  2. &lt;a href="https://marketplace.visualstudio.com/items?itemName=MS-vsliveshare.vsliveshare"&gt;Live Share&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://marketplace.visualstudio.com/items?itemName=MS-vsliveshare.vsliveshare"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--tA54aUT_--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.postimg.cc/HnNmcBK2/vscode-liveshare.png" alt="vscode-liveshare.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;In these times of COVID quarantines, this extension can help you collaborate in real-time with others working on the same project. Edit and debug with your team from the comfort of your home. Everyone gets their own cursor and you can see the changes as they type.  &lt;/p&gt;

&lt;h2&gt;
  
  
  3. &lt;a href="https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode"&gt;Prettier&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://marketplace.visualstudio.com/items?itemName=esbenp.prettier-vscode"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--rlexvH81--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.postimg.cc/L4ggDw42/vscode-prettier.png" alt="vscode-prettier.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Stop wasting time formatting your code and let this tool do it for you. It enforces a consistent style by formatting your code every time you save a file (just make sure you manage the settings correctly, as shown below). &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--G4ZUgj0o--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.postimg.cc/ZngbvQmK/prettier-format-On-Save.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--G4ZUgj0o--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.postimg.cc/ZngbvQmK/prettier-format-On-Save.png" alt="prettier-format-On-Save.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Alternative: &lt;a href="https://marketplace.visualstudio.com/items?itemName=HookyQR.beautify"&gt;Beautify&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  4. &lt;a href="https://marketplace.visualstudio.com/items?itemName=2gua.rainbow-brackets"&gt;Rainbow Brackets&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://marketplace.visualstudio.com/items?itemName=2gua.rainbow-brackets"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--XfEmxVcS--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.postimg.cc/5NjN4FGg/vscode-rainbow-Brackets.png" alt="vscode-rainbow-Brackets.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Visual help for those programmers that need to worry about closures, like javascript programmers. It does this by providing different colors for round brackets, square brackets, and squiggly brackets.&lt;/p&gt;

&lt;p&gt;Alternative: &lt;a href="https://marketplace.visualstudio.com/items?itemName=CoenraadS.bracket-pair-colorizer-2"&gt;Bracket Pair Colorizer 2&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  5. &lt;a href="https://marketplace.visualstudio.com/items?itemName=johnpapa.vscode-peacock"&gt;Peacock&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://marketplace.visualstudio.com/items?itemName=johnpapa.vscode-peacock"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--LCusEKUQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.postimg.cc/fbgkjj6V/vscode-peacocklogo.png" alt="vscode-peacocklogo.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Useful for when you have more than one code editor window open at the same time, as it changes the color of your workspace. Another visual aid, this time designed to help you identify your different code editor windows/projects more easily. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--63jqin8e--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.postimg.cc/CKDm3n5v/vscode-peacock.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--63jqin8e--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.postimg.cc/CKDm3n5v/vscode-peacock.png" alt="vscode-peacock.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Alternative: &lt;a href="https://marketplace.visualstudio.com/items?itemName=Equinusocio.vsc-material-theme"&gt;Material Theme&lt;/a&gt; (&lt;a href="https://marketplace.visualstudio.com/items?itemName=PKief.material-icon-theme"&gt;Material Icon Theme&lt;/a&gt; as a compliment). &lt;br&gt;
Complementary: &lt;a href="https://marketplace.visualstudio.com/items?itemName=vscode-icons-team.vscode-icons"&gt;vscode Icons&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  6. &lt;a href="https://marketplace.visualstudio.com/items?itemName=eamodio.gitlens"&gt;GitLens&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://marketplace.visualstudio.com/items?itemName=eamodio.gitlens"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--sXUdheVv--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.postimg.cc/kGPJfjwg/vscode-gitlenslogo.png" alt="vscode-gitlenslogo.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;If you know and work with git, you will want this extension. This customizable extension lets you better understand your code by easily allowing you to view when, why, and by whom the code was added/edited. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--2ZR2V-8o--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.postimg.cc/WbqXc527/vscode-gitlens.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--2ZR2V-8o--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.postimg.cc/WbqXc527/vscode-gitlens.png" alt="vscode-gitlens.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  7. &lt;a href="https://marketplace.visualstudio.com/items?itemName=streetsidesoftware.code-spell-checker"&gt;Code Spell Checker&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://marketplace.visualstudio.com/items?itemName=streetsidesoftware.code-spell-checker"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Jdn-oZXK--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.postimg.cc/nVK2TXhH/vscode-spellchecker.png" alt="vscode-spellchecker.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This one does exactly what it says. It is a spell checker for your editor. It works with camelCase so no worries when naming variables in Javascript. Basically, you will get a squiggly line underneath words you may have misspelled. You also get suggestions for what word you should write instead. &lt;br&gt;
Supported languages are English(US) and English(UK), but you have add-on dictionaries for Dutch, Catalan, Czech, French, German, Russian, Spanish, Swedish, and Medical Terms. &lt;/p&gt;

&lt;h2&gt;
  
  
  8. &lt;a href="https://marketplace.visualstudio.com/items?itemName=humao.rest-client"&gt;REST Client&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://marketplace.visualstudio.com/items?itemName=humao.rest-client"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--hvZbbwd4--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.postimg.cc/yxCfx96G/vscode-rest.png" alt="vscode-rest.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Do you know PostMan? Well, this tool is similar, only there is no need to leave your code editor. Once you prepare a request a &lt;code&gt;Send Request&lt;/code&gt; link will appear above it. Click on it and view the response right in your editor’s window.  &lt;/p&gt;

&lt;h2&gt;
  
  
  9. &lt;a href="https://marketplace.visualstudio.com/items?itemName=Zignd.html-css-class-completion"&gt;IntelliSense for CSS class names in HTML&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://marketplace.visualstudio.com/items?itemName=Zignd.html-css-class-completion"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--F3fZSAFQ--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.postimg.cc/3RRSz7SL/vscode-intellicss.png" alt="vscode-intellicss.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;You don’t need to remember all the CSS class names while you are working on your HTML file. This extension will provide you with a completion list for the HTML &lt;code&gt;class&lt;/code&gt; attribute based on your workspace or external files referenced beforehand. &lt;/p&gt;

&lt;p&gt;Alternative: &lt;a href="https://marketplace.visualstudio.com/items?itemName=ecmel.vscode-html-css"&gt;HTML CSS Support&lt;/a&gt; &lt;br&gt;
Complementary: &lt;a href="https://marketplace.visualstudio.com/items?itemName=pranaygp.vscode-css-peek"&gt;CSS Peek&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  10. &lt;a href="https://marketplace.visualstudio.com/items?itemName=VisualStudioExptTeam.vscodeintellicode"&gt;Visual Studio IntelliCode&lt;/a&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://marketplace.visualstudio.com/items?itemName=VisualStudioExptTeam.vscodeintellicode"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--Xpgs8iYh--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.postimg.cc/GtXfHtBn/vscode-intellicode.png" alt="vscode-intellicode.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;This extension uses AI technology to help Python, TypeScript/JavaScript, and Java developers. As you code, it will show a recommended completion items list sorted by context, rather than alphabetically or by most recent. &lt;/p&gt;




&lt;p&gt;There is no shame in using tools to help you. Quite the contrary, a smart developer is one that will use these to make their lives easier and become more efficient in the process! &lt;/p&gt;

&lt;p&gt;If you liked what you read hit that ❤️ on the left or wherever it is. If you really liked it don’t forget to share it with the community by hitting that dot-dot-dot icon near the heart. &lt;/p&gt;

&lt;p&gt;💻 &lt;strong&gt;article.close()&lt;/strong&gt;&lt;/p&gt;




&lt;p&gt;Bonus:&lt;/p&gt;

&lt;p&gt;Have a look at &lt;a href="https://emmet.io/"&gt;Emmet&lt;/a&gt;. It is already built into VS Code so no need to install. Take your time to explore and learn more about what you can do with this tool.&lt;/p&gt;

&lt;p&gt;Some of the runner-ups: &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://marketplace.visualstudio.com/items?itemName=formulahendry.auto-rename-tag"&gt;Auto Rename Tag&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://marketplace.visualstudio.com/items?itemName=msjsdiag.debugger-for-chrome"&gt;Debugger for Chrome&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://marketplace.visualstudio.com/items?itemName=DavidAnson.vscode-markdownlint"&gt;Markdownlint&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://marketplace.visualstudio.com/items?itemName=dzhavat.css-flexbox-cheatsheet"&gt;CSS Flexbox Cheatsheet&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://marketplace.visualstudio.com/items?itemName=dsznajder.es7-react-js-snippets"&gt;ES7 React/Redux/GraphQL/React-Native snippets&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://marketplace.visualstudio.com/items?itemName=Tyriar.lorem-ipsum"&gt;Lorem ipsum&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://marketplace.visualstudio.com/items?itemName=dbaeumer.vscode-eslint"&gt;ESLint&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>vscode</category>
      <category>codenewbie</category>
      <category>beginners</category>
    </item>
    <item>
      <title>A Look into Processing MultiDimensional Arrays Using Javascript</title>
      <dc:creator>Maria del Carmen Santiago</dc:creator>
      <pubDate>Thu, 16 Jul 2020 21:00:31 +0000</pubDate>
      <link>https://dev.to/santiagocodes/a-look-into-processing-multidimensional-arrays-using-javascript-cbl</link>
      <guid>https://dev.to/santiagocodes/a-look-into-processing-multidimensional-arrays-using-javascript-cbl</guid>
      <description>&lt;p&gt;&lt;em&gt;Understanding multidimensional arrays by solving a simple two-dimensional &lt;strong&gt;Harry Potter Challenge&lt;/strong&gt; using Vanilla Javascript.&lt;/em&gt;&lt;/p&gt;

&lt;h1&gt;
  
  
  The Challenge
&lt;/h1&gt;

&lt;p&gt;The Hogwarts Express has added several new stops on its journey from Platform 9 ¾ in London’s King’s Cross Station to Hogsmeade Station in Hogwarts School of Witchcraft and Wizardry. Dumbledore needs a management tool with which a crew member can input the numbers of passengers boarding and disembarking at each station. With these numbers, this tool will automatically calculate the number of passengers on board the train.  &lt;/p&gt;

&lt;h2&gt;
  
  
  Arrays
&lt;/h2&gt;

&lt;p&gt;According to MDN web docs, &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array"&gt;arrays&lt;/a&gt; are “list-like objects whose prototype has methods to perform traversal and mutation operations”. &lt;/p&gt;

&lt;p&gt;There is more than one way to create an array. You can use the array constructor &lt;code&gt;const array1 = new Array(“item1”, “item2”)&lt;/code&gt;, but it is recommended for both readability and speed to use the array literal method. Below we will use the literal method to create a one-dimension array with the names of the train stations from London to Hogwarts.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;stations&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
   &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;King's Cross&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Waverly&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Weasley&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Cardiff Central&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Hogsmeade&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;];&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;A two-dimensional array is just a one-dimensional array inside another array. For each station, a pair of elements will be added in a &lt;code&gt;[ [b1, d1], [b2, d2] … ]&lt;/code&gt; fashion, where &lt;code&gt;b&lt;/code&gt; represents the number of passengers that have boarded the train and &lt;code&gt;d&lt;/code&gt; represents the number of passengers that have disembarked the train. For now, we will just create an empty array that will be populated with new information submitted by the crew member in charge of the train’s passenger capacity.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;passengerLog&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt; &lt;span class="p"&gt;];&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Accessing HTML Elements
&lt;/h2&gt;

&lt;p&gt;What is important for us to know about the HTML are the &lt;code&gt;class names&lt;/code&gt; of the elements inside the form. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note: There are different ways to name your classes. In this project, I used the BEM naming convention. For more on this, you can do some research on naming conventions &lt;a href="https://www.freecodecamp.org/news/css-naming-conventions-that-will-save-you-hours-of-debugging-35cea737d849/"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;ul&gt;
&lt;li&gt;Station name’s display area: &lt;code&gt;.station__name&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Passengers boarding input box: &lt;code&gt;.passengers__in&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Passengers disembarking input box: &lt;code&gt;.passengers__out&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Submit button: &lt;code&gt;.button__add-passengers&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Passengers onboard display area: &lt;code&gt;.passengers__total&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;HTML:&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;form&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;table&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;tr&amp;gt;&lt;/span&gt;
          &lt;span class="nt"&gt;&amp;lt;th&lt;/span&gt; &lt;span class="na"&gt;colspan=&lt;/span&gt;&lt;span class="s"&gt;"2"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;STATION&lt;span class="nt"&gt;&amp;lt;/th&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;/tr&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;tr&amp;gt;&lt;/span&gt;
          &lt;span class="nt"&gt;&amp;lt;td&lt;/span&gt; &lt;span class="na"&gt;colspan=&lt;/span&gt;&lt;span class="s"&gt;"2"&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"station__name"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;/tr&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;tr&amp;gt;&lt;/span&gt;
          &lt;span class="nt"&gt;&amp;lt;th&amp;gt;&lt;/span&gt;IN&lt;span class="nt"&gt;&amp;lt;/th&amp;gt;&lt;/span&gt;
          &lt;span class="nt"&gt;&amp;lt;th&amp;gt;&lt;/span&gt;OUT&lt;span class="nt"&gt;&amp;lt;/th&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;/tr&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;tr&amp;gt;&lt;/span&gt;
          &lt;span class="nt"&gt;&amp;lt;td&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"input__in-out"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt;
                   &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"passengers__in"&lt;/span&gt;
                   &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"number"&lt;/span&gt;
                   &lt;span class="na"&gt;min=&lt;/span&gt;&lt;span class="s"&gt;"0"&lt;/span&gt;
                   &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
          &lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
          &lt;span class="nt"&gt;&amp;lt;td&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"input__in-out"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt;
                   &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"passengers__out"&lt;/span&gt;
                   &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"number"&lt;/span&gt;
                   &lt;span class="na"&gt;min=&lt;/span&gt;&lt;span class="s"&gt;"0"&lt;/span&gt;
                   &lt;span class="na"&gt;value=&lt;/span&gt;&lt;span class="s"&gt;"0"&lt;/span&gt;
                   &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
          &lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;/tr&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;tr&amp;gt;&lt;/span&gt;
          &lt;span class="nt"&gt;&amp;lt;td&lt;/span&gt; &lt;span class="na"&gt;colspan=&lt;/span&gt;&lt;span class="s"&gt;"2"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
            &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"submit"&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"button__add-passengers"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
              Submit
            &lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
          &lt;span class="nt"&gt;&amp;lt;/td&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;/tr&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;/table&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;br&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;p&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"passengers__total"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/form&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Next, we will be using the &lt;code&gt;querySelector&lt;/code&gt; method and using the class selectors mentioned before in order to return the elements we need. The &lt;code&gt;form&lt;/code&gt; itself has no class name so you can use the same method, but omitting the &lt;code&gt;.&lt;/code&gt; at the beginning of the selector name. &lt;/p&gt;

&lt;p&gt;JavaScript:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;stationName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;.station__name&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;passengersIn&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;.passengers__in&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;passengersOut&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;.passengers__out&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;buttonAddPassengers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;.button__add-passengers&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;passengersTotal&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;.passengers__total&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;form&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;form&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Adding Elements to Multidimensional Arrays
&lt;/h2&gt;

&lt;p&gt;The &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/push"&gt;push&lt;/a&gt; method will add elements to the end of an array. If we have an array &lt;code&gt;const letters = [‘b’, ‘c’, ‘d’]&lt;/code&gt; and want to add a fourth letter we just need to use the &lt;code&gt;array.push(‘e’)&lt;/code&gt; method to add that letter. This means the output for &lt;code&gt;console.log(letters)&lt;/code&gt; will go from &lt;code&gt;[‘b’, ‘c’, ‘d’]&lt;/code&gt; to &lt;code&gt;[‘b’, ‘c’, ‘d’, ‘e’]&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;As mentioned before, multidimensional arrays are just one-dimensional arrays inside other one-dimensional arrays so the same method can be used to add an array into an array. We already created an array called &lt;code&gt;passengerLog&lt;/code&gt;. Before leaving each station, the crew member in charge will use the form in order to submit two numbers. The number of passengers that boarded the train and the number that disembarked at said station. &lt;/p&gt;

&lt;p&gt;These two numbers will need to be added to the &lt;code&gt;passengerLog&lt;/code&gt; array using the &lt;code&gt;push&lt;/code&gt; method &lt;code&gt;passengerLog.push([passengersInValue, passengersOutValue]);&lt;/code&gt;. When adding an element in the form of an array you will be creating a two-dimensional array that will be constructed as follows: &lt;code&gt;[ [passengersInStationOne, passengersOutStationOne], [passengersInStationTwo, passengersOutStationTwo] ... ]&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;passengersIn&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;.passengers__in&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  &lt;span class="c1"&gt;// already established &lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;passengersOut&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;.passengers__out&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  &lt;span class="c1"&gt;// already established &lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;passengerLog&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[];&lt;/span&gt; &lt;span class="c1"&gt;// already established &lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;addToPassengerLog&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;passengersInValue&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;passengersIn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
   &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;passengersOutValue&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;passengersOut&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="c1"&gt;// Replace empty input boxes with 0 before adding to log&lt;/span&gt;
  &lt;span class="c1"&gt;// Add last entry to the passenger log&lt;/span&gt;
   &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;passengersInValue&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;passengersOutValue&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;passengerLog&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="nx"&gt;passengersInValue&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;passengersOutValue&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
   &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;passengersInValue&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;passengersOutValue&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;passengerLog&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="nx"&gt;passengersInValue&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
   &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;passengersInValue&lt;/span&gt; &lt;span class="o"&gt;&amp;amp;&amp;amp;&lt;/span&gt; &lt;span class="nx"&gt;passengersOutValue&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;passengerLog&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;passengersOutValue&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
   &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;passengerLog&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;push&lt;/span&gt;&lt;span class="p"&gt;([&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
   &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I’ve gone a step further for this project and added an &lt;code&gt;if...else statement&lt;/code&gt; to check for empty input logs and change them to zero before adding the input values into the main array. The &lt;code&gt;if...else statements&lt;/code&gt; all have a logical &lt;code&gt;&amp;amp;&amp;amp;&lt;/code&gt; operator which will return &lt;code&gt;true&lt;/code&gt; if both statements on either side of the &lt;code&gt;&amp;amp;&amp;amp;&lt;/code&gt; operator are true. &lt;/p&gt;

&lt;p&gt;If &lt;code&gt;(passengersInValue &amp;amp;&amp;amp; passengersOutValue)&lt;/code&gt;, means that &lt;code&gt;passengersInValue&lt;/code&gt; and &lt;code&gt;passengersOutValue&lt;/code&gt; exist. So, as we state below it, both values will be added to the &lt;code&gt;passengerLog&lt;/code&gt; array. However, if &lt;code&gt;(passengersInValue &amp;amp;&amp;amp; !passengersOutValue)&lt;/code&gt; this means that the &lt;code&gt;passengersInValue&lt;/code&gt; exists, but the &lt;code&gt;passengersOutValue&lt;/code&gt; does not (that is what the &lt;code&gt;!&lt;/code&gt; not operator is for). That input box has been left empty on the form. Hence, we add the &lt;code&gt;passengersInValue&lt;/code&gt; value and a zero, as stated below that &lt;code&gt;else if statement&lt;/code&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Extra: If we wished to add an element (or elements) to the beginning of an array, we could use the &lt;code&gt;unshift&lt;/code&gt; method. We can take that &lt;code&gt;const letters = [‘b’, ‘c’, ‘d’, ‘e’]&lt;/code&gt; array I used as an example before and add an &lt;code&gt;a&lt;/code&gt; at the beginning as follows: &lt;code&gt;array.unshift(‘a’)&lt;/code&gt;. Now the output for &lt;code&gt;console.log(letters)&lt;/code&gt; will go from &lt;code&gt;[‘b’, ‘c’, ‘d’, ‘e’]&lt;/code&gt; to &lt;code&gt;[‘a’, ‘b’, ‘c’, ‘d’, ‘e’]&lt;/code&gt;. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Removing Elements from Multidimensional Arrays
&lt;/h2&gt;

&lt;p&gt;The method used to remove the last element from an array is called &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/pop"&gt;pop&lt;/a&gt;. This will be an easy one. As we push elements into the array we get a two-dimensional array that looks like this: &lt;code&gt;[ [passengersInStationOne, passengersOutStationOne], [passengersInStationTwo, passengersOutStationTwo] ]&lt;/code&gt;. When we use the &lt;code&gt;pop&lt;/code&gt; method, it will remove not just &lt;code&gt;passengersOutStationTwo&lt;/code&gt;, but the whole &lt;code&gt;[passengersInStationTwo, passengersOutStationTwo]&lt;/code&gt; array as this whole array is considered an element of the &lt;code&gt;passengerLog&lt;/code&gt; array.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;passengerLog&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[];&lt;/span&gt; &lt;span class="c1"&gt;// already established &lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;removeFromPassengerLog&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// Remove last entry from passenger log&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;passengerLog&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;pop&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;blockquote&gt;
&lt;p&gt;Extra: If we wished to remove an element from the beginning of an array, we could use the &lt;code&gt;shift&lt;/code&gt; method. We can take that &lt;code&gt;const letters = [‘a’, ‘b’, ‘c’, ‘d’, ‘e’]&lt;/code&gt; array and remove the &lt;code&gt;a&lt;/code&gt; at the beginning as follows: &lt;code&gt;array.shift()&lt;/code&gt;. Now the output for &lt;code&gt;console.log(letters)&lt;/code&gt; will go from &lt;code&gt;[‘a’, ‘b’, ‘c’, ‘d’, ‘e’]&lt;/code&gt; to &lt;code&gt;[‘b’, ‘c’, ‘d’, ‘e’]&lt;/code&gt;. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Reduce Multidimensional Arrays
&lt;/h2&gt;

&lt;p&gt;The &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce"&gt;reduce&lt;/a&gt; method will execute a function determined by you on each element. After it is done it will return a single output value. &lt;/p&gt;

&lt;p&gt;Reduce can take in four arguments. An accumulator(acc), current value (cur), current index (idx), and source array (src) with a syntax &lt;code&gt;array.reduce(function(acc, cur, idx, src), initialValue)&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;For this example, we will only use the first two arguments (which are the only two that are required). Applying &lt;code&gt;reduce&lt;/code&gt; to the &lt;code&gt;passengerLog&lt;/code&gt; array means that for each &lt;code&gt;[passengersInStationX, passengersOutStationX]&lt;/code&gt; entry we will execute the function provided. The results will be stored inside the accumulator (acc) before going to the next entry, executing the function on that next set of values, and adding the result to the accumulator. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Side Note: Arrays are zero-based. To access an item in an array you can use the index position as follows: &lt;code&gt;const letters = [‘b’, ‘c’, ‘d’, ‘e’]&lt;/code&gt; &lt;code&gt;console.log(letters[0]) //output: ‘b’&lt;/code&gt; &lt;code&gt;console.log(letters[1]) //output: ‘c’&lt;/code&gt;. As for multidimensional arrays, if we have &lt;code&gt;const letters2 = [ [‘b’, ‘c’], [‘d’, ‘e’] ]&lt;/code&gt; and we want to access the letter ‘c’ we would need to use the index of the first element &lt;code&gt;[‘b’, ‘c’]&lt;/code&gt; and then the index of the letter ‘c’ inside that array. That means &lt;code&gt;console.log(letters2[0]) //output: [‘b’, ‘c’]&lt;/code&gt;, whereas &lt;code&gt;console.log(letters2[0][1]) //output: ‘c’&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;calculatePassengersTotal&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// Calculate number of passengers onboard.&lt;/span&gt;
   &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;passengerLog&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;reduce&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;acc&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;cur&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;acc&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="nx"&gt;cur&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nx"&gt;cur&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
   &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Another way of doing the same thing would be as follows:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;calculatePassengersTotal&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// Calculate number of passengers onboard.&lt;/span&gt;
  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;passengerLog&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;reduce&lt;/span&gt;&lt;span class="p"&gt;((&lt;/span&gt;&lt;span class="nx"&gt;onboard&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;boarding&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;disembarking&lt;/span&gt;&lt;span class="p"&gt;])&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;onboard&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="nx"&gt;boarding&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="nx"&gt;disembarking&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
   &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Next Station!
&lt;/h2&gt;

&lt;p&gt;The names of the stations are given to us so the management tool will automatically let the crew member in charge know which station they are at.  &lt;/p&gt;

&lt;p&gt;We will declare a couple of variables first. One for the index of the station, and since arrays are zero-based we will assign the number zero to it. The second variable will store the length of the array containing the names of the stations. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Side Note: The &lt;code&gt;length&lt;/code&gt; property returns the number of elements in an array. Arrays may be zero-based, but for this property we start counting from one. For a multidimensional array like &lt;code&gt;const letters2 = [['b', 'c'], ['d', 'e']];&lt;/code&gt; we would get an output of 2 from &lt;code&gt;console.log(letters.length)&lt;/code&gt; and not 1 (as if we started counting from zero) nor 4 (as if we were counting each letter as a separate element of the &lt;code&gt;letters2&lt;/code&gt; array). &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The basic form of this &lt;code&gt;nextStation&lt;/code&gt; function is &lt;code&gt;stationName.innerHTML = stations[stationIndex]&lt;/code&gt; so as to change the HTML content of the &lt;code&gt;stationName&lt;/code&gt; element to the station on the index &lt;code&gt;stationIndex&lt;/code&gt;. Since we assigned that to zero the first station will be &lt;code&gt;King's Cross&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;stations&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;     &lt;span class="c1"&gt;// already established &lt;/span&gt;
   &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;King's Cross&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Waverly&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Weasley&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Cardiff Central&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
   &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Hogsmeade&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;];&lt;/span&gt;   

&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;stationIndex&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;stationLength&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;stations&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;length&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;   &lt;span class="c1"&gt;// output: 5&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;nextStation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;stationIndex&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// Display name of station. &lt;/span&gt;
  &lt;span class="c1"&gt;// For the last two stations the text on the button will change.&lt;/span&gt;
  &lt;span class="c1"&gt;// On the last station the button will be disabled.&lt;/span&gt;
   &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;stationIndex&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="nx"&gt;stationLength&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;2&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;buttonAddPassengers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;textContent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Last Station Coming Up&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
   &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;stationIndex&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="nx"&gt;stationLength&lt;/span&gt; &lt;span class="o"&gt;-&lt;/span&gt; &lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;buttonAddPassengers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;textContent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;End of Journey&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="nx"&gt;buttonAddPassengers&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;disabled&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
   &lt;span class="p"&gt;}&lt;/span&gt; 
   &lt;span class="k"&gt;return &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;stationName&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;innerHTML&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;stations&lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="nx"&gt;stationIndex&lt;/span&gt;&lt;span class="p"&gt;]);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nf"&gt;nextStation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;stationIndex&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;I have added an &lt;code&gt;if...else statement&lt;/code&gt; to change the text content of the submit button for when the train is approaching the destination and to change it again when the journey has ended (disabling the button at the same time).  &lt;/p&gt;

&lt;h2&gt;
  
  
  Submit Passenger Log
&lt;/h2&gt;

&lt;p&gt;The main function that will be executed when we hit that submit button on the form is the one below. On it we will first call the &lt;code&gt;addToPassengerLog()&lt;/code&gt; function to add (or &lt;code&gt;push&lt;/code&gt;) the inputs logged by the crew member. Then we declare a variable and assign the results from the &lt;code&gt;calculatePassengersTotal()&lt;/code&gt; function, which will give us the number of passengers on board. &lt;/p&gt;

&lt;p&gt;If the total number of passengers is zero or more then we display the number in the assigned space provided using &lt;code&gt;innerHTML&lt;/code&gt; on that element. Next, we clear the input boxes using &lt;code&gt;form.reset();&lt;/code&gt;. Finally, we increase the &lt;code&gt;stationIndex&lt;/code&gt; by one and, with that, display the next station using the &lt;code&gt;nextStation(stationIndex)&lt;/code&gt; function.&lt;/p&gt;

&lt;p&gt;If the total number of passengers is less than zero, then that means there was a mistake since we can’t have a negative number of passengers on board. To give the crew member a chance to correct that mistake we will remove that last entry from the log using the &lt;code&gt;removeFromPassengerLog()&lt;/code&gt; function, clear the input boxes and send a message about the mistake for which the crew member will have to confirm they have read using &lt;code&gt;window.confirm( )&lt;/code&gt;.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;stationName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;.station__name&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  &lt;span class="c1"&gt;// already established &lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;passengersIn&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;.passengers__in&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  &lt;span class="c1"&gt;// already established &lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;passengersOut&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;.passengers__out&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  &lt;span class="c1"&gt;// already established &lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;passengersTotal&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;.passengers__total&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  &lt;span class="c1"&gt;// already established &lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;form&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;form&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  &lt;span class="c1"&gt;// already established &lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;submitPassengerLog&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
   &lt;span class="nx"&gt;e&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;preventDefault&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
   &lt;span class="nf"&gt;addToPassengerLog&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
   &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;totalPassengers&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;calculatePassengersTotal&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt; &lt;span class="nx"&gt;totalPassengers&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;=&lt;/span&gt; &lt;span class="mi"&gt;0&lt;/span&gt; &lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Display the total number of passengers on board.&lt;/span&gt;
    &lt;span class="nx"&gt;passengersTotal&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;innerHTML&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;`Passengers onboard: &lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;totalPassengers&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;
   &lt;span class="p"&gt;}&lt;/span&gt;
   &lt;span class="c1"&gt;// Clear input boxes.&lt;/span&gt;
   &lt;span class="nx"&gt;form&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;reset&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
   &lt;span class="c1"&gt;// Display next station&lt;/span&gt;
   &lt;span class="nx"&gt;stationIndex&lt;/span&gt;&lt;span class="o"&gt;++&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
   &lt;span class="nf"&gt;nextStation&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;stationIndex&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;

    &lt;span class="nf"&gt;removeFromPassengerLog&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="nx"&gt;form&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;reset&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="nb"&gt;window&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;confirm&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;Check how many witches and wizards are on the train./nYou can't have more of them leaving the train than are onboard.&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nx"&gt;form&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;submit&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;submitPassengerLog&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Demo
&lt;/h2&gt;

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

&lt;p&gt;For more on arrays, take a look at MDN web docs in &lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array"&gt;arrays&lt;/a&gt;. I hope that with what we have seen here together you now have a better understanding of multidimensional arrays and how to work with them on more complicated projects. &lt;/p&gt;

&lt;p&gt;If you liked what you read hit that ❤️ on the left or wherever it is. If you really liked it don’t forget to share it with the community by hitting that dot-dot-dot icon near the heart. &lt;/p&gt;

&lt;p&gt;💻 &lt;strong&gt;article.close()&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Resources
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://didacticode.com/reto-harry-potter/"&gt;Original Challenge&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.freecodecamp.org/news/css-naming-conventions-that-will-save-you-hours-of-debugging-35cea737d849/"&gt;Naming Conventions&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array"&gt;Arrays&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/push"&gt;Push Method&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/pop"&gt;Pop Method&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/Reduce"&gt;Reduce Method&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>javascript</category>
      <category>challenge</category>
      <category>tutorial</category>
      <category>wecoded</category>
    </item>
    <item>
      <title>Multi-faced Flip Card with a Click (Bonus: Going further into 3D space)</title>
      <dc:creator>Maria del Carmen Santiago</dc:creator>
      <pubDate>Tue, 07 Jul 2020 16:33:02 +0000</pubDate>
      <link>https://dev.to/santiagocodes/multi-faced-flip-card-with-a-click-bonus-going-further-into-3d-space-2jff</link>
      <guid>https://dev.to/santiagocodes/multi-faced-flip-card-with-a-click-bonus-going-further-into-3d-space-2jff</guid>
      <description>&lt;p&gt;&lt;em&gt;More than just your average &lt;strong&gt;Flip Card&lt;/strong&gt; tutorial. Don’t just flip your card on hover, use JavaScript to flip it on command. Includes instructions on how to change the reverse face to show a different face each time and tricks to give the card a nice 3D effect while flipping.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This series will be divided into three parts (plus a fun bonus): &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Part I: &lt;a href="https://dev.to/santiagocodes/multi-faced-flip-card-with-a-click-part-i-o6c"&gt;HTML&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Part II: &lt;a href="https://dev.to/santiagocodes/multi-faced-flip-card-with-a-click-part-2-css-3oam"&gt;CSS&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Part III: &lt;a href="https://dev.to/santiagocodes/multi-faced-flip-card-with-a-click-part-3-javascript-2f7f"&gt;JavaScript&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Bonus: Going further into 3D space&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  Bonus: Going further into 3D space
&lt;/h1&gt;

&lt;p&gt;The bonus part of this series will explore the possibility of giving a 3D effect to independent elements on our card. We will be having a look at the different CSS selectors and the properties that need to be added or edited. No extra JS needed. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Big shout out to Kevin Powell and his &lt;a href="https://www.youtube.com/watch?v=FeJEEE3zc4U"&gt;Create a 3D flipping animation with HTML and CSS&lt;/a&gt; youtube tutorial.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  Recap
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://postimg.cc/DWD07yZx"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--nKsFhADr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.postimg.cc/d1QymhKc/flip-card-structure.jpg" alt="flip-card-structure.jpg"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;It’s important to review the structure of our HTML document in order to decide upon the appropriate styles and where to apply them. So to recap, we have a parent element named &lt;code&gt;card__container&lt;/code&gt;, with a child named &lt;code&gt;card__content&lt;/code&gt;. The &lt;code&gt;card__container&lt;/code&gt; will remain in position, while the &lt;code&gt;card__content&lt;/code&gt; does the flipping.&lt;/p&gt;

&lt;p&gt;That last element will, in turn, have at least two children. These will be positioned one on top of the other, with the &lt;code&gt;card__front&lt;/code&gt; staying in position and the &lt;code&gt;card__back&lt;/code&gt; rotating 180 degrees on the y-axis. The resulting ‘card’ will show only the &lt;code&gt;card__front&lt;/code&gt; face by default. Using JavaScript, we rotated the &lt;code&gt;card__content&lt;/code&gt; element by adding a &lt;code&gt;class&lt;/code&gt; to it in order to rotate our ‘card’ on the y-axis and show the &lt;code&gt;card__back&lt;/code&gt; instead of the &lt;code&gt;card__front&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;As for the &lt;code&gt;card__back&lt;/code&gt;, we could have just one, or we could have several options with a &lt;code&gt;display: none;&lt;/code&gt; declaration. Using Javascript we can change which option to display by adding a &lt;code&gt;class&lt;/code&gt; with &lt;code&gt;display: block;&lt;/code&gt; to the specific &lt;code&gt;card__back&lt;/code&gt; we want, according to whatever condition we choose. For this &lt;em&gt;Stranger Things&lt;/em&gt; project, it will depend on which number is inserted on the &lt;code&gt;&amp;lt;form&amp;gt;&lt;/code&gt; at the &lt;code&gt;card__front&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Now, let’s get started!&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;code&gt;.card__face&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;The front and the back faces of the card share similar declarations so I’ve grouped them under the &lt;code&gt;.card__face&lt;/code&gt; selector. One thing I had to change (which I will explain later) was the transparency of the card. I could have just changed the &lt;code&gt;background: rgba(10,10,10,0.8)&lt;/code&gt; alpha value to 1, but I decided to replace it with a gradient background instead. &lt;/p&gt;

&lt;p&gt;A resource I enjoy using for this purpose is &lt;a href="https://www.gradientmagic.com/"&gt;Gradient Magic&lt;/a&gt;. On this website, you have hundreds of background gradient options to choose from. Pick the one you like, hit the &lt;code&gt;Copy CSS&lt;/code&gt; button, and paste that declaration into your CSS. Easy peasy. &lt;/p&gt;

&lt;p&gt;Nothing else is new from the last project on this selector: we still have the &lt;code&gt;transform-style: preserve-3d;&lt;/code&gt; to preserve the 3D look while flipping and the &lt;code&gt;backface-visibility: hidden;&lt;/code&gt; to hide whichever part of the card is not facing us. This isn’t really necessary when the card’s background image has no transparency, but it doesn’t hurt to have it.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.card__face&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;   &lt;span class="err"&gt;//&lt;/span&gt; &lt;span class="err"&gt;-or-&lt;/span&gt; &lt;span class="err"&gt;.card__front,&lt;/span&gt; &lt;span class="err"&gt;.card__back&lt;/span&gt; &lt;span class="err"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;position&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;absolute&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="err"&gt;//&lt;/span&gt; &lt;span class="err"&gt;remove&lt;/span&gt; &lt;span class="err"&gt;line&lt;/span&gt;
  &lt;span class="err"&gt;//&lt;/span&gt; &lt;span class="nl"&gt;background&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;rgba&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;0.8&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;   
&lt;span class="err"&gt;//&lt;/span&gt; &lt;span class="err"&gt;new&lt;/span&gt; &lt;span class="err"&gt;line&lt;/span&gt;
  &lt;span class="nl"&gt;background-image&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;radial-gradient&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;circle&lt;/span&gt; &lt;span class="n"&gt;at&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;rgb&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;71&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;41&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;41&lt;/span&gt;&lt;span class="p"&gt;),&lt;/span&gt;&lt;span class="nb"&gt;rgb&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;8&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;));&lt;/span&gt;
  &lt;span class="nl"&gt;box-shadow&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="m"&gt;10px&lt;/span&gt; &lt;span class="m"&gt;8px&lt;/span&gt; &lt;span class="n"&gt;rgba&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;255&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;0.75&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nl"&gt;border-radius&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;5px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;text-align&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;backface-visibility&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;hidden&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;transform-style&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;preserve-3d&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;code&gt;.card__front&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;The front of the card with the validating &lt;code&gt;&amp;lt;form&amp;gt;&lt;/code&gt; is where the magic starts to happen. In comes the &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/translateZ"&gt;translateZ&lt;/a&gt; property value. &lt;/p&gt;

&lt;p&gt;When we translate (or reposition) elements on the x-axis it means that we are moving those elements from side to side on the screen, on the y-axis we move them up and down the screen. If you want to take that element into a 3D space you have to move it on the z-axis. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://postimg.cc/yg6kZ057"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--CWApZ0sr--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.postimg.cc/W3grxnwq/z-axus.png" alt="z-axus.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;As for removing any transparency from the background of the card, this had to do with the &lt;code&gt;backface-visibility: hidden;&lt;/code&gt; not working on the elements that have a &lt;code&gt;translateZ&lt;/code&gt; property on them while flipping. You could solve this by adding a &lt;code&gt;backface-visibility: hidden;&lt;/code&gt; declaration to all the selectors that have a &lt;code&gt;translateZ&lt;/code&gt; property, but that seems like more trouble than it’s worth so I just removed the transparency for the background color of the card.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.card__front&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;40px&lt;/span&gt; &lt;span class="m"&gt;20px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.card__front&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nt"&gt;h2&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;font-weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;900&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;padding-bottom&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0.5em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;text-align&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;white&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;text-shadow&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;-0.05rem&lt;/span&gt; &lt;span class="m"&gt;-0.05rem&lt;/span&gt; &lt;span class="m"&gt;5px&lt;/span&gt; &lt;span class="n"&gt;rgba&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;237&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;43&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;18&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nl"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;translateZ&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;5rem&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;   &lt;span class="err"&gt;//&lt;/span&gt; &lt;span class="err"&gt;new&lt;/span&gt; &lt;span class="err"&gt;line&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.card__front&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nt"&gt;p&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;position&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;fixed&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;bottom&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;18px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;font-weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;600&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;text-align&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;white&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;text-shadow&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;-0.05rem&lt;/span&gt; &lt;span class="m"&gt;-0.05rem&lt;/span&gt; &lt;span class="m"&gt;5px&lt;/span&gt; &lt;span class="n"&gt;rgba&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;237&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;43&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;18&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nl"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;translateZ&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;3rem&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;   &lt;span class="err"&gt;//&lt;/span&gt; &lt;span class="err"&gt;new&lt;/span&gt; &lt;span class="err"&gt;line&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.card__front&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nt"&gt;form&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;margin-top&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;25px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;translateZ&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;7rem&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;   &lt;span class="err"&gt;//&lt;/span&gt; &lt;span class="err"&gt;new&lt;/span&gt; &lt;span class="err"&gt;line&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.card__front&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nt"&gt;form&lt;/span&gt; &lt;span class="nt"&gt;input&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;10px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;border&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1px&lt;/span&gt; &lt;span class="nb"&gt;solid&lt;/span&gt; &lt;span class="n"&gt;rgba&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;0.1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#ddd&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;box-shadow&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="m"&gt;5px&lt;/span&gt; &lt;span class="m"&gt;3px&lt;/span&gt; &lt;span class="n"&gt;rgba&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;255&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;0.4&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nl"&gt;border-radius&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;5px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.card__front&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nt"&gt;form&lt;/span&gt; &lt;span class="nt"&gt;input&lt;/span&gt;&lt;span class="nd"&gt;:hover&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#eee&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;box-shadow&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="m"&gt;7px&lt;/span&gt; &lt;span class="m"&gt;5px&lt;/span&gt; &lt;span class="n"&gt;rgba&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;255&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;0.4&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.btn&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;margin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;5px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;10px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;outline&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;border&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1px&lt;/span&gt; &lt;span class="nb"&gt;solid&lt;/span&gt; &lt;span class="n"&gt;rgba&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;0.1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;transparent&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;box-shadow&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="m"&gt;5px&lt;/span&gt; &lt;span class="m"&gt;3px&lt;/span&gt; &lt;span class="n"&gt;rgba&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;255&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;0.4&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;white&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;border-radius&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;10px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.btn&lt;/span&gt;&lt;span class="nd"&gt;:hover&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;box-shadow&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="m"&gt;7px&lt;/span&gt; &lt;span class="m"&gt;5px&lt;/span&gt; &lt;span class="n"&gt;rgba&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;255&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;0.4&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.btn&lt;/span&gt;&lt;span class="nd"&gt;:active&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#333&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;code&gt;.card__back&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;The most important change for the &lt;code&gt;card__back&lt;/code&gt; selector is choosing which elements within it we want to reposition on the z-axis, and by how much. &lt;/p&gt;

&lt;p&gt;For aesthetic value, I have added a &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/::before"&gt;pseudo-element&lt;/a&gt; on the &lt;code&gt;card__back&lt;/code&gt; selector. I did this because I thought it would look better to add a &lt;code&gt;transform: translateZ(3rem);&lt;/code&gt; to a border around the image than adding this declaration to the image itself.&lt;/p&gt;

&lt;p&gt;A &lt;code&gt;transform: translateZ(5rem);&lt;/code&gt; added to the &lt;code&gt;btn__back&lt;/code&gt; selector will make that button “pop” even more than the border around the image, while a &lt;code&gt;transform: translateZ(7rem);&lt;/code&gt; added to the paragraph inside &lt;code&gt;card__back__one&lt;/code&gt; will make that element “pop” further still.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.btn__back&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;margin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0.5em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;background&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;rgba&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;0.8&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nl"&gt;position&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;absolute&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;top&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2.5em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;right&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2.5em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;translateZ&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;5rem&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;   &lt;span class="err"&gt;//&lt;/span&gt; &lt;span class="err"&gt;new&lt;/span&gt; &lt;span class="err"&gt;line&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.card__back&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;rotateY&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;180deg&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;none&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.card__back.display&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;block&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.card__back&lt;/span&gt;&lt;span class="nd"&gt;::before&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;   &lt;span class="err"&gt;//&lt;/span&gt; &lt;span class="err"&gt;new&lt;/span&gt; &lt;span class="err"&gt;ruleset&lt;/span&gt;
  &lt;span class="nl"&gt;content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;''&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;position&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;absolute&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;top&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0.75em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;bottom&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0.75em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;left&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0.75em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;right&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0.75em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;border&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1px&lt;/span&gt; &lt;span class="nb"&gt;solid&lt;/span&gt; &lt;span class="nb"&gt;rgb&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;255&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nl"&gt;border-radius&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;5px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;translateZ&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;3rem&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;   &lt;span class="err"&gt;//&lt;/span&gt; &lt;span class="err"&gt;new&lt;/span&gt; &lt;span class="err"&gt;line&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.image__back&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0.8em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;border-radius&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;5px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nf"&gt;#card__back__one&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nt"&gt;p&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;margin-top&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;-2.5em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#111&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;text-shadow&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;-0.05rem&lt;/span&gt; &lt;span class="m"&gt;-0.05rem&lt;/span&gt; &lt;span class="m"&gt;5px&lt;/span&gt; &lt;span class="n"&gt;rgba&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;237&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;43&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;18&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;font-weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;700&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;text-align&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;translateZ&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;7rem&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;   &lt;span class="err"&gt;//&lt;/span&gt; &lt;span class="err"&gt;new&lt;/span&gt; &lt;span class="err"&gt;line&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;code&gt;.card__content&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;No changes are made for this selector. The only declaration I would edit would be to change up that &lt;code&gt;transition: transform 2s;&lt;/code&gt; declaration from 2 to 3 seconds. I give you this recommendation because by slowing down the flip action the user can better appreciate the 3D effect we are trying to achieve, since this effect is only really appreciated while the card flips. &lt;/p&gt;

&lt;p&gt;Maybe in the future when we get fancy hologram-like computers we will be able to see those elements pop out of our screens. For now, while the card lays flat we won’t be able to see the elements pop closer towards us.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.card__content&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;position&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;relative&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;transform-style&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;preserve-3d&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;transform-origin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt; &lt;span class="nb"&gt;right&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;transition&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;transform&lt;/span&gt; &lt;span class="m"&gt;3s&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;   &lt;span class="err"&gt;//&lt;/span&gt; &lt;span class="err"&gt;line&lt;/span&gt; &lt;span class="err"&gt;edit&lt;/span&gt; 
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.card__content.is-flipped&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;translateX&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;-100%&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;rotateY&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;-180deg&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  &lt;code&gt;.card__container&lt;/code&gt;
&lt;/h2&gt;

&lt;p&gt;The &lt;code&gt;card__container&lt;/code&gt; will remain basically the same as well. The only thing I would recommend is to remove the &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/perspective"&gt;perspective&lt;/a&gt; property or give it a higher value. &lt;/p&gt;

&lt;p&gt;Why? Because the elements with a &lt;code&gt;translateZ()&lt;/code&gt; property value will be affected by the &lt;code&gt;perspective&lt;/code&gt; property. The lower the value of this last property, the larger the elements with a &lt;code&gt;Z&lt;/code&gt; &amp;gt; 0 will appear, hence messing with the look of the card. You could keep the same perspective, but you will have to adjust all the other elements affected by this.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.card__container&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;350px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;350px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="err"&gt;//&lt;/span&gt; &lt;span class="nl"&gt;perspective&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;350px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;   &lt;span class="err"&gt;//&lt;/span&gt; &lt;span class="err"&gt;remove&lt;/span&gt; &lt;span class="err"&gt;line&lt;/span&gt;  &lt;span class="err"&gt;-or&lt;/span&gt; &lt;span class="err"&gt;edit-&lt;/span&gt; &lt;span class="nl"&gt;perspective&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1000px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  CSS Variables (optional)
&lt;/h2&gt;

&lt;p&gt;This is a good project in which to use CSS variables.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nd"&gt;:root&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="py"&gt;--level-one&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;translateZ&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;3rem&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="py"&gt;--level-two&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;translateZ&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;5rem&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="py"&gt;--level-three&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;translateZ&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;7rem&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;This way you can you can make a variable for each level you want to have, while moving on the z-axis. If you want to change the levels you only need to edit the property value in the variable rather than go one selector at a time and checking which needs editing and by how much. &lt;/p&gt;

&lt;p&gt;Below is an example of how to use the variable we have set above.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.card__front&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nt"&gt;form&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;margin-top&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;25px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;var&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;--level-three&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;  
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Demo
&lt;/h2&gt;

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

&lt;p&gt;If you liked what you read hit that ❤️ on the left or wherever it is. If you really liked it don’t forget to share it with the community by hitting that dot-dot-dot icon near that heart. &lt;/p&gt;

&lt;p&gt;💻 &lt;strong&gt;article.close()&lt;/strong&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Resources
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.youtube.com/watch?v=FeJEEE3zc4U"&gt;Create a 3D flipping animation with HTML and CSS&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://alligator.io/css/translatez-and-perspective/"&gt;Tricks for Using CSS translateZ() and perspective()&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.gradientmagic.com/"&gt;Gradient Magic&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/perspective"&gt;perspective&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;Transform Function: &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/transform-function/translateZ"&gt;translateZ&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;Pseudo-element: &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/::before"&gt;::before&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Custom Properties: &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/Using_CSS_custom_properties"&gt;CSS Variables&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>javascript</category>
      <category>css</category>
      <category>html</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Multi-faced Flip Card with a Click (Part 3: JavaScript)</title>
      <dc:creator>Maria del Carmen Santiago</dc:creator>
      <pubDate>Thu, 02 Jul 2020 10:56:01 +0000</pubDate>
      <link>https://dev.to/santiagocodes/multi-faced-flip-card-with-a-click-part-3-javascript-2f7f</link>
      <guid>https://dev.to/santiagocodes/multi-faced-flip-card-with-a-click-part-3-javascript-2f7f</guid>
      <description>&lt;p&gt;&lt;em&gt;More than just your average &lt;strong&gt;Flip Card&lt;/strong&gt; tutorial. Don’t just flip your card on hover, use JavaScript to flip it on command. Includes instructions on how to change the reverse face to show a different face each time and tricks to give the card a nice 3D effect while flipping.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This series will be divided into three parts (plus a fun bonus at the end): &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Part I: &lt;a href="https://dev.to/santiagocodes/multi-faced-flip-card-with-a-click-part-i-o6c"&gt;HTML&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Part II: &lt;a href="https://dev.to/santiagocodes/multi-faced-flip-card-with-a-click-part-2-css-3oam"&gt;CSS&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Part III: &lt;a href="https://dev.to/santiagocodes/multi-faced-flip-card-with-a-click-part-3-javascript-2f7f"&gt;JavaScript&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Bonus: &lt;a href="https://dev.to/santiagocodes/multi-faced-flip-card-with-a-click-bonus-going-further-into-3d-space-2jff"&gt;Going further into 3D space&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  Part III: JavaScript
&lt;/h1&gt;

&lt;p&gt;Let’s start with my favorite part of this project… the JavaScript! We’ll start with the function that flips the card. Then I will discuss the function that validates the input and gives us the appropriate response card on the back. Next, we will move on to the function that takes care of flipping the card back around to the front face again. Finally, I discuss the event listeners we will have to add in order for these functions to execute when needed. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;In case you feel you need to review your JS basics, click &lt;a href="https://developer.mozilla.org/en-US/docs/Learn/Getting_started_with_the_web/JavaScript_basics"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;At the bottom of the page, you will find two codepens. The first is a codepen for this project and the second is for a similar, but more basic, project. &lt;/p&gt;

&lt;p&gt;Let’s get started!&lt;/p&gt;

&lt;h2&gt;
  
  
  flipCard Function
&lt;/h2&gt;

&lt;p&gt;The function to flip the card is a very short one. If you recall from the previous article in this series, we have a CSS ruleset of &lt;code&gt;.card__content.is-flipped {transform: translateX(-100%) rotateY(-180deg);}&lt;/code&gt;. So what we will be doing here is selecting the &lt;code&gt;card__content&lt;/code&gt; element in our javascript and &lt;a href="https://www.w3schools.com/howto/howto_js_toggle_class.asp"&gt;toggling&lt;/a&gt; the “is-flipped” &lt;code&gt;class&lt;/code&gt; to make that &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; flip. Remember that the container stays put while the content flips.  &lt;/p&gt;

&lt;p&gt;When you toggle a &lt;code&gt;class&lt;/code&gt; you can think of it like an on/off switch that will add or remove the &lt;code&gt;class&lt;/code&gt; according to its previous state. You access an element’s list of classes using &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/Element/classList"&gt;element.classList&lt;/a&gt;. From there you can do things like &lt;code&gt;.toggle(‘class__name’)&lt;/code&gt;, adding a class to the element using &lt;code&gt;.add(‘class__name’)&lt;/code&gt;, among other things. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Quick JS Review: When using &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector"&gt;document.querySelector()&lt;/a&gt; with a &lt;code&gt;(‘.class__name’)&lt;/code&gt; selector, the first element in the document with the &lt;code&gt;class&lt;/code&gt; of “class_&lt;em&gt;name” is returned. To return all matches to that &lt;code&gt;class&lt;/code&gt;, use &lt;code&gt;querySelectorAll()&lt;/code&gt;. The next step should be to save this result inside a variable. When using a selector of `(‘#id&lt;/em&gt;&lt;em&gt;name’)&lt;code&gt;, the element with the unique &lt;/code&gt;id` called “id&lt;/em&gt;_name” will be returned and should be saved in its own variable as well.&lt;br&gt;
&lt;/p&gt;
&lt;/blockquote&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;cardContent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;.card__content&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;flipCard&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;cardContent&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;classList&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;toggle&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;is-flipped&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  checkNumber Function
&lt;/h2&gt;

&lt;p&gt;We have a card with a &lt;code&gt;&amp;lt;form&amp;gt;&lt;/code&gt; on the front that will validate a number given by the user. The card will flip using the previous function and on the back of it, we will get… nothing. Do you remember the &lt;code&gt;.card__back&lt;/code&gt; CSS ruleset? If you take a look at it, it has a &lt;code&gt;display: none;&lt;/code&gt; declaration that will make all the elements with this &lt;code&gt;class&lt;/code&gt; “disappear” from our view. &lt;/p&gt;

&lt;p&gt;So, let’s back up a little and go step by step on this one. First, we will create three variables in which we will store the three different backs of the card using their unique &lt;code&gt;id&lt;/code&gt;s. Then we will create a function, which I have named &lt;code&gt;checkNumber()&lt;/code&gt; and we will pass the event on it. We pass on the event because we need to prevent the page from submitting the form and refreshing the page by using the &lt;code&gt;event.preventDefault()&lt;/code&gt; method. &lt;/p&gt;

&lt;p&gt;In a variable, we will store the value given to us by the user using &lt;code&gt;document.querySelector('#input__form').value&lt;/code&gt;. We will then proceed to &lt;em&gt;check&lt;/em&gt; the &lt;em&gt;number&lt;/em&gt; using an &lt;code&gt;if&lt;/code&gt; statement. If the input number is equal to 6.62607015 ( one of the Planck’s constant values mentioned in Part I of this series), then we will add the &lt;code&gt;class&lt;/code&gt; of “display” to &lt;code&gt;#card__back__one&lt;/code&gt;. If you look back you will remember that in the CSS we have a ruleset of &lt;code&gt;.card__back.display { display: block;}&lt;/code&gt;. That is the class we will be adding, and is why &lt;code&gt;#card__back__one&lt;/code&gt; will show and not the others. &lt;/p&gt;

&lt;p&gt;Now, if the input number is equal to 6.62607004 then it will be &lt;code&gt;#card__back__two&lt;/code&gt; that is shown and not &lt;code&gt;#card__back__one&lt;/code&gt;. If the user inputs any other number, &lt;code&gt;#card__back__three&lt;/code&gt; will be the one shown to the user instead of the other two. After adding the “display” &lt;code&gt;class&lt;/code&gt; to the correct card we will call the &lt;code&gt;flipCard()&lt;/code&gt; function we worked on before. An extra method you may want to use is the &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/reset"&gt;form.reset()&lt;/a&gt; method in order to restore the default values of our &lt;code&gt;&amp;lt;form&amp;gt;&lt;/code&gt;. In our case, that would set the input value back to a blank.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;card1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;#card__back__one&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;card2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;#card__back__two&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;card3&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;#card__back__three&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;input&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;#input__form&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;form&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;form&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;checkNumber&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;){&lt;/span&gt;
  &lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;preventDefault&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="kd"&gt;let&lt;/span&gt; &lt;span class="nx"&gt;inputNumber&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;input&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;value&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;inputNumber&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mf"&gt;6.62607015&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;card1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;classList&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;display&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="k"&gt;if&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;inputNumber&lt;/span&gt; &lt;span class="o"&gt;==&lt;/span&gt; &lt;span class="mf"&gt;6.62607004&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;card2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;classList&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;display&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;card3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;classList&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;add&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;display&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nx"&gt;flipCard&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
  &lt;span class="nx"&gt;form&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;reset&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  flipCardBack Function
&lt;/h2&gt;

&lt;p&gt;Do we need another function to flip the card back to the front of the card? In this case we do as we need to remove that “display” &lt;code&gt;class&lt;/code&gt; we just added. We do not want the back of the card to disappear before it has flipped completely and the page is already showing us the front. That is why we will use the &lt;a href="https://www.w3schools.com/jsref/met_win_settimeout.asp"&gt;setTimeout&lt;/a&gt; method for this one. Inside &lt;code&gt;setTimeout&lt;/code&gt; we will have a function that will remove the &lt;code&gt;class&lt;/code&gt; “display” from all of the backs of the card. This function will be executed after 2000 milliseconds (it works the same if you choose just 1000 milliseconds). This value I chose has to do with the transition time I set in the CSS (which was two seconds). We mustn’t forget to flip that card either so just reuse the &lt;code&gt;flipCard&lt;/code&gt; function in there.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;card1&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;#card__back__one&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;card2&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;#card__back__two&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;card3&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;#card__back__three&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nx"&gt;flipCardBack&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nx"&gt;setTimeout&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;card1&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;classList&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;remove&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;display&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="nx"&gt;card2&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;classList&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;remove&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;display&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="nx"&gt;card3&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;classList&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;remove&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;display&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="mi"&gt;2000&lt;/span&gt; &lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="nx"&gt;flipCard&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  Event Listeners
&lt;/h2&gt;

&lt;p&gt;We have all of our functions, but when do they get executed? The &lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener"&gt;addEventListener()&lt;/a&gt; method will call a function when an event happens to the target element. &lt;/p&gt;

&lt;p&gt;The first event listener is an easy one. When a form is submitted, the &lt;code&gt;checkNumber&lt;/code&gt; function will be executed. The event we passed inside the parentheses is that submit. &lt;/p&gt;

&lt;p&gt;The second event listener caused me a bit of trouble. What I forgot was that, even though all the buttons at the back have the same class and look the same, they are three different buttons. So initially I added an event listener like the following &lt;code&gt;btnBack.addEventListener(click, flipCardBack);&lt;/code&gt; and it worked… the first time around. After the first full flip, I would enter another number on the &lt;code&gt;&amp;lt;form&amp;gt;&lt;/code&gt;, and when it flipped a second time I was getting the card face I wanted, but the button wouldn’t flip back to the front. &lt;/p&gt;

&lt;p&gt;It was driving me a bit crazy that the button would work once, but not the second time around. Well, it turned out that I needed to add an event listener for each button separately. You could place an &lt;code&gt;id&lt;/code&gt; on each button and have an event listener added to each like so, &lt;code&gt;const btnBack1 = document.querySelector('#btn__back1').addEventListener(‘click’, flipCardBack)&lt;/code&gt;. That is fine when you only have three buttons, but what if there were more? That is where &lt;code&gt;forEach&lt;/code&gt; comes in handy.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;form&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;form&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;btnBack&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;querySelectorAll&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;.btn__back&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="nx"&gt;form&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;submit&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;checkNumber&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;btnBack&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;forEach&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;btn&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nx"&gt;btn&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="err"&gt;‘&lt;/span&gt;&lt;span class="nx"&gt;click&lt;/span&gt;&lt;span class="err"&gt;’&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;flipCardBack&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  The Code
&lt;/h2&gt;

&lt;p&gt;Here is the CodePen of the complete project. Feel free to fork it and play around with it. I just ask that you share your code if you make something cool with it! I would enjoy having a look and learning something new. &lt;/p&gt;

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

&lt;h2&gt;
  
  
  Alternative Simpler Solution
&lt;/h2&gt;

&lt;p&gt;There is a simpler way of doing all of this. You could just make one back of the card instead of three and change the image using &lt;code&gt;image.src&lt;/code&gt; as shown below, but that will limit you in terms of having completely different card faces with different layouts. &lt;/p&gt;

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

&lt;p&gt;If you liked what you read hit that ❤️ on the left or wherever it is. If you really liked it don’t forget to share it with the community by hitting that dot-dot-dot icon near the heart. &lt;/p&gt;

&lt;p&gt;💻 &lt;strong&gt;article.close()&lt;/strong&gt;&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Learn/Getting_started_with_the_web/JavaScript_basics"&gt;JavaScript Basics&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.w3schools.com/howto/howto_js_toggle_class.asp"&gt;Toggle a Class&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/Element/classList"&gt;element.classList&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector"&gt;document.querySelector()&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;
&lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLFormElement/reset"&gt;form.reset()&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.w3schools.com/jsref/met_win_settimeout.asp"&gt;setTimeout&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/EventTarget/addEventListener"&gt;addEventListener()&lt;/a&gt; &lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>tutorial</category>
      <category>html</category>
      <category>css</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Multi-faced Flip Card with a Click (Part 2: CSS)</title>
      <dc:creator>Maria del Carmen Santiago</dc:creator>
      <pubDate>Tue, 30 Jun 2020 19:12:08 +0000</pubDate>
      <link>https://dev.to/santiagocodes/multi-faced-flip-card-with-a-click-part-2-css-3oam</link>
      <guid>https://dev.to/santiagocodes/multi-faced-flip-card-with-a-click-part-2-css-3oam</guid>
      <description>&lt;p&gt;&lt;em&gt;More than just your average &lt;strong&gt;Flip Card&lt;/strong&gt; tutorial. Don’t just flip your card on hover, use JavaScript to flip it on command. Includes instructions on how to change the reverse face to show a different face each time and tricks to give the card a nice 3D effect while flipping.&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;This series will be divided into three parts (plus a fun bonus at the end): &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Part I: &lt;a href="https://dev.to/santiagocodes/multi-faced-flip-card-with-a-click-part-i-o6c"&gt;HTML&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Part II: &lt;a href="https://dev.to/santiagocodes/multi-faced-flip-card-with-a-click-part-2-css-3oam"&gt;CSS&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Part III: &lt;a href="https://dev.to/santiagocodes/multi-faced-flip-card-with-a-click-part-3-javascript-2f7f"&gt;JavaScript&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Bonus: &lt;a href="https://dev.to/santiagocodes/multi-faced-flip-card-with-a-click-bonus-going-further-into-3d-space-2jff"&gt;Going further into 3D space&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  Part II: The CSS
&lt;/h1&gt;

&lt;p&gt;I will be covering this part by starting from the card outline and working my way in. There will be some explanation about what each declaration is doing, and I will provide links for those of you that want to understand each property further.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;In case you feel like you need to review your CSS basics, click &lt;a href="https://developer.mozilla.org/en-US/docs/Learn/Getting_started_with_the_web/CSS_basics"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  The Container
&lt;/h2&gt;

&lt;p&gt;Let’s start with the &lt;code&gt;.card__container&lt;/code&gt; selector, which refers to the outline &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; of our card, and give it the desired width and height. You can choose different &lt;a href="https://www.freecodecamp.org/news/css-unit-guide/"&gt;CSS units&lt;/a&gt; for this. I used absolute units by setting both the width and the height to 350px, but you can use relative units (e.g. em, %, vw, vh) if it suits you best for responsiveness. &lt;/p&gt;

&lt;p&gt;The last property is a new one for me, at least until a week ago, called &lt;code&gt;perspective&lt;/code&gt;. As I mentioned in Part I, the container will stay static and the content will be the one doing the flip. By adding a &lt;code&gt;perspective&lt;/code&gt; property to the container of our card we will be giving the child element, which in our case will be the &lt;code&gt;.card__content&lt;/code&gt;, a perspective view. As for the property value, a lower number will give you a more intense 3D effect. (Once the project is up and running, try changing the perspective from 350px to 50px and see how freaky it looks. For now, you won’t notice anything though so just keep it in mind for later).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.card__container&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;350px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;350px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;perspective&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;350px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  The Content
&lt;/h2&gt;

&lt;p&gt;With width and height both set to 100%, our &lt;code&gt;.card__content&lt;/code&gt; will take up all the space of the parent element, which is that of the &lt;code&gt;.card__container&lt;/code&gt; that we just set up a moment ago. The &lt;code&gt;position&lt;/code&gt; property will be set to &lt;code&gt;relative&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;The &lt;a href="https://www.w3schools.com/cssref/css3_pr_transform-style.asp"&gt;transform-style&lt;/a&gt; property set to &lt;code&gt;preserve-3d&lt;/code&gt; does exactly as it states. This will preserve the 3D appearance of the element as it flips. This effect is only appreciated when applying the &lt;code&gt;transform&lt;/code&gt; property, which we will be adding to the &lt;code&gt;.card__content.is-flipped&lt;/code&gt; selector. (This new &lt;code&gt;.is-flipped&lt;/code&gt; class will be of use to us on the next part of the series.)&lt;/p&gt;

&lt;p&gt;You could set the &lt;code&gt;transform&lt;/code&gt; property to rotate 180 degrees on the y-axis alone, but adding a few extra things, like &lt;code&gt;translateX(-100%)&lt;/code&gt; alongside the &lt;a href="https://css-tricks.com/almanac/properties/t/transform-origin/"&gt;transform-origin&lt;/a&gt; property will give the flip a nice effect, although this is optional. &lt;/p&gt;

&lt;p&gt;The &lt;code&gt;transform-origin&lt;/code&gt; default value is &lt;code&gt;50% 50%&lt;/code&gt;, which is the center of the element. When the transformation is applied to the element and the &lt;code&gt;transform-origin&lt;/code&gt; is set to &lt;code&gt;center right&lt;/code&gt; the rotation’s axis will move to the center of the right-hand edge. You can better understand this concept if you play with the values and see the effects yourself. &lt;/p&gt;

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

&lt;p&gt;The &lt;code&gt;transform-style&lt;/code&gt; and &lt;code&gt;transform-origin&lt;/code&gt; properties only work when you have a &lt;code&gt;transform&lt;/code&gt; property on the element. On the other hand, the &lt;a href="https://www.w3schools.com/css/css3_transitions.asp"&gt;transition&lt;/a&gt; property works on any property. This is used to allow a smooth transition when there is a change detected in the property selected. In our case we set the transition a value to &lt;code&gt;transform 2s&lt;/code&gt;. This means that when the transform property changes it won’t do so abruptly, but will do so over two seconds. You can change this, but I found that 1 second was too quick, and although 3 seconds was acceptable, it was a bit too slow for my taste.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.card__content&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;position&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;relative&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;transform-style&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;preserve-3d&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;transform-origin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt; &lt;span class="nb"&gt;right&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;transition&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;transform&lt;/span&gt; &lt;span class="m"&gt;2s&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.card__content.is-flipped&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;translateX&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;-100%&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;rotateY&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;-180deg&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  The Faces
&lt;/h2&gt;

&lt;p&gt;Now, let’s move on to the content on the front and back of the card. Most of the properties will be the same for these two, except for a few differences. We can group the equal declarations under a class name like I did with &lt;code&gt;.card-face&lt;/code&gt;, or you could skip adding that extra class to those &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt;s and group the front and back selectors with a comma at the center like so &lt;code&gt;.card-front, .card-back{ property: property-value; }&lt;/code&gt;. The choice is yours. &lt;/p&gt;

&lt;p&gt;I won’t explain those declarations that are for aesthetics purposes, but I will explain how the other ones will help us get our flip card working. We previously set the &lt;code&gt;position&lt;/code&gt; of the &lt;code&gt;.card__content&lt;/code&gt; to &lt;code&gt;relative&lt;/code&gt;, and that had to do with the next property we will be adding to the face of the card. With a declaration of &lt;a href="https://css-tricks.com/almanac/properties/p/position/"&gt;position: absolute&lt;/a&gt; the reverse face of the card will be revealed in the same position as the front face of the card, and not below as the space the two elements take up will be one on top of the other.  &lt;/p&gt;

&lt;p&gt;This next part is a little difficult to explain, but bear with me. Take two pieces of paper (one to represent the &lt;code&gt;.card-front&lt;/code&gt; and another to represent the &lt;code&gt;.card-back&lt;/code&gt; of the card) and have them both facing you. When you simulate the flip action, what do you get? You get the back of the &lt;code&gt;.card-back&lt;/code&gt;. That is not what we want, which is why we will initially rotate &lt;code&gt;.card-back&lt;/code&gt; 180 degrees (or half a turn) on the y-axis. Do the same to your piece of paper and try again. &lt;/p&gt;

&lt;p&gt;One of the tricks to getting the reverse face to show different results is to set all of the &lt;code&gt;.card-back&lt;/code&gt;s to &lt;code&gt;display: none;&lt;/code&gt; and using JavaScript to change that declaration to &lt;code&gt;display: block;&lt;/code&gt; the one we want (you’ll see more about this on Part III of the series). &lt;/p&gt;

&lt;p&gt;Now, the &lt;code&gt;.card-back&lt;/code&gt; of the card won’t always be the face of the card facing backwards, which is why we add the &lt;code&gt;backface-visibility: hidden;&lt;/code&gt; declaration to both faces of the card. This means that whichever face is at the back will be hidden and won’t ruin the aesthetic of the face that is showing.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.card__face&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;   &lt;span class="c"&gt;/* -same as- .card-front, .card-back { */&lt;/span&gt;
  &lt;span class="nl"&gt;position&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;absolute&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;   
  &lt;span class="nl"&gt;background&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;rgba&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;0.8&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;   &lt;span class="c"&gt;/* aesthetic  */&lt;/span&gt;
  &lt;span class="nl"&gt;box-shadow&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="m"&gt;10px&lt;/span&gt; &lt;span class="m"&gt;8px&lt;/span&gt; &lt;span class="n"&gt;rgba&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;255&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;0.75&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;   &lt;span class="c"&gt;/* aesthetic  */&lt;/span&gt;
  &lt;span class="nl"&gt;border-radius&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;5px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;   &lt;span class="c"&gt;/* aesthetic  */&lt;/span&gt;
  &lt;span class="nl"&gt;text-align&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;    &lt;span class="c"&gt;/* aesthetic  */&lt;/span&gt;
  &lt;span class="nl"&gt;backface-visibility&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;hidden&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.card__back&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;transform&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;rotateY&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;180deg&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;   &lt;span class="c"&gt;/* -same as- transform: rotateY(0.5turn); */&lt;/span&gt;
  &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;none&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.card__back.display&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;block&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;h2&gt;
  
  
  The Front of the Card (optional)
&lt;/h2&gt;

&lt;p&gt;This next part you can change to whatever you want. Since the following is all about the aesthetics of the front of the card I won’t explain it, but I will explain a little bit about the &lt;a href="https://www.w3schools.com/cssref/css_selectors.asp"&gt;selectors&lt;/a&gt; used. &lt;/p&gt;

&lt;p&gt;When I use something like &lt;code&gt;.card__front &amp;gt; h2&lt;/code&gt; this means that the ruleset that follows will only be applied to the &lt;code&gt;&amp;lt;h2&amp;gt;&lt;/code&gt; tags where the parent is &lt;code&gt;.card__front&lt;/code&gt; class. When using something like &lt;code&gt;#input__form:hover&lt;/code&gt; this means that the ruleset will be applied when the user is hovering over the element with the &lt;code&gt;id&lt;/code&gt; of &lt;code&gt;#input__form&lt;/code&gt;. That &lt;code&gt;:hover&lt;/code&gt; is a &lt;a href="https://www.w3schools.com/css/css_pseudo_classes.asp"&gt;CSS pseudo class&lt;/a&gt;, just like &lt;code&gt;.btn:active&lt;/code&gt; where the ruleset will be applied for selected links with a &lt;code&gt;.btn&lt;/code&gt; class. &lt;/p&gt;

&lt;p&gt;If you have any questions I do encourage you to comment down below and I will get back to you. &lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;FYI: Selectors starting with &lt;code&gt;#&lt;/code&gt; are &lt;code&gt;id&lt;/code&gt;s and selectors starting with &lt;code&gt;.&lt;/code&gt; are classes. Also, remember that &lt;code&gt;id&lt;/code&gt;s are unique to one element. &lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;HTML:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="c"&gt;&amp;lt;!--       Front of the card --&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"card__face card__front"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;h2&amp;gt;&lt;/span&gt;Planck's Constant&lt;span class="nt"&gt;&amp;lt;/h2&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;form&amp;gt;&lt;/span&gt;
       &lt;span class="nt"&gt;&amp;lt;input&lt;/span&gt; 
               &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"input__form"&lt;/span&gt;
               &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"number"&lt;/span&gt; 
               &lt;span class="na"&gt;step=&lt;/span&gt;&lt;span class="s"&gt;"0.00000001"&lt;/span&gt; 
               &lt;span class="na"&gt;min=&lt;/span&gt;&lt;span class="s"&gt;"6"&lt;/span&gt; &lt;span class="na"&gt;max=&lt;/span&gt;&lt;span class="s"&gt;"7"&lt;/span&gt; 
               &lt;span class="na"&gt;placeholder=&lt;/span&gt;&lt;span class="s"&gt;"Enter Number"&lt;/span&gt; 
               &lt;span class="na"&gt;required=&lt;/span&gt;&lt;span class="s"&gt;"required"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
       &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"btn"&lt;/span&gt; &lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"submit"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Validate&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/form&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;CSS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.card__front&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;40px&lt;/span&gt; &lt;span class="m"&gt;20px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.card__front&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nt"&gt;h2&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;text-align&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;margin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;font-weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;900&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;padding-bottom&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0.5em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;white&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;text-shadow&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;-0.05rem&lt;/span&gt; &lt;span class="m"&gt;-0.05rem&lt;/span&gt; &lt;span class="m"&gt;5px&lt;/span&gt; &lt;span class="n"&gt;rgba&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;237&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;43&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;18&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.card__front&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nt"&gt;form&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;margin-top&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;25px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.card__front&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nt"&gt;form&lt;/span&gt; &lt;span class="nt"&gt;input&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;   &lt;span class="err"&gt;&amp;lt;!--&lt;/span&gt; &lt;span class="err"&gt;-same&lt;/span&gt; &lt;span class="err"&gt;as-&lt;/span&gt;  &lt;span class="err"&gt;#input__form&lt;/span&gt; &lt;span class="err"&gt;{&lt;/span&gt; &lt;span class="err"&gt;--&amp;gt;&lt;/span&gt;
  &lt;span class="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;10px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;border&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1px&lt;/span&gt; &lt;span class="nb"&gt;solid&lt;/span&gt; &lt;span class="n"&gt;rgba&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;0.1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#ddd&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;box-shadow&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="m"&gt;5px&lt;/span&gt; &lt;span class="m"&gt;3px&lt;/span&gt; &lt;span class="n"&gt;rgba&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;255&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;0.4&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nl"&gt;border-radius&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;5px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.card__front&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nt"&gt;form&lt;/span&gt; &lt;span class="nt"&gt;input&lt;/span&gt;&lt;span class="nd"&gt;:hover&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;    &lt;span class="err"&gt;&amp;lt;!--&lt;/span&gt; &lt;span class="err"&gt;-same&lt;/span&gt; &lt;span class="err"&gt;as-&lt;/span&gt;  &lt;span class="err"&gt;#&lt;/span&gt;&lt;span class="py"&gt;input__form&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="n"&gt;hover&lt;/span&gt; &lt;span class="err"&gt;{&lt;/span&gt; &lt;span class="n"&gt;--&lt;/span&gt;&lt;span class="err"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="n"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#eee&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;box-shadow&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="m"&gt;7px&lt;/span&gt; &lt;span class="m"&gt;5px&lt;/span&gt; &lt;span class="n"&gt;rgba&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;255&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;0.4&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.btn&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;margin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;5px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;10px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;outline&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;border&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1px&lt;/span&gt; &lt;span class="nb"&gt;solid&lt;/span&gt; &lt;span class="n"&gt;rgba&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;0.1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;transparent&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;box-shadow&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="m"&gt;5px&lt;/span&gt; &lt;span class="m"&gt;3px&lt;/span&gt; &lt;span class="n"&gt;rgba&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;255&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;0.4&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;white&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;border-radius&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;10px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.btn&lt;/span&gt;&lt;span class="nd"&gt;:hover&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;box-shadow&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="m"&gt;7px&lt;/span&gt; &lt;span class="m"&gt;5px&lt;/span&gt; &lt;span class="n"&gt;rgba&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;255&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;0.4&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.btn&lt;/span&gt;&lt;span class="nd"&gt;:active&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#333&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The result for the front of the card should look something like this: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://postimg.cc/4nWnfykZ"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--7AYC_Lcb--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.postimg.cc/pXHjB5s9/chrome-JGf-Qsmld-DA.png" alt="chrome-JGf-Qsmld-DA.png"&gt;&lt;/a&gt; &lt;/p&gt;

&lt;h2&gt;
  
  
  The Back of the Card (optional)
&lt;/h2&gt;

&lt;p&gt;Same as the previous section, I won’t explain the code below but if you have any questions feel free to comment down below and I will get back to you on that.&lt;/p&gt;

&lt;p&gt;Do keep in mind that in this case, the 3 options we have for the back of the card have the same layout. I only changed the &lt;code&gt;src&lt;/code&gt; of the image and the text of the button, but this doesn’t have to be the case. You can add an &lt;code&gt;id&lt;/code&gt; to each face of the card and have completely different card layouts for each of them. &lt;/p&gt;

&lt;p&gt;For example, I have a &lt;code&gt;#card__back__one &amp;gt; p&lt;/code&gt; selector because I have a paragraph that I needed to style on &lt;code&gt;#card__back__one&lt;/code&gt; that does not exist on &lt;code&gt;#card__back__two&lt;/code&gt; nor on &lt;code&gt;#card__back__three&lt;/code&gt;. Remember that each one is literally a completely different face so you can do with them what you want. &lt;/p&gt;

&lt;p&gt;HTML:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="c"&gt;&amp;lt;!--       Back of card__back__one if 6.62607015 --&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"card__back__one"&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"card__face card__back"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;img&lt;/span&gt; 
             &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"image__back"&lt;/span&gt; 
             &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"https://i.postimg.cc/BZpQPT4M/stranger-things-lights.jpg"&lt;/span&gt; 
             &lt;span class="na"&gt;alt=&lt;/span&gt;&lt;span class="s"&gt;"Kareen Wheeler happy"&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;You Got It!&lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"btn__back__one"&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;'btn btn__back'&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Reset&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;span class="c"&gt;&amp;lt;!--       Back of card__back__two if 6.62607004 --&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"card__back__two"&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"card__face card__back"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;img&lt;/span&gt; 
             &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"image__back"&lt;/span&gt; 
             &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"https://i.postimg.cc/hjrgxnWf/susie-constante-planck.jpg"&lt;/span&gt; 
             &lt;span class="na"&gt;alt=&lt;/span&gt;&lt;span class="s"&gt;"Susie's Planck's Constant is 6.62607004."&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"btn__back__two"&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;'btn btn__back'&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Reset&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt; 
&lt;span class="c"&gt;&amp;lt;!--       Back of card__back__three if default --&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"card__back__three"&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"card__face card__back"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;img&lt;/span&gt; 
             &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"image__back"&lt;/span&gt; 
             &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"https://i.postimg.cc/tTTkpd57/robin-stranger-things-you-suck.jpg"&lt;/span&gt; 
             &lt;span class="na"&gt;alt=&lt;/span&gt;&lt;span class="s"&gt;"Robin thinks you suck."&lt;/span&gt;&lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
        &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"btn__back__three"&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;'btn btn__back'&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Try Again&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt; 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;CSS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.image__back&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100%&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;margin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;box-shadow&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="m"&gt;1px&lt;/span&gt; &lt;span class="n"&gt;rgba&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;255&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;0.55&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nl"&gt;border-radius&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;5px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nf"&gt;#card__back__one&lt;/span&gt; &lt;span class="o"&gt;&amp;gt;&lt;/span&gt; &lt;span class="nt"&gt;p&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#111&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;text-shadow&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;-0.05rem&lt;/span&gt; &lt;span class="m"&gt;-0.05rem&lt;/span&gt; &lt;span class="m"&gt;5px&lt;/span&gt; &lt;span class="n"&gt;rgba&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;237&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;43&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;18&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;font-weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;700&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;text-align&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;margin-top&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;-50px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.btn__back&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;position&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;absolute&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;top&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;8px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;right&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;8px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;background&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;rgba&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;10&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="m"&gt;0.8&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

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



&lt;p&gt;The result for the back of the card (in this case, of &lt;code&gt;#card__back__three&lt;/code&gt;) should look something like this: &lt;/p&gt;

&lt;p&gt;&lt;a href="https://postimg.cc/ygwQcB2N"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--LxpCmTrM--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://i.postimg.cc/zvfsmGjT/chrome-WTf-ECM5ol-I.png" alt="chrome-WTf-ECM5ol-I.png"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Extra Asethetic Features
&lt;/h2&gt;

&lt;p&gt;I know there are certain things (like the &lt;em&gt;Stranger Things&lt;/em&gt; logo) that I didn’t mention in this part, but I will be adding the codepen with the whole project on Part III so you can take a look at those bits that have nothing to do with the actual action of flipping the card in the next part of this series. &lt;/p&gt;

&lt;p&gt;Remember to comment below if you have any questions or suggestions. In the next part of this series, we will be looking into the JavaScript of this project.&lt;/p&gt;

&lt;p&gt;💻 &lt;strong&gt;article.close()&lt;/strong&gt;&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://www.w3schools.com/howto/howto_css_flip_card.asp"&gt;w3schools's How To - Flip Card&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Learn/Getting_started_with_the_web/CSS_basics"&gt;CSS Basics&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.w3schools.com/cssref/css_selectors.asp"&gt;selectors&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.w3schools.com/css/css_pseudo_classes.asp"&gt;CSS pseudo class&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.w3schools.com/cssref/css3_pr_transform-style.asp"&gt;transform-style&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://css-tricks.com/almanac/properties/t/transform-origin/"&gt;transform-origin&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.w3schools.com/css/css3_transitions.asp"&gt;transition&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://css-tricks.com/almanac/properties/p/position/"&gt;position: absolute&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://pixabay.com/illustrations/stranger-things-serie-horror-tv-4337985/"&gt;Stranger Things Logo&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://postimages.org/"&gt;PostImages&lt;/a&gt;: Get permanent links for Facebook, Twitter, message boards and blogs.&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>css</category>
      <category>tutorial</category>
      <category>flipcard</category>
    </item>
  </channel>
</rss>
