<?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: Jose Arteaga</title>
    <description>The latest articles on DEV Community by Jose Arteaga (@jharteaga).</description>
    <link>https://dev.to/jharteaga</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%2F248100%2Fdd0e2ff2-0fea-4e41-ad5d-3f9468593410.jpg</url>
      <title>DEV Community: Jose Arteaga</title>
      <link>https://dev.to/jharteaga</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jharteaga"/>
    <language>en</language>
    <item>
      <title>Difference between HTMLCollection and NodeList</title>
      <dc:creator>Jose Arteaga</dc:creator>
      <pubDate>Thu, 26 Mar 2020 20:40:08 +0000</pubDate>
      <link>https://dev.to/jharteaga/difference-between-htmlcollection-and-nodelist-25bp</link>
      <guid>https://dev.to/jharteaga/difference-between-htmlcollection-and-nodelist-25bp</guid>
      <description>&lt;p&gt;These days that I have been working with javascript for DOM manipulation, I realized that I can bring a group of elements by its class name in two ways:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;code&gt;document.getElementsByClassName()&lt;/code&gt;;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;document.querySelectorAll()&lt;/code&gt;;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;However, none of them is better than another because they should be used according to the structure that we have in our HTML and our needs. &lt;strong&gt;But!&lt;/strong&gt; it's important that we have to take into consideration the output of each of them and understand how they work.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Theory&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;According to MDN documentation:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;em&gt;getElementsByClassName()&lt;/em&gt; returns a live &lt;code&gt;HTMLCollection&lt;/code&gt; representing an array-like object of all child elements which have all of the given class name(s).&lt;/li&gt;
&lt;li&gt;
&lt;em&gt;querySelectorAll()&lt;/em&gt; returns a static (not live) &lt;code&gt;NodeList&lt;/code&gt; representing a list of the document's elements that match the specified group of selectors.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;That being said, I questioned myself what the heck means a &lt;code&gt;live HTMLCollection&lt;/code&gt; and a &lt;code&gt;static NodeList&lt;/code&gt;? From there, let me explain to you in a better way this difference.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Hands-on&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Let's consider the following HTML structure:&lt;/p&gt;

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

&lt;span class="cp"&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;html&lt;/span&gt; &lt;span class="na"&gt;lang=&lt;/span&gt;&lt;span class="s"&gt;"en"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;charset=&lt;/span&gt;&lt;span class="s"&gt;"UTF-8"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"viewport"&lt;/span&gt; &lt;span class="na"&gt;content=&lt;/span&gt;&lt;span class="s"&gt;"width=device-width, initial-scale=1.0"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;title&amp;gt;&lt;/span&gt;Demo&lt;span class="nt"&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;ul&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"list"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;li&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"item"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;First Item&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;li&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"item"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Second Item&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;li&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"item"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Third Item&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/ul&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"script.js"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;


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

&lt;/div&gt;

&lt;p&gt;Now, let's get the items by their class name &lt;code&gt;item&lt;/code&gt; in the two ways mentioned above:&lt;/p&gt;

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

&lt;p&gt;We can see that both brought all the elements that I needed with the class &lt;code&gt;item&lt;/code&gt;. However, there is a big difference in the data structure they were returned.&lt;/p&gt;

&lt;p&gt;Now, let's add a new &lt;code&gt;&amp;lt;li&amp;gt;&lt;/code&gt; element to our list, and let's add some javascript code to our &lt;em&gt;script.js&lt;/em&gt; file.&lt;/p&gt;

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

&lt;span class="c1"&gt;//get UL element&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;list&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;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;list&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;//Get items by class name (two ways)&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;itemsByClassName&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;getElementsByClassName&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;item&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;itemsByQuerySelector&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="s1"&gt;.item&lt;/span&gt;&lt;span class="dl"&gt;'&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="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;First console log&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;itemsByClassName&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;itemsByQuerySelector&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;//adding the fourth element&lt;/span&gt;
&lt;span class="nx"&gt;list&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;`&amp;lt;li class="item"&amp;gt;Fourth Item&amp;lt;/li&amp;gt;`&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="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Second console log&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;itemsByClassName&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;itemsByQuerySelector&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;


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

&lt;/div&gt;

&lt;p&gt;Let's see the results!&lt;/p&gt;

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

&lt;p&gt;We can see that the new item was added to the list, though, the &lt;code&gt;HTMLCollection&lt;/code&gt; was updated with the fourth item and the &lt;code&gt;NodeList&lt;/code&gt; still has the first three elements, it didn't realize that there was a change in our list.&lt;/p&gt;

&lt;p&gt;Therefore, this is the big reason why &lt;code&gt;HTMLCollection&lt;/code&gt; is a live data structure and &lt;code&gt;NodeList&lt;/code&gt; is a static data structure. At first hand the &lt;code&gt;HTMLCollection&lt;/code&gt; updates itself automatically every time it detects a change in the items that were retrieved by the method. On the other hand, &lt;code&gt;NodeList&lt;/code&gt; will remain the same since the moment we executed it no matter the changes that occur in our HTML.&lt;/p&gt;

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

