<?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: Prashant Andani</title>
    <description>The latest articles on DEV Community by Prashant Andani (@prashantandani).</description>
    <link>https://dev.to/prashantandani</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%2F151439%2Fb3b503c6-cb4e-4833-a764-bf14dee2c42c.png</url>
      <title>DEV Community: Prashant Andani</title>
      <link>https://dev.to/prashantandani</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/prashantandani"/>
    <language>en</language>
    <item>
      <title>Difference between npm install and npm ci</title>
      <dc:creator>Prashant Andani</dc:creator>
      <pubDate>Fri, 15 May 2020 06:20:11 +0000</pubDate>
      <link>https://dev.to/prashantandani/difference-between-npm-install-and-npm-ci-62p</link>
      <guid>https://dev.to/prashantandani/difference-between-npm-install-and-npm-ci-62p</guid>
      <description>&lt;p&gt;The main differences between using &lt;em&gt;npm install&lt;/em&gt; and &lt;em&gt;npm ci&lt;/em&gt; are:&lt;/p&gt;

&lt;p&gt;The project must have an existing package-lock.json or npm-shrinkwrap.json.&lt;/p&gt;

&lt;p&gt;If dependencies in the package-lock do not match those in package.json, npm ci will exit with an error, instead of updating the package-lock.&lt;br&gt;
npm ci can only install entire projects at a time: individual dependencies cannot be added with this command.&lt;/p&gt;

&lt;p&gt;If a node_modules is already present, it will be automatically removed before npm ci begins its install.&lt;/p&gt;

&lt;p&gt;It will never write to package.json or any of the package-locks: installs are essentially frozen.&lt;/p&gt;

</description>
      <category>npm</category>
      <category>javascript</category>
    </item>
    <item>
      <title>How many of you received Hacktoberfest T-shirt?</title>
      <dc:creator>Prashant Andani</dc:creator>
      <pubDate>Sat, 30 Nov 2019 06:07:36 +0000</pubDate>
      <link>https://dev.to/prashantandani/how-many-of-you-received-hacktoberfest-t-shirt-2f2n</link>
      <guid>https://dev.to/prashantandani/how-many-of-you-received-hacktoberfest-t-shirt-2f2n</guid>
      <description>&lt;p&gt;How many of you received Hacktoberfest Swag? Send Pics and be proud of your contributions to the open-source community.&lt;br&gt;
:)&lt;/p&gt;

</description>
      <category>hactoberfest</category>
      <category>digitalocean</category>
      <category>opensource</category>
    </item>
    <item>
      <title>Function currying for the dynamic length of params i.e Implementing Add(1)(2)(3).....(n)()</title>
      <dc:creator>Prashant Andani</dc:creator>
      <pubDate>Tue, 08 Oct 2019 15:01:46 +0000</pubDate>
      <link>https://dev.to/prashantandani/function-currying-for-the-dynamic-length-of-params-i-e-implementing-add-1-2-3-n-423n</link>
      <guid>https://dev.to/prashantandani/function-currying-for-the-dynamic-length-of-params-i-e-implementing-add-1-2-3-n-423n</guid>
      <description>&lt;p&gt;Currying refers to the process of transforming a function with multiple arities into the same function with less arity. The curried effect is achieved by binding some of the arguments to the first function to invoke so that those values are fixed for the next invocation. Here’s an example of what a curried function looks like:&lt;/p&gt;

&lt;p&gt;// add(2)(3); &lt;/p&gt;

&lt;p&gt;and the function definition is&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;function add(a) {
  return function(b) {
    return a + b;
  }
}
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;The above solution works for the currying for a function with two params&lt;/p&gt;

&lt;p&gt;How would we achieve if there are more dynamic no. of params&lt;/p&gt;

&lt;p&gt;i.e add(2)(3)(4)(5)....(n)()&lt;/p&gt;

&lt;p&gt;Let's write a generic &lt;code&gt;add&lt;/code&gt; function that takes &lt;code&gt;n&lt;/code&gt; no. of params.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;  function add(a) {
   return function(b) {
      return b ? add(a + b) : a;
   }
  }
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;😇 One-liner solution with an ES6 arrow function&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const add = a =&amp;gt; b =&amp;gt; b ? add(a + b) : a; 
&lt;/code&gt;&lt;/pre&gt;&lt;/div&gt;



&lt;p&gt;🙌 🙌🏻 🙌🏼 🙌🏽 🙌🏾 🙌🏿&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
    </item>
    <item>
      <title>Implementation of ES6 Map() function</title>
      <dc:creator>Prashant Andani</dc:creator>
      <pubDate>Tue, 08 Oct 2019 09:57:43 +0000</pubDate>
      <link>https://dev.to/prashantandani/implementation-of-es6-map-function-1kdo</link>
      <guid>https://dev.to/prashantandani/implementation-of-es6-map-function-1kdo</guid>
      <description>&lt;div class="highlight"&gt;&lt;pre class="highlight plaintext"&gt;&lt;code&gt;//implementing map function

/* Implemetation */
const arrayMap = (arr, fn) =&amp;gt; {
  const arrTemp = [];
  for (var i = 0; i &amp;lt; arr.length; i++) {
    arrTemp.push(fn(arr[i], i));
  }
  return arrTemp;
};

/* Usage */
// const arr = [1,2, 3];
// const iterator = each =&amp;gt; each + 1;
const result = arrayMap(arr, iterator);
//console.log(result);

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



</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>es6</category>
    </item>
    <item>
      <title>Frontend Architecture Decision making and checklist</title>
      <dc:creator>Prashant Andani</dc:creator>
      <pubDate>Tue, 01 Oct 2019 09:18:19 +0000</pubDate>
      <link>https://dev.to/prashantandani/frontend-architecture-decision-making-and-checklist-3n7a</link>
      <guid>https://dev.to/prashantandani/frontend-architecture-decision-making-and-checklist-3n7a</guid>
      <description>&lt;p&gt;Before getting started with the Architecture planning for a Front end development of a project. Things to be sure and Architect the code base accordingly&lt;br&gt;
Here is the checklist to worth looking in to.&lt;/p&gt;

&lt;p&gt;** This is the first set of thoughts **&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Responsiveness&lt;/strong&gt; (Web, Mobile etc)
 Multi-Browser support (chrome, firefox, safari with versions)
 Is IE Support required?

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Feature flagging&lt;/strong&gt; (A/B testing of a set of features for user groups based on location etc before releasing to all)
&lt;a href="https://dzone.com/articles/feature-flag-driven-development"&gt;https://dzone.com/articles/feature-flag-driven-development&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Role-based access&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;SEO&lt;/strong&gt; - Server-side rendering&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;PWA&lt;/strong&gt; - Mobile Web (Offline first, Network first) &lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Realtime data sync&lt;/strong&gt; - Is realtime data syncing is required, in that case, we can think of Web socket or any other approach.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Security&lt;/strong&gt; - What are the security measures to be considered&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Internationalization&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Accessibility&lt;/strong&gt; - 
 Accessibility is the practice of making your websites usable by as many people as possible.
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Performance first&lt;/strong&gt; - 
&lt;a href="https://medium.com/yld-blog/performance-driven-development-c7fc030cc060"&gt;https://medium.com/yld-blog/performance-driven-development-c7fc030cc060&lt;/a&gt;
&lt;/li&gt;
&lt;/ol&gt;


&lt;/li&gt;
&lt;/ol&gt;

</description>
    </item>
    <item>
      <title>PWA vs React Native (Decision on choosing over one another)</title>
      <dc:creator>Prashant Andani</dc:creator>
      <pubDate>Thu, 19 Sep 2019 06:35:24 +0000</pubDate>
      <link>https://dev.to/prashantandani/pwa-vs-react-native-decision-on-choosing-over-one-another-352o</link>
      <guid>https://dev.to/prashantandani/pwa-vs-react-native-decision-on-choosing-over-one-another-352o</guid>
      <description>&lt;p&gt;&lt;strong&gt;&lt;em&gt;PWA vs React Native&lt;/em&gt;&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Whenever building cross-platform apps, two things come to a mind, PWA or React Native. As these are the hottest technologies out there(You are free to consider others).&lt;/p&gt;

&lt;p&gt;If you are an app developer today, which one should you prioritize and build for?&lt;/p&gt;

&lt;p&gt;What decisions go into choosing one over the other?&lt;/p&gt;