&lt;p&gt;To sum up, feel free to use them, but take into consideration this huge difference to decide which of them suits you better according to your needs.&lt;/p&gt;

&lt;p&gt;For more information, check these resources out:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/HTMLCollection" rel="noopener noreferrer"&gt;MDN Documentation: HTMLCollection&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/API/NodeList" rel="noopener noreferrer"&gt;MDN Documentation: NodeList&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Thanks for reading!&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>html</category>
      <category>beginners</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>CSS Units: REM or EM!?</title>
      <dc:creator>Jose Arteaga</dc:creator>
      <pubDate>Thu, 19 Mar 2020 04:26:19 +0000</pubDate>
      <link>https://dev.to/jharteaga/css-units-rem-or-em-2m9k</link>
      <guid>https://dev.to/jharteaga/css-units-rem-or-em-2m9k</guid>
      <description>&lt;p&gt;Are you struggling trying to understand what the heck is the difference between &lt;code&gt;rem&lt;/code&gt; and &lt;code&gt;em&lt;/code&gt; in your CSS files? Trying to guess which to use for font-sizes, margin and padding? I was in the same position, and throughout this article, I aim to help you understand each of them, their differences and my rule of thumb to apply them inside any web project.&lt;/p&gt;

&lt;p&gt;Before we start, we should be aware of what kind of units are we going deal with, and for that, let's see the following groups of CSS units available:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;CSS Length units group&lt;/th&gt;
&lt;th&gt;Units&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Absolute&lt;/td&gt;
&lt;td&gt;px, pt, cm, mm, in, Q, pc&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Relative&lt;/td&gt;
&lt;td&gt;
&lt;strong&gt;em&lt;/strong&gt;, &lt;strong&gt;rem&lt;/strong&gt;, vw, vh, vmin, vmax, ex, ch, lh&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Percentages&lt;/td&gt;
&lt;td&gt;%&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;As you may see, &lt;code&gt;rem&lt;/code&gt; and &lt;code&gt;em&lt;/code&gt; are relative units, and according to &lt;a href="https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Values_and_units" rel="noopener noreferrer"&gt;MDN documentation&lt;/a&gt;:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Relative length units are relative to something else, perhaps the size of the parent element's font, or the size of the viewport.&lt;/p&gt;
&lt;/blockquote&gt;

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

&lt;h2&gt;
  
  
  &lt;strong&gt;Theory&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;&lt;code&gt;em&lt;/code&gt; unit&lt;/strong&gt; is relative to its parent, either the root element or any container; it depends where it's defined.&lt;br&gt;
&lt;strong&gt;&lt;code&gt;rem&lt;/code&gt; unit&lt;/strong&gt; is relative &lt;strong&gt;only&lt;/strong&gt; to the root element, no matter whether or not it has a different parent than the root.&lt;/p&gt;

&lt;p&gt;The theory is important, however, let's see an example to clarify these meanings with the font-size property.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Hands-on&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Note&lt;/strong&gt;: By default, the browser font size is 16px.&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;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"em-container"&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;EM&lt;span class="nt"&gt;&amp;lt;/p&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;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"rem-container"&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;REM&lt;span class="nt"&gt;&amp;lt;/p&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;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;

&lt;span class="nc"&gt;.em-container&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
&lt;span class="nc"&gt;.rem-container&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;32px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.em-container&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;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1em&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.rem-container&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;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="p"&gt;}&lt;/span&gt;


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

&lt;/div&gt;

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

&lt;p&gt;Even though we have defined to each container a font-size of 32px, we can see different behaviours. &lt;strong&gt;&lt;code&gt;em&lt;/code&gt;&lt;/strong&gt; will always behave according to its parent, in this case, &lt;code&gt;em-container&lt;/code&gt;, and &lt;strong&gt;&lt;code&gt;rem&lt;/code&gt;&lt;/strong&gt; always according to the root. Therefore, our values for each of them are the following:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;1em&lt;/strong&gt; = parent font-size (32px)&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1rem&lt;/strong&gt; = root font-size (16px, by default)&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;Cascading EM problem in font-size&lt;/strong&gt;
&lt;/h2&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;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"em-container-1"&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;EM-1&lt;span class="nt"&gt;&amp;lt;/p&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;"em-container-2"&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;EM-2&lt;span class="nt"&gt;&amp;lt;/p&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;/div&amp;gt;&lt;/span&gt;


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

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