&lt;p&gt;The below points help in making the right decision on which one to choose or suits best for your needs.&lt;br&gt;
Wait!!!&lt;/p&gt;

&lt;p&gt;If Cost and Time aren't your problems, you should build both a PWA and a React Native solution and design the architecture of your app in a way to re-use as much logic between the PWA, React Native-Android, and React &lt;br&gt;
Native-iOS projects as possible.&lt;/p&gt;

&lt;p&gt;The PWA gets you the widest reach where any device with a browser can view your app.&lt;/p&gt;

&lt;p&gt;The React Native app gets you richness/depth where you get to take advantage of a device's native UI controls for maximum performance and familiarity for users.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Here are some thoughts.&lt;/strong&gt;&lt;br&gt;
Are you going mobile-first or everywhere first?&lt;br&gt;
If your goal is to target mobile devices (Android and iOS) only via the app store, then go with React Native.&lt;br&gt;
If you want to reach the widest range of users and devices via the browser, go with a PWA.&lt;/p&gt;

&lt;p&gt;If you want the lowest-cost option for your development team, then a PWA wins.&lt;br&gt;
You write your app once using HTML, CSS, and JS and it will run pretty much everywhere a browser is available. If a browser isn't available (think smartwatches and so on), you can always build a hybrid app using a WebView that wraps your PWA and gets it on those tiny little screens:&lt;br&gt;
To make your PWA work well across all of these devices, you do need to ensure your app is responsive/adaptive and relies on progressive enhancement. Knowing the range of devices you'll need to support upfront is key.&lt;/p&gt;

&lt;p&gt;If you want the best UI responsiveness and performance, go React Native.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;React Native&lt;/em&gt; uses the iOS and Android native UI controls, so you get to use the platform controls users are familiar with along with the snappy performance a non-HTML UI layer provides.&lt;/p&gt;

&lt;p&gt;With a &lt;em&gt;PWA&lt;/em&gt;, the interactions are always going to be a bit clunky - the animations will be less rich, multi-touch will be less responsive, the lack of multithreading will always keep your interactions fighting for priority with other things your app is doing, and so on.&lt;/p&gt;

&lt;p&gt;If you care about low-end devices, PWA is slightly better than React Native.&lt;br&gt;
While the UI layer in React Native is made up of platform controls, the underlying data communication is all JavaScript.&lt;br&gt;
If you have an app that deals extensively with data, the slow JS throughput on lower-end Android devices is a very noticeable bottleneck that often makes the UI feel clunky.&lt;/p&gt;

&lt;p&gt;React Native creates a native app package (~usually tens of megabytes in size!) that needs to be installed prior to the user seeing even a single pixel from your app.&lt;/p&gt;

&lt;p&gt;PWAs load in the browser immediately.&lt;/p&gt;

&lt;p&gt;This may be less of a problem in areas where you have plenty of cheap/fast bandwidth and device storage. If you are targeting large parts of the world where bandwidth and storage are problems, then a PWA is better. Installing an app from the app store is a major commitment, so giving users a lite version that is an instantly-available PWA and a richer version that is a React Native-based app (installed via the app store) is the best approach.&lt;/p&gt;

&lt;p&gt;I do realize this suggestion falls under the magical world where there are no time and resource constraints and you can build multiple versions of your app, but sometimes that is the best solution. This is what Twitter did!&lt;/p&gt;

&lt;p&gt;&lt;em&gt;What are you (or your development team) skilled in?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;There is always a nontrivial cost to learn new technology and train others on it. Both PWAs and React Native have their steep learning curves when you want to create a great user experience (especially at the critical last-mile), so keep this detail in mind as a factor.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Is your app consumer-focused or enterprise-focused?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Consumer apps tend to need a high degree of visual polish, and that tends to favor React Native because you get to work with native UI controls. &lt;/p&gt;

&lt;p&gt;Enterprise apps should be visually awesome as well, but that is often not a differentiator since most enterprise apps can't be substituted for something similar. A good PWA with (optionally) good offline capabilities could meet most enterprise requirements.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Do you need access to native device APIs?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;PWAs are limited by the browser sandbox, so you can't go beyond what the Web APIs provide access to. If all you need is a webcam/camera, microphone, geolocation, etc., then you are good. If you need deeper access to customized hardware and sensors, richer Bluetooth support, and so on, React Native allows you to access the native hardware. You could take the Hybrid App approach using a WebView and fully extend your PWA with the code for accessing native device capabilities, but that will require you to still build a native app (even if Apache Cordova or Ionic make that a breeze) and go through the app stores.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Desktop or Mobile or both?&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;If you only care about the desktop, then React Native won't help. I do realize there are desktop ports of React Native available, but most aren't officially maintained by the React team and have various gaps that you will need to address yourself. A PWA will run well on desktops, but if you need more native access to lower-level APIs, the browser security sandbox will block you from getting that access unless you decide to rely on a WebView inside a native app (similar to Electron).&lt;/p&gt;

</description>
      <category>pwa</category>
      <category>reactnative</category>
      <category>webdev</category>
      <category>javascript</category>
    </item>
    <item>
      <title>SCSS Mixins for responsive design, utility classes</title>
      <dc:creator>Prashant Andani</dc:creator>
      <pubDate>Thu, 19 Sep 2019 05:58:17 +0000</pubDate>
      <link>https://dev.to/prashantandani/scss-mixins-for-responsive-design-utility-classes-534e</link>
      <guid>https://dev.to/prashantandani/scss-mixins-for-responsive-design-utility-classes-534e</guid>
      <description>&lt;p&gt;&lt;strong&gt;Problem:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;When I start any new web application, I worry about responsive design. How am I going to handle the different view for different screen sizes? Always used to desire of having bootstrap kind of row/column spacing without having bootstrap.&lt;br&gt;
Always wanted to also have utility classes for spacing (paddings, margins).&lt;/p&gt;

&lt;p&gt;Easily rememberable class names which could make my problems disappear.&lt;br&gt;
SCSS Mixins for responsive design, utility classes above specified problems must have been faced by almost all the web application developers. If you’re using some CSS framework, they provide you different solutions for these. But, assuming you have SCSS mixins which generate you those classes and solves your problem in around 50 lines of CSS code instead of importing a complete framework (eg. Bootstrap).&lt;/p&gt;

&lt;p&gt;Don’t worry, I have a solution to your worries. If you’re not using SCSS, then convert SCSS code to CSS using online converters.&lt;/p&gt;

&lt;p&gt;Please import this file&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/malothnaresh/css-utilities/blob/master/common.scss"&gt;https://github.com/malothnaresh/css-utilities/blob/master/common.scss&lt;/a&gt;&lt;br&gt;
Usage:&lt;/p&gt;

&lt;p&gt;Spacing utility classes:&lt;/p&gt;

&lt;p&gt;The first mixing in this file creates most of the required spacing utility classes. The unit used is &lt;code&gt;rem&lt;/code&gt;. And every count you specified is &lt;code&gt;0.25rem * #{count}&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Eg:&lt;/p&gt;

&lt;p&gt;p-0: Padding &lt;code&gt;0rem&lt;/code&gt; to all sides;&lt;br&gt;
m-0: Margin &lt;code&gt;0rem&lt;/code&gt; to all sides;&lt;br&gt;
p-1: Padding &lt;code&gt;0.25rem&lt;/code&gt; to all sides;&lt;br&gt;
m-2: Margin &lt;code&gt;0.50rem&lt;/code&gt; to all sides;&lt;br&gt;
p-3: Padding &lt;code&gt;0.75rem&lt;/code&gt; to all sides;&lt;br&gt;
m-4: Margin &lt;code&gt;1rem&lt;/code&gt; to all sides;&lt;br&gt;
pl-5: PaddingLeft 1.25rem;&lt;br&gt;
mr-6: MarginRight 1.50rem;&lt;br&gt;
pt-7: PaddingTop 1.75rem;&lt;br&gt;
mb-8: MarginBottom 2rem;&lt;br&gt;
All class names are:&lt;/p&gt;