&lt;span class="nc"&gt;.em-container-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;32px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.em-container-2&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;64px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.em-container-1&lt;/span&gt; &lt;span class="nt"&gt;p&lt;/span&gt;&lt;span class="o"&gt;,&lt;/span&gt;
&lt;span class="nc"&gt;.em-container-2&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;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1em&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;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fsl8wxmf2ckbfduy8iyoe.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fi%2Fsl8wxmf2ckbfduy8iyoe.PNG"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Despite both &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt; elements have a font-size of &lt;code&gt;1em&lt;/code&gt;, both behave completely different, no matter both have the same font-size. In this case we have the following font-size assigned:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;.em-container-1 { font-size: 1em }&lt;/strong&gt; = parent font-size: 32px&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;.em-container-2 { font-size: 1em }&lt;/strong&gt; = parent font-size: 64px&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;If we are not aware of this cascading effect, we could have a frustrating day trying to understand why the font-size doesn't behave as we want.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;My Rule of thumb&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;Having said that, as a rule of thumb I have decided to use each of these CSS units in the following way:&lt;/p&gt;

&lt;blockquote&gt;
&lt;h3&gt;
  
  
  &lt;strong&gt;em&lt;/strong&gt; units for margin and padding properties
&lt;/h3&gt;
&lt;h3&gt;
  
  
  &lt;strong&gt;rem&lt;/strong&gt; units for font-size
&lt;/h3&gt;
&lt;/blockquote&gt;

&lt;p&gt;I really hope this post had helped you to understand this difference, however, the best way to understand it is playing with the code and check the differences of behaviours.&lt;/p&gt;

&lt;p&gt;Please let me know, according to your experience, how do you use these units.&lt;/p&gt;

&lt;p&gt;Thanks for reading!&lt;/p&gt;

</description>
      <category>css</category>
      <category>beginners</category>
      <category>webdev</category>
      <category>codenewbie</category>
    </item>
    <item>
      <title>%, px, em, rem, viewport...How to know which one to use in CSS for responsive design?</title>
      <dc:creator>Jose Arteaga</dc:creator>
      <pubDate>Mon, 25 Nov 2019 11:53:41 +0000</pubDate>
      <link>https://dev.to/jharteaga/px-em-rem-viewport-how-to-know-which-one-to-use-in-css-for-responsive-design-4jbi</link>
      <guid>https://dev.to/jharteaga/px-em-rem-viewport-how-to-know-which-one-to-use-in-css-for-responsive-design-4jbi</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcl4u-web.s3.amazonaws.com%2Fcache%2Fpress_release_image%2Fsigns-of-confusion-562a42fd4e38d.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fcl4u-web.s3.amazonaws.com%2Fcache%2Fpress_release_image%2Fsigns-of-confusion-562a42fd4e38d.jpeg" alt="Drag Racing"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;I've been working on the FreeCodeCamp Responsive Design projects, and there has been one thing that I've struggled a lot designing responsive websites, and it's understanding whether I have to use pixels, EM, REM, percentages, Viewport, etc. for font sizes, images, containers, and media queries.&lt;/p&gt;

&lt;p&gt;Do you have any recommendations on how to get a better understanding of it and overcome it?&lt;/p&gt;

&lt;p&gt;I'd appreciate your help!&lt;/p&gt;

&lt;p&gt;Thanks!&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>beginners</category>
      <category>webdev</category>
      <category>css</category>
    </item>
    <item>
      <title>Traditional Functions or Arrow Functions in Javascript?</title>
      <dc:creator>Jose Arteaga</dc:creator>
      <pubDate>Wed, 30 Oct 2019 18:41:14 +0000</pubDate>
      <link>https://dev.to/jharteaga/traditional-functions-or-arrow-functions-in-javascript-303n</link>
      <guid>https://dev.to/jharteaga/traditional-functions-or-arrow-functions-in-javascript-303n</guid>
      <description>&lt;p&gt;Recently, I started my Web Dev journey, and these days I have been reading about functions in Javascript. I've noticed that there are many ways to declare a function. Two of them caught my attention though, which are &lt;strong&gt;Traditional Functions&lt;/strong&gt; and &lt;strong&gt;Arrow Functions&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;I have read about them and in my understanding, I have to take into consideration the following:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Traditional Functions&lt;/th&gt;
&lt;th&gt;Arrow Functions&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;No matter where you declare&lt;br&gt;and call the function,&lt;br&gt;Hoisting is the key.&lt;/td&gt;
&lt;td&gt;The order matters. Declare it&lt;br&gt;into a variable and then call it.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Once you declare it,&lt;br&gt;you won't lose it.&lt;/td&gt;
&lt;td&gt;The code seems cleaner than a&lt;br&gt; traditional declaration.&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;/td&gt;
&lt;td&gt;Once you override the variable&lt;br&gt; where the function lives, it's over.&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;So, I would like to put on the table this topic in order to clarify my mind a little bit more about it, and comprehend the best use case for each of them.&lt;/p&gt;

&lt;p&gt;Which one do you usually use when you code functions in Javascript?&lt;/p&gt;

</description>
      <category>discuss</category>
      <category>beginners</category>
      <category>javascript</category>
      <category>webdev</category>
    </item>
  </channel>
</rss>