&lt;p&gt;Padding all sides: [p-0, p-1, …p–20]&lt;br&gt;
Margin all sides: [m-0, m-1, …m-20]&lt;br&gt;
Padding Left: [pl-0, pl-1, …pl-20]&lt;br&gt;
Padding Right: [pr-0, pr-1, …pr–20]&lt;br&gt;
Padding Top: [pt-0, pt-1, …pt–20]&lt;br&gt;
Padding Bottom [pb-0, pb-1, …pb–20]&lt;br&gt;
Margin Left: [ml-0, ml-1, …ml–20]&lt;br&gt;
Margin Right: [mr-0, mr-1, …mr–20]&lt;br&gt;
Margin Top: [mt-0, mt-1, …mt–20]&lt;br&gt;
Margin Bottom: [mb-0, mb-1, …mb–20].&lt;br&gt;
Row / Columns Divider:&lt;/p&gt;

&lt;p&gt;The second mixin in this file gives you a row divided into 12 columns (Bootstrap’s style of row/column design pattern). Every row is “display: flex” with 12 columns (flexes).&lt;/p&gt;

&lt;p&gt;Eg:&lt;/p&gt;

&lt;p&gt;This content would be 3 columns on large screens, 6 columns on medium screen, 12 columns on small and extremely small screen&lt;/p&gt;

&lt;p&gt;All class names according to screen sizes:&lt;/p&gt;

&lt;p&gt;Extremely small screens (max-width: 480px):&lt;/p&gt;

&lt;p&gt;col-xs-1, col-xs-2, col-xs-3, col-xs-4, col-xs-5, col-xs-6, col-xs-7, col-xs-8, col-xs-9, col-xs-10, col-xs-11, col-xs-12.&lt;/p&gt;

&lt;p&gt;Small screens (max-width: 768px):&lt;/p&gt;

&lt;p&gt;col-sm-1, col-sm-2, col-sm-3, col-sm-4, col-sm-5, col-sm-6, col-sm-7, col-sm-8, col-sm-9, col-sm-10, col-sm-11, col-sm-12.&lt;/p&gt;

&lt;p&gt;Medium screens (max-width: 1125px):&lt;/p&gt;

&lt;p&gt;col-md-1, col-md-2, col-md-3, col-md-4, col-md-5, col-md-6, col-md-7, col-md-8, col-md-9, col-md-10, col-md-11, col-md-12.&lt;/p&gt;

&lt;p&gt;Large screens (Desktop / Monitor screens):&lt;/p&gt;

&lt;p&gt;col-lg-1, col-lg-2, col-lg-3, col-lg-4, col-lg-5, col-lg-6, col-lg-7, col-lg-8, col-lg-9, col-lg-10, col-lg-11, col-lg-12.&lt;/p&gt;

&lt;p&gt;Hope this bootstraps your styling…&lt;/p&gt;

&lt;p&gt;Medium Doc Link: &lt;a href="https://medium.com/@cryptoipl/scss-mixins-for-responsive-design-utilities-classes-4194a25e7a99"&gt;https://medium.com/@cryptoipl/scss-mixins-for-responsive-design-utilities-classes-4194a25e7a99&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Contribution by: Maloth Naresh&lt;/p&gt;

</description>
      <category>scss</category>
      <category>css</category>
      <category>responsivedesign</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Quick guide to CSS Units (px, em, rem)</title>
      <dc:creator>Prashant Andani</dc:creator>
      <pubDate>Wed, 18 Sep 2019 09:45:33 +0000</pubDate>
      <link>https://dev.to/prashantandani/quick-guide-to-css-units-px-em-rem-4lic</link>
      <guid>https://dev.to/prashantandani/quick-guide-to-css-units-px-em-rem-4lic</guid>
      <description>&lt;p&gt;Here are some commonly used CSS Units with the pros and cons of each of them.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PIXEL(px):&lt;/strong&gt;&lt;br&gt;
Pixels are fixed in size. 1px = 1 dot on a computer screen. It is an absolute unit of measure&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Pros:&lt;/em&gt;&lt;br&gt;
Pixels are preferred when we want to develop pixel-perfect web applications (Non-responsive in nature)&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Cons:&lt;/em&gt;&lt;br&gt;
Pixels cannot be used to build a responsive website. If we need to build a responsive website, then excessive use of media queries would have to be used in order to achieve a responsive design which might become cumbersome. This approach will also lend towards missing few viewports.&lt;/p&gt;

&lt;p&gt;When to use?&lt;br&gt;
Pixels come in handy especially when we have fixed divs, like the height of a header or footer remains the same irrespective of the viewport.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;POINT(pt):&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Points are usually used for things to be printed on paper ie for print media.&lt;br&gt;
Same as a pixel.&lt;br&gt;
Fixed measure and not scalable.   &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;EM:&lt;/strong&gt;&lt;br&gt;
EM is always equal to the current font-size. It is scalable in nature.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Pros:&lt;/em&gt;&lt;br&gt;
Since it is scalable, can build responsive websites.&lt;br&gt;
If font-size is equal to 16px, then 1em = 16px, 0.5em = 8px and 2em = 32px.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Cons:&lt;/em&gt;&lt;br&gt;
 Em causes an issue when we have nested elements. &lt;/p&gt;

&lt;p&gt;Let us have a root at 100% that is 16px. Let there be a child who should have 12px, so we specify the value as 0.75em. Now if we have another child inside this, it will get a font size of 0.75em of 12px, that is 9px. To avoid this, we need to again specify it&lt;/p&gt;

&lt;p&gt;&lt;code&gt;html {&lt;br&gt;
                 font-size: 100%;&lt;br&gt;
             }&lt;br&gt;
             ul {&lt;br&gt;
                 font-size: 0.75em;&lt;br&gt;
             }&lt;br&gt;
             ul ul {&lt;br&gt;
                 font-size: 1em;&lt;br&gt;
             }&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;We need to pay a lot of attention when nesting of elements take place.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;PERCENT(%):&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Percent unit is similar to em.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Pros:&lt;/em&gt;&lt;br&gt;
As the name suggests, percent of something. If nothing specified, it will take % of the browser's width or height.&lt;br&gt;
Useful for building Fluid Layout.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Cons:&lt;/em&gt;&lt;br&gt;
 If the child elements are fixed width, and if a parent is in %, it can result in unexpected layout. Need to be careful with nested elements.&lt;br&gt;
NOTE: When base size increases, % and em automatically increases but pixel and pt remain the same.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;REM:&lt;/strong&gt;&lt;br&gt;
Stands for Root EM. REM is relative only to the root size whereas em is relative to its nearest parent.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Pros:&lt;/em&gt;&lt;br&gt;
Rem always takes the root size into consideration irrespective of the nesting of elements.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Cons:&lt;/em&gt;&lt;br&gt;
Browser default size for Rem is 16px. Hence it becomes difficult to remember the rem values. &lt;/p&gt;

&lt;p&gt;&lt;code&gt;10px = 0.625rem&lt;br&gt;
          12px = 0.75rem&lt;br&gt;
          14px = 0.875rem&lt;br&gt;
          16px = 1rem (base)&lt;br&gt;
          18px = 1.125rem&lt;br&gt;
          20px = 1.25rem&lt;br&gt;
          24px = 1.5rem&lt;br&gt;
          30px = 1.875rem&lt;br&gt;
          32px = 2rem&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;2.Partial support in IE 10.&lt;/p&gt;

&lt;p&gt;VW, VH:&lt;/p&gt;

&lt;p&gt;These units are viewport width and viewport height respectively. 1vw =  1/100 th  of the viewport width and &lt;br&gt;
1vh = 1/100 of viewport height.&lt;br&gt;
It is a relative measure.&lt;/p&gt;

&lt;p&gt;NOTE: There major difference between % and vh/vw is that VW unit determines its size based on the width of the viewport. Browsers calculate the viewport size as the browser window, which includes the space for the scrollbar whereas in %, it's only the width of the html element.&lt;br&gt;
If we set 100vw, then it will include the html element+body+scrollbar width. &lt;/p&gt;

&lt;p&gt;For heights, if we use %, it can cause an issue as the size in % of an element is determined by its parent height. We can have an element fill the entire screen only if its parent also fills the entire height of the screen. &lt;br&gt;
But,&lt;br&gt;
 .test {&lt;br&gt;
    height: 100vh;&lt;br&gt;
}&lt;/p&gt;

&lt;p&gt;Here, no matter how the element is nested, it will be relative to the viewport dimensions. The problem of scrollbar won't be an issue since most webpages don't have a horizontal scroll.&lt;br&gt;
Hence, when dealing with widths, the % unit is more suitable. With heights, the vh unit is better.&lt;/p&gt;

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