<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>Forem: Vinod Godti </title>
    <description>The latest articles on Forem by Vinod Godti  (@gvinod1991).</description>
    <link>https://forem.com/gvinod1991</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%2F156360%2Fc4a8bfd7-2f24-4f20-850a-af02923a226b.jpg</url>
      <title>Forem: Vinod Godti </title>
      <link>https://forem.com/gvinod1991</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/gvinod1991"/>
    <language>en</language>
    <item>
      <title>API calls using fetch in javascript</title>
      <dc:creator>Vinod Godti </dc:creator>
      <pubDate>Mon, 23 Dec 2019 20:24:09 +0000</pubDate>
      <link>https://forem.com/gvinod1991/api-calls-using-fetch-in-javascript-26ik</link>
      <guid>https://forem.com/gvinod1991/api-calls-using-fetch-in-javascript-26ik</guid>
      <description>&lt;p&gt;Nowadays almost all web applications are API based which means backend for the application will be written in API(Application programming interface). So that backend application can be used across all platforms such as browsers, mobile, and desktop.The API integration is the most important thing to learn in modern web application development.&lt;/p&gt;

&lt;p&gt;Today we will learn how to make API calls by using fetch in javascript&lt;/p&gt;

&lt;p&gt;Before going to details , Let's have some idea of the API. Basically API has four methods(commonly used) those are GET, POST, PUT and DELETE. With these four methods get, create, update or delete functionality can be implemented.&lt;/p&gt;

&lt;p&gt;GET means to get some data from the server or any other source&lt;br&gt;
POST means Posting some data to the server to create some record&lt;br&gt;
PUT means posting some data to update the existing record&lt;br&gt;
DELETE means send a delete request to the server to delete some data in server&lt;/p&gt;

&lt;p&gt;let's jump into our main topic&lt;/p&gt;

&lt;p&gt;fetch is basically a module that is a builtin feature of javascript used to call the API endpoints of the server and get the response.&lt;/p&gt;

&lt;p&gt;Basic syntax&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fetch('server url')
    .then(res =&amp;gt; 
        console.log(res)
    );
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  GET Request Fetch
&lt;/h2&gt;

&lt;p&gt;I found an online tool to make fake API calls and check how "fetch" works.&lt;br&gt;
The tool is &lt;a href="https://jsonplaceholder.typicode.com.Just"&gt;https://jsonplaceholder.typicode.com.Just&lt;/a&gt; we have to pass the URL in fetch API as shown in the below URL.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fetch('https://jsonplaceholder.typicode.com/todos/1')
.then(response =&amp;gt; response.json())
.then(json =&amp;gt; console.log(json))//Make response into json format

Output
 {
    "userId": 1,
    "id": 1,
    "title": "delectus aut autem",
    "completed": false
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  POST Request Fetch
&lt;/h2&gt;

&lt;p&gt;We can make a POST request to the server using the fetch using the following syntax.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    fetch('https://jsonplaceholder.typicode.com/posts', {
    method: 'POST',
    body: JSON.stringify({
        title: 'foo',
        body: 'bar',
        userId: 1
    }),
    headers: {
        "Content-type": "application/json; charset=UTF-8"
    }
    })
    .then(response =&amp;gt; response.json())
    .then(json =&amp;gt; console.log(json))

Output/Response 

    {
        id: 101,
        title: 'foo',
        body: 'bar',
        userId: 1
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;In the above request,we can send any data object in the stringified format in the body of the request. In the backend, this data can be accessed for processing or saving into the database. Here as we send the data in JSON format so we are making header content-type as application/json.There are other content-type such application/xml,text/html or  multipart/form-data.&lt;/p&gt;

&lt;h2&gt;
  
  
  PUT Request Fetch
&lt;/h2&gt;

&lt;p&gt;To update some data to server/resource, We can use this method.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    fetch('https://jsonplaceholder.typicode.com/posts/1', {
    method: 'PUT',
    body: JSON.stringify({
        id: 1,
        title: 'foo',
        body: 'bar',
        userId: 1
    }),
    headers: {
        "Content-type": "application/json; charset=UTF-8"
    }
    })
    .then(response =&amp;gt; response.json())
    .then(json =&amp;gt; console.log(json))

    Output 
    {
        id: 1,
        title: 'foo',
        body: 'bar',
        userId: 1
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  DELETE Request Fetch
&lt;/h2&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;To delete some data in the server/resource, we can use this method.

    fetch('https://jsonplaceholder.typicode.com/posts/1', {
        method: 'DELETE'
    })
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Important: the resource will not be really deleted on the server but it will be faked as if.&lt;/p&gt;

&lt;p&gt;To understand the API calls, first, you have to understand,How API can be written in backend and how it executed. We will cover this topic in next blog.&lt;/p&gt;

</description>
      <category>fetch</category>
      <category>api</category>
      <category>frontend</category>
    </item>
    <item>
      <title>CSS clip-path property and it's advantages</title>
      <dc:creator>Vinod Godti </dc:creator>
      <pubDate>Thu, 31 Oct 2019 18:18:49 +0000</pubDate>
      <link>https://forem.com/gvinod1991/css-clip-path-property-and-it-s-advantages-ifh</link>
      <guid>https://forem.com/gvinod1991/css-clip-path-property-and-it-s-advantages-ifh</guid>
      <description>&lt;p&gt;CSS clip-path property is very useful when designing the landing pages and the latest web page design.clip-path to show some portion of the image or shape instead of showing the entire shape or image.&lt;/p&gt;

&lt;p&gt;let's dive into details&lt;/p&gt;

&lt;h2&gt;
  
  
  Basic Shapes
&lt;/h2&gt;

&lt;p&gt;clip-path has basic-shape values such as circle, ellipse, polygon or inset to make some basic shapes circle, ellipse, polygon or rectangle respectively.&lt;br&gt;
clip-path property works only when there should be basic shape or image. On top of the basic shape or image, we can clip some path out to create many new shapes.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.circle{
    width:100px;
    height:100px;
    background:#AD2F11;
    clip-path:circle(50%)
}

.ellipse{
    ....
clip-path:ellipse(25% 40% at 50% 50%) 
}
.triangle {
    ....
    clip-path:polygon(50% 0%, 0% 100%, 100% 100%);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  Advance shapes
&lt;/h2&gt;

&lt;p&gt;Now let's take one more step ahead to make trapezoid shape using clip-path&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.trapezoid{
    ...
    clip-path:polygon(20% 0%, 80% 0%, 100% 100%, 0% 100%);
}

.pentagon{
    ...
    clip-path:polygon(50% 0%, 100% 38%, 82% 100%, 18% 100%, 0% 38%);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;For some old version browsers, we should use a vendor-specific prefix on clip-path such as -webkit-,-moz,-o- for Chrome, Mozilla and opera respectively.&lt;/p&gt;

&lt;p&gt;Circle clip-path syntax can be defined also like this &lt;/p&gt;

&lt;p&gt;clip-path: circle(radius at posX posY)&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.circle-advanced{
    clip-path:circle(50% at 70% 20%)
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;Ellipse also be defined as &lt;/p&gt;

&lt;p&gt;clip-path: ellipse(radiusX radiusY at posX posY)&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.ellipse-advanced{

    clip-path:ellipse(50% 65% at 70% 50%);
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;Find the codepen below to play with the above examples&lt;/p&gt;

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

&lt;p&gt;To explore more advanced CSS clip-path, visit the below URL.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://bennettfeely.com/clippy/"&gt;clipy&lt;/a&gt; &lt;/p&gt;

</description>
      <category>css</category>
      <category>clippath</category>
      <category>landingpages</category>
    </item>
    <item>
      <title>Complex shapes and layout design in CSS </title>
      <dc:creator>Vinod Godti </dc:creator>
      <pubDate>Fri, 25 Oct 2019 18:02:15 +0000</pubDate>
      <link>https://forem.com/gvinod1991/complex-shapes-and-layout-design-in-css-1i2j</link>
      <guid>https://forem.com/gvinod1991/complex-shapes-and-layout-design-in-css-1i2j</guid>
      <description>&lt;p&gt;Some shapes or layout design in CSS is a little bit tricky to design in CSS code. using border-radius we can create many different shapes.CSS clip-path property will make complex shapes CSS design a lot easier to write code.&lt;/p&gt;

&lt;h2&gt;
  
  
  using the border-radius property
&lt;/h2&gt;

&lt;p&gt;I will start with simple shapes and go to complex shapes&lt;/p&gt;

&lt;p&gt;let's create the rounded corner rectangle &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!-- Rectangle with single border radius--&amp;gt;
&amp;lt;div class="rectangle"&amp;gt;

&amp;lt;/div&amp;gt;

.rectangle{
    background:#3380FF;
    width: 20rem;
    height: 20rem;
    border-radius:25px;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;In the above CSS code border-radius property applied and rounded corner rectangle formed.&lt;/p&gt;

&lt;p&gt;Let's change border-radius property value 2 different values&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.rectangle{
    ....
    border-radius:25px 10px;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;first value in the border-radius is for top left and bottom right corner.&lt;br&gt;
second value is for top right and bottom left corner.Thus we can have different rounded corner.&lt;/p&gt;

&lt;p&gt;border-radius property can also have 4 values.Each value for each corner.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.rectangle{
    ....
    border-radius:10px 20px 30px 40px;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;first in the border-radius is for top left and 2nd is top right,3rd value is for bottom right and finally 4th one is bottom left value.&lt;/p&gt;

&lt;p&gt;There is another way of providing the value of the border-radius property which is eight different value with "/" with 1 to 4 value on each side of the slash&lt;/p&gt;

&lt;p&gt;let's look into the CSS code&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    border-radius:[top-left horizontal radius] [top-right horizontal radius] [bottom-right horizontal radius] [bottom-left horizontal radius] / [top-left vertical radius] [top-right vertical radius] [bottom-right vertical radius] [bottom-left vertical radius]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;As mentioned in the above code before the slash are for horizontal border-radius and after the slash are for vertical border-radius&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.rectangle{
    border-radius:10px 20px 30px 40px/ 40px 30px 20px 10px;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;p&gt;All the values of the border-radius can be provided as percentage or em. If I write border-radius as 50% with square it will be converted to circle which is the beauty of the border-radius property.&lt;/p&gt;

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

&lt;p&gt;Recently I found an amazing tool to create asymmetric shapes. So guy's here it is &lt;a href="https://9elements.github.io/fancy-border-radius/"&gt;9elements&lt;/a&gt;&lt;br&gt;
In this tool, you can create n number of different shapes with a border-radius property only.&lt;br&gt;
In the next blog, I will write about clip-path and other complex CSS shapes.&lt;/p&gt;

</description>
    </item>
    <item>
      <title>Capture Visitors in HTML/JS to your website </title>
      <dc:creator>Vinod Godti </dc:creator>
      <pubDate>Fri, 27 Sep 2019 18:04:29 +0000</pubDate>
      <link>https://forem.com/gvinod1991/capture-visitors-in-html-js-to-your-website-1b0m</link>
      <guid>https://forem.com/gvinod1991/capture-visitors-in-html-js-to-your-website-1b0m</guid>
      <description>&lt;p&gt;We can capture visitor's IP,geo-location and page URLs visited in a website. We can also capture from which device, platform and browser user as visited the webpage.&lt;/p&gt;

&lt;h2&gt;
  
  
  Why we should capture visitor's details
&lt;/h2&gt;

&lt;p&gt;To know the from which location traffic comes into our website. From this visitor's history, we can also analyze the user's behaviour. As per the user's behaviour we can target our potential customer.&lt;/p&gt;

&lt;p&gt;Let's capture the visitor's geo-location&lt;/p&gt;

&lt;p&gt;To gather the geo-location(longitude and latitude) of the visitor,We have HTML Geolocation API.we can access geolocation by calling method getCurrentPosition of navigator.geolocation object.&lt;/p&gt;

&lt;p&gt;first we have check that browser or device support  navigator.geolocation object or not &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;if(navigator.geolocation){
    navigator.geolocation.getCurrentPosition(function(position){
        console.log("longitude:"position.coords.longitude)
        console.log("latitude:"position.coords.latitude)
    })
}else{
    console.log("Geolocation is not supported by this device/browser")
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;NOTE: This API is strictly privacy-based means the browser will prompt for visitor's permission, when the user accepts to share location then only we can get the geolocation.&lt;/p&gt;

&lt;h2&gt;
  
  
  Page URLs and referrer URL
&lt;/h2&gt;

&lt;p&gt;To know from which website/webpage visitors came to your webpage/website we will use document.referrer.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    console.log(document.referrer)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;To get current page URL &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    console.log(location.href) 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  Browser/Platform Details
&lt;/h2&gt;

&lt;p&gt;We have navigator.userAgent to get the visitor's browser/platform details.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;console.log(navigator.userAgent)

//Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Ubuntu Chromium/76.0.3809.100 Chrome/76.0.3809.100 Safari/537.36
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  IP Address and location
&lt;/h2&gt;

&lt;p&gt;There are various web services to get IP address, city, region and country name. We may not get accurate details, But we can still rely on these services.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;fetch("https://ipapi.co/json/")
.then(response=&amp;gt;response.json())
.then((responseJson=&amp;gt;{
    console.log(responseJson)
}))

{
"ip": "2409:4062:115:954b:211e:e74:5180:15ae",
"city": "Bhubaneswar",
"region": "Odisha",
"region_code": "OR",
"country": "IN",
"country_name": "India",
"continent_code": "AS",
"in_eu": false,
"postal": "751030",
"latitude": 20.2724,
"longitude": 85.8339,
"timezone": "Asia/Kolkata",
"utc_offset": "+0530",
"country_calling_code": "+91",
"currency": "INR",
"languages": "en-IN,hi,bn,te,mr,ta,ur,gu,kn,ml,or,pa,as,bh,sat,ks,ne,sd,kok,doi,mni,sit,sa,fr,lus,inc",
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Limitations:&lt;br&gt;
1,000 requests per day&lt;br&gt;
Requires SSL (https)&lt;/p&gt;

&lt;p&gt;Note:- We can use various analytics services to track visitors to our website. To track website traffic by your own way then you can use the above hack.&lt;/p&gt;

</description>
      <category>html</category>
      <category>javascript</category>
      <category>geolocation</category>
      <category>visitors</category>
    </item>
    <item>
      <title>CSS Shapes with Animation</title>
      <dc:creator>Vinod Godti </dc:creator>
      <pubDate>Sun, 15 Sep 2019 05:13:20 +0000</pubDate>
      <link>https://forem.com/gvinod1991/css-shapes-with-animation-41jh</link>
      <guid>https://forem.com/gvinod1991/css-shapes-with-animation-41jh</guid>
      <description>&lt;p&gt;You can do wonders with simple CSS properties in the designing world.for example you can create a simple arrow symbol or heart with beating. So let's learn how to create different shapes in CSS and add animation property to shapes that are created.&lt;/p&gt;

&lt;h2&gt;
  
  
  Circle
&lt;/h2&gt;

&lt;p&gt;To create a circle, we have to first create div element and assign width and height CSS property. Add some background color and make border-radius 50%.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.circle{
   width:100x;
   height:100px;
   background:#159AC1;
   border-radius:50%; 
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  Rectangle
&lt;/h2&gt;

&lt;p&gt;To create a rectangle, We have to create a div element and assign width and height CSS property. Add some background color to make more clearly visible.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.rectangle{
   width:100x;
   height:50px;
   background:#159AC1;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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

&lt;h2&gt;
  
  
  Triangle
&lt;/h2&gt;

&lt;p&gt;To create a triangle shape, we have to user border property as with position: absolute. See the CSS code below.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.triangle-up{
    position: absolute;
    border-right: 20px solid transparent;
    border-left: 20px solid transparent;
    border-bottom: 20px solid tomato;
}

.triangle-down{
    position: absolute;
    border-top:20px solid tomato;
    border-left:20px solid transparent;
    border-right:20px solid transparent;
}

.triangle-right{
    position:absolute;
    border-right:20px solid tomato;
    border-top:20px solid transparent;
    border-bottom:20px solid transparent;
}

.triangle-left{
    position: absolute;
    border-left: 20px solid tomato;
    border-top: 20px solid transparent;
    border-bottom: 20px solid transparent;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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

&lt;h2&gt;
  
  
  Quarter Moon
&lt;/h2&gt;

&lt;p&gt;To create the quarter moon, First, create circle white background and apply box-shadow&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.quarter-moon {
    position: relative;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: #fff;
    box-shadow: 10px 10px 0 0 pink;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  Heart
&lt;/h2&gt;

&lt;p&gt;To create a heart shape, We should use pseudo-class before and after. We used scale rotate &amp;amp; scale transform properties in animation keyframe to show heartbeat&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.heart{
        position: relative;
    }

.heart:before {
    content: "";
    position: absolute;
    width: 50px;
    height: 75px;
    left: 0px;
    border-radius: 50px 50px 0 0;
    background: pink;
    transform: rotate(-45deg);
    animation: heart-pump 1s infinite;
}

.heart:after {
    content: "";
    position: absolute;
    width: 50px;
    height: 75px;
    left: 20px;
    border-radius: 50px 50px 0 0;
    background: pink;
    transform: rotate(45deg);
    animation: heart-pump-1 1s infinite;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Adding heart-beat animation&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@keyframes heart-pump {
    to {
        transform: rotate(-45deg) scale(1.2);
    }
}

@keyframes heart-pump-1 {
    to {
        transform: rotate(45deg) scale(1.2);
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

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

</description>
      <category>css</category>
      <category>animation</category>
      <category>shapes</category>
    </item>
    <item>
      <title>Javascript variables and it's data types </title>
      <dc:creator>Vinod Godti </dc:creator>
      <pubDate>Fri, 30 Aug 2019 17:54:16 +0000</pubDate>
      <link>https://forem.com/gvinod1991/javascript-variables-and-it-s-data-types-44gl</link>
      <guid>https://forem.com/gvinod1991/javascript-variables-and-it-s-data-types-44gl</guid>
      <description>&lt;h2&gt;
  
  
  How to declare a variable in javascript?
&lt;/h2&gt;

&lt;p&gt;There are 3 types of variable declaration.&lt;/p&gt;

&lt;p&gt;First using "var" keyword, which is an old method to declare a variable.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Syntax: - var "Variable Name";
var x;//Now x value is undefined means we not defined the variable yet
var y=5; //Now y value is 5 as we assigned 5 to it
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Second, using "let" keyword&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let x=5; //Now x value is 5 as we assigned 5 to it
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Difference between var and let keyword is variables declared with "let" keyword have block scope but in case of "var" have function scope.&lt;/p&gt;

&lt;p&gt;see the code below &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
    let i=0;
}
console.log(i)//Throws ReferenceError:i is undefined
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Here scope of i is limited inside the curly braces only. Outside curly braces variable i not available.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;{
    var x=5;
}

console.log(x);//5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Here the scope of variable x is available inside and outside of the curly braces as variables declared with "var" keyword are hoisted(Only variable declarations moved on top of the function or program)&lt;br&gt;
Above code executed like below&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var x;
{
    x=5;
}
console.log(x)//5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Third, using const, If we declare a variable using the const keyword value which is assigned first will never be updated with other value.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;const x=4;
x=5//Throws TypeError: Assignment to constant variable.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  Data Types and Type Checking
&lt;/h2&gt;

&lt;p&gt;There are 6 basic data types of variables that can be declared in javascript.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1.Number
2.String
3.Boolean
4.Object
5.Undefined
6.Null
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;One more data type in ES6 added is "Symbol"[I will cover this data type in my future blogs].&lt;br&gt;
Javascript variables are dynamically typed which means if we declare variable and assign value to it then it will convert that value type.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;var x=5;
console.log(x)//Type is Number
x="Ryu" // Type is String
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;We can check the type of the variables using &lt;strong&gt;typeof&lt;/strong&gt; function&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let x=5;
typeof(x) //Number

let x="Ryu";
typeof(x) //String

let x=true;
typeof(x) //Boolean

let x={};
typeof(x) //Object

let x=[];
typeof(x) //Object (In javascript array is also a object)

let x;
typeof(x) //Undefined

let x=null
typeof(x) //Object(It's a Javascript's exception is that typeof null is also a object)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Note:- This blog gives a brief about the variables and it's data types in Javascript. There are a lot of concepts regarding this topic that are not discussed in this blog.&lt;/p&gt;

&lt;p&gt;Follow me on my (twitter)[&lt;a href="https://twitter.com/GodtiVinod"&gt;https://twitter.com/GodtiVinod&lt;/a&gt;] and connect me on (LinkedIn)[&lt;a href="https://www.linkedin.com/in/godti-vinod-37bb46a9/"&gt;https://www.linkedin.com/in/godti-vinod-37bb46a9/&lt;/a&gt;]&lt;/p&gt;

</description>
      <category>javascript</category>
      <category>var</category>
      <category>let</category>
      <category>frontend</category>
    </item>
    <item>
      <title>WebStorage APIs and it's uses in day to day coding</title>
      <dc:creator>Vinod Godti </dc:creator>
      <pubDate>Sun, 18 Aug 2019 15:24:36 +0000</pubDate>
      <link>https://forem.com/gvinod1991/webstorage-apis-and-it-s-uses-in-day-to-day-coding-3icc</link>
      <guid>https://forem.com/gvinod1991/webstorage-apis-and-it-s-uses-in-day-to-day-coding-3icc</guid>
      <description>&lt;p&gt;Web storage APIs are used to store data in the browser. Using web storage API we can store a minimum of 5MB data in desktop browsers.There is 2 mechanisms that are most commonly used in the modern web development world are &lt;strong&gt;Local storage&lt;/strong&gt; and &lt;strong&gt;Session storage&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Why we should use Web storage?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;To store user's specific data in their own browsers such as navigation history, Profile details and other data that are irrelevant to store in the server's database.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Some user's specific data loading from the server via API call may be very expensive in terms of time.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let's dive into details &lt;/p&gt;

&lt;h2&gt;
  
  
  LocalStorage
&lt;/h2&gt;

&lt;p&gt;In this web storage, we can store data in a key-value pair format.&lt;br&gt;
Data stored in the web browser and data will persist even if the browser is closed. Data will remain as it unless and until we forcefully clear the data. We can store minimum of 5 MB or higher based on browser and platform.&lt;/p&gt;

&lt;h3&gt;
  
  
  Methods
&lt;/h3&gt;

&lt;p&gt;Local storage has various methods to access, store, update and delete the data.&lt;/p&gt;

&lt;p&gt;To save the data&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;window.localStorage.setItem("name","John Doe") 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;access the data &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;window.localStorage.getItem("name") //Output John Doe
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;remove the data from local storage&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;window.localStorage.removeItem("name") //Removes the data 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;update the data &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;window.localStorage("name","Nicolas")
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;To store the JSON data in local storage, We have to first convert JSON data into a string and then store it as localStorage accepts only string data.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let userData=JSON.stringify({"name":"Nicolas","email_id":"nicolas@abc.com"});
window.localStorage.setItem("userData",userData);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;To access the data, Again we have to convert a string into JSON data&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let userData=window.localStorage.getItem("userData");
console.log(JSON.parse(userData));
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  SessionStorage
&lt;/h2&gt;

&lt;p&gt;sessionStorage is the same as localStorage except data will be available until the browser tab is closed. Data will be available in a particular session. It also can store a minimum of 5 MB data. &lt;/p&gt;
&lt;h3&gt;
  
  
  Methods
&lt;/h3&gt;

&lt;p&gt;To save the data&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;window.sessionStorage.setItem("name","John Doe") 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;access the data &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;window.sessionStorage.getItem("name") //Output John Doe
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;remove the data from local storage&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;window.sessionStorage.removeItem("name") //Removes the data 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;This web storage API also accepts string data only.&lt;/p&gt;

</description>
      <category>htmlwebstorage</category>
      <category>localstorage</category>
      <category>html</category>
    </item>
    <item>
      <title>Flex box layout for responsive designs(Part-2)</title>
      <dc:creator>Vinod Godti </dc:creator>
      <pubDate>Tue, 30 Jul 2019 12:56:52 +0000</pubDate>
      <link>https://forem.com/gvinod1991/flex-box-layout-for-responsive-designs-part-2-27o6</link>
      <guid>https://forem.com/gvinod1991/flex-box-layout-for-responsive-designs-part-2-27o6</guid>
      <description>&lt;p&gt;So far we have covered the flex-direction,justify-content,align-items, and flex-wrap properties and it's value to design/develop the responsive layout. There are more properties in the flex-box like the order of the flex items and align-self.&lt;/p&gt;

&lt;p&gt;So let's get started&lt;/p&gt;

&lt;h2&gt;
  
  
  order
&lt;/h2&gt;

&lt;p&gt;sometimes it is not sufficient to reversing the rows and column order of the container for the exact requirement to develop the layout. In that case, we can use order property to order the items inside the container.By default order of any item is 0 inside the container.we can use positive or negative integers as order values. Order property can only be applied to individual items.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;ul class="flex-box"&amp;gt;
    &amp;lt;li class="home"&amp;gt;Home&amp;lt;/li&amp;gt;
    &amp;lt;li&amp;gt;About&amp;lt;/li&amp;gt;
    &amp;lt;li&amp;gt;Portfolio&amp;lt;/li&amp;gt;
    &amp;lt;li&amp;gt;Contact&amp;lt;/li&amp;gt;
&amp;lt;/ul&amp;gt;

.flex-box {
    display: flex;
    flex-direction: row;
    justify-content: flex-start;
    align-items: center;
}
.flex-box :first-child {
    order: 1;
}
.flex-box :last-child {
    order: -1;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Highest ordered items are displayed later than that of lowest order items&lt;/p&gt;

&lt;p&gt;In the above example "Home" will be displayed last than other 3 and "Contact" will be displayed first as it's order is lower than others&lt;/p&gt;

&lt;p&gt;Flex items with same order will be displayed in the same order as source order such as one after other&lt;/p&gt;

&lt;p&gt;Thus if you have 4 items with order values of 3, 2, 2, and 0 sets on them respectively, their display order would be 4th, 2nd, 3rd, then 1st.&lt;/p&gt;

&lt;p&gt;The 3rd item displayed after the 2nd because it has the same order value and is after it in the source order.&lt;/p&gt;

&lt;p&gt;Have look at the code pen link below to get a more clear picture.&lt;/p&gt;

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

&lt;h2&gt;
  
  
  align-self
&lt;/h2&gt;

&lt;p&gt;This property can also be applied to individual items.It will accept the same values as align-items and its value for the specific item. Consider the below CSS code with the previous example's Html code.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.flex-box {
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    align-items: center;
}
.flex-box :first-child {
    align-self: flex-start;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;"Home" will be displayed at the beginning of the row. As align-self property and value flex-start was applied in the above code&lt;/p&gt;

&lt;p&gt;To get more clarity in align self refer to the below code pen&lt;/p&gt;

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

</description>
      <category>css</category>
      <category>flexbox</category>
      <category>ui</category>
      <category>frontend</category>
    </item>
    <item>
      <title>Flex-box layout for responsive designs(Part-1)</title>
      <dc:creator>Vinod Godti </dc:creator>
      <pubDate>Sun, 14 Jul 2019 19:47:04 +0000</pubDate>
      <link>https://forem.com/gvinod1991/flex-box-layout-for-responsive-designs-part-1-24co</link>
      <guid>https://forem.com/gvinod1991/flex-box-layout-for-responsive-designs-part-1-24co</guid>
      <description>&lt;p&gt;In designing, Webpage or screen layout design is the most important part. If we could design the layout well than we can fit items inside the layout/container as per requirement. To design the layout we usually used display, position, and float. Before this layout module, we had used a table layout. Now we have a new feature in CSS to the layout which is display: flex, in other words, flexible layout. We can align and distribute space between the items in the container even if the size of items is unknown or dynamic.&lt;/p&gt;

&lt;p&gt;Flex-box Layout module can be helpful for developers to develop responsive layouts easily without using the float and position.&lt;/p&gt;

&lt;p&gt;Let's dig into more details of the flex-box layout or flexible layout.&lt;/p&gt;

&lt;p&gt;To start with display flex, we need to define container with a display: flex.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.container{
    display:flex;
}

&amp;lt;div class="container"&amp;gt;
    &amp;lt;div&amp;gt;1&amp;lt;/div&amp;gt;
    &amp;lt;div&amp;gt;2&amp;lt;/div&amp;gt;
    &amp;lt;div&amp;gt;3&amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;To align items horizontally,justify-content is used. It accepts the following values.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;flex-start: items align to the left side of the container&lt;/li&gt;
&lt;li&gt;flex-end: items align to the right side of the container&lt;/li&gt;
&lt;li&gt;center: items align at the center of the container&lt;/li&gt;
&lt;li&gt;space-between: items display with equal spacing between them&lt;/li&gt;
&lt;li&gt;space-around: items display with equal space around them&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;See the code below&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.container{
    display:flex;
    justify-content:flex-start;/*Item align at beginning of the container horizontally*/
}
&amp;lt;div class="container"&amp;gt;
    &amp;lt;div&amp;gt;1&amp;lt;/div&amp;gt;
    &amp;lt;div&amp;gt;2&amp;lt;/div&amp;gt;
    &amp;lt;div&amp;gt;3&amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt; 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;To align items vertically,align-item is used. It accepts the following values.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;flex-start: items align to the top side of the container&lt;/li&gt;
&lt;li&gt;flex-end: items align to the bottom side of the container&lt;/li&gt;
&lt;li&gt;center: items align at the center of the container&lt;/li&gt;
&lt;li&gt;baseline: items display at the baseline of the container&lt;/li&gt;
&lt;li&gt;stretch: items are stretched to fit the container&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;See the code below&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.container{
    display:flex;
    align-item:flex-end;/*Item align at the bottom vertically*/
}

&amp;lt;div class="container"&amp;gt;
    &amp;lt;div&amp;gt;1&amp;lt;/div&amp;gt;
    &amp;lt;div&amp;gt;2&amp;lt;/div&amp;gt;
    &amp;lt;div&amp;gt;3&amp;lt;/div&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;One thing you should consider that the direction of the elements is positioned. For display flex, there is direction property which is flex-direction: row or column. In the case of "row", elements are placed the same as the text direction and in case of "column", elements are placed from top to bottom. There are 2 more values for the flex-direction which are "row-reverse" and "column-reverse".When "row-reverse" is applied to flex-direction then items are placed as opposite of text direction and in the case of "column-reverse" items are placed bottom to top.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.container{
    display:flex;
    flex-direction:row;
    justify-content:space-around;/*Space around the item in horizontal direction*/
}
.container{
    display:flex;
    flex-direction:column;
    align-item:flex-end;/*Item align at the bottom vertically */
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;When the direction is reversed then flex-start and flex-end values of the justify-content and align-items are also reversed means flex-start will start behaving like flex-end and vice-versa.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.container{
    display:flex;
    flex-direction:row-reverse;
    justify-content:flex-start/*items align to the right side of the container*/
}

.container{
    display:flex;
    flex-direction:column-reverse;
    align-item:flex-end;items align to the top side of the container
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;To make the new line or not when items size is more than the container size can be decided by flex-wrap property.flex-wrap property will accept the following values.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;wrap: items wrap around to new line&lt;/li&gt;
&lt;li&gt;wrap-reverse: items wrap around the new line in reverse order&lt;/li&gt;
&lt;li&gt;nowrap: Every item is fit to a single line&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;See the code below&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.container{
    display:flex;
    flex-wrap:wrap/*wraps to new line if items are not fitting in one line*/
}
.container{
    display:flex;
    flex-wrap:wrap-reverse/*wraps to new line if items are not fitting in one line in reverse direction*/
}
.container{
    display:flex;
    flex-wrap:nowrap/*Don't wraps to new line even if,items are not fitting in one line*/
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Flex-box layout design will be helpful for developers to design the layout quickly and efficiently. The remaining concepts of flex-box will be covered in part-2 of this blog post.&lt;/p&gt;

</description>
      <category>css</category>
      <category>ui</category>
      <category>flexbox</category>
      <category>cssflex</category>
    </item>
    <item>
      <title>CSS Media Types and Queries for Mobile Responsive Design </title>
      <dc:creator>Vinod Godti </dc:creator>
      <pubDate>Sun, 23 Jun 2019 19:40:48 +0000</pubDate>
      <link>https://forem.com/gvinod1991/css-media-types-and-queries-for-mobile-responsive-design-4f4c</link>
      <guid>https://forem.com/gvinod1991/css-media-types-and-queries-for-mobile-responsive-design-4f4c</guid>
      <description>&lt;p&gt;Nowadays mobile responsive websites and even web applications are very common. Everyone wants to develop their websites and web apps should be mobile responsive, which means clearly visible and interactive in every handheld devices. Due to the smartphone revolution, mobile browser users are more than desktop browsers. To target the mobile browser user every organization/individual is mostly preferred to develop mobile responsive websites or web apps. Every UI/UX developer should know about responsive and more interactive designs. In responsive design, CSS media queries play a very crucial role, why because using media queries we can write device-specific CSS code which is a basement of responsive design.&lt;/p&gt;

&lt;p&gt;Let's dive into details of CSS media types and queries &lt;/p&gt;

&lt;p&gt;In CSS2 @media rule was introduced for the first time to define the rules for different media types such as computer screens, handheld devices, printers, and TV screens but it not supported as expected for many devices except printers.&lt;/p&gt;

&lt;p&gt;Later in CSS3 media queries were introduced by extending the @media from CSS2. Media queries look for the resolution of the screen, not the devices. As per the width and height of the screen, Media query rule will be applied.&lt;/p&gt;

&lt;h2&gt;
  
  
  Media Types
&lt;/h2&gt;

&lt;p&gt;There are four media types &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;all (used for all media types)&lt;/li&gt;
&lt;li&gt;screen (used for screens)&lt;/li&gt;
&lt;li&gt;print (used for print devices)&lt;/li&gt;
&lt;li&gt;speech (used for screen readers)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;We can link the media specific external stylesheets in the header part of the HTML file.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;link rel="stylesheet" media='print' href="print.css"&amp;gt;
&amp;lt;link rel="stylesheet" media='screen' href="styles.css"&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  Media Queries
&lt;/h2&gt;

&lt;p&gt;Media queries rules are used to write the device-specific styles and syntax is &lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@media mediatype not|only|and|, (expressions){
    /*css code here*/
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;",", "and", "not", "only" are used to combine the two or more media queries to make complex media query.&lt;/p&gt;

&lt;h3&gt;
  
  
  and
&lt;/h3&gt;

&lt;p&gt;let's write some CSS for mobile browsers smaller than 480px(iPhone)&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@media screen and (max-width:480px){
    .nav{
        font-size:12px;
        display:block
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The above media query is combined with "and" condition, When the device screen width is 480px or less, then above styles are applied to nav class&lt;/p&gt;

&lt;p&gt;Now we will target range of the screen width&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@media screen and (min-width:480px) and (max-width:768px){
    .nav{
        color:green
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Font color will be green when screen width in between the 480px and 768px(tablet screen width)&lt;/p&gt;

&lt;p&gt;For Tablets, iPads (portrait) screens, We can write following media query &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@media screen (min-width:480px) and (min-width:1024px){
    .nav{
        color:grey
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;For laptops/desktop screens &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@media screen and (min-width:1224px){
    .nav{
        color:blue
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;For large desktop screens &lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@media screen and (min-width:1884px){
    .nav{
        color:red
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;For screen orientations&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@media screen and (min-device-width: 481px) and (max-device-width: 1024px) and (orientation:portrait) {
    .nav{
        color:blue;/*Color will be blue,When screen orientation is portrait and width in between 481px and 1024px*/
    }
}

@media screen and (min-device-width: 481px) and (max-device-width: 1024px) and (orientation:landscape) {
    .nav{
        color:tomato;/* color will be tomato ,When screen orientation is landscape and width in between 481px and 1024px*/
    }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
  
  
  or(,)
&lt;/h3&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@media (max-width:480px), (min-width:768px){
    .html{
        color:green
    }
} 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Two separate media queries are joined with "," and styles will be applied when screen width is 480px or less and 768px or above.&lt;/p&gt;

&lt;h3&gt;
  
  
  only
&lt;/h3&gt;

&lt;p&gt;"only" keyword is used to not load stylesheet by the browser which not support the media queries.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@media only screen (max-width:480px){
    html{
        color:green
    }
} 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
  
  
  not
&lt;/h3&gt;

&lt;p&gt;if we write a media query with "not" keyword, media query is true without not will become false. media query not supported browsers will not understand the "not" keyword, therefore associated styles are not applied.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@media not screen (max-width:480px){
    html{
        color:green
    }
} 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Device screen widths for media queries&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Mobile phone screens width : 480px&lt;/li&gt;
&lt;li&gt;Tablets(ipad) screen width : 768px&lt;/li&gt;
&lt;li&gt;Laptop and Desktop screen widths &amp;gt; 1024px&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Note:-First design layout for the mobile phone screen and then use media queries for tablet and desktop screens, Thus development will be faster.&lt;/p&gt;

</description>
      <category>css</category>
      <category>ui</category>
      <category>ux</category>
      <category>frontend</category>
    </item>
    <item>
      <title>CSS selectors and it's Specificity(Priority to override other)</title>
      <dc:creator>Vinod Godti </dc:creator>
      <pubDate>Sat, 08 Jun 2019 15:27:17 +0000</pubDate>
      <link>https://forem.com/gvinod1991/css-selectors-and-it-s-specificity-priority-to-override-other-1kij</link>
      <guid>https://forem.com/gvinod1991/css-selectors-and-it-s-specificity-priority-to-override-other-1kij</guid>
      <description>&lt;h2&gt;
  
  
  What's the problem when a developer didn't understand selectors clearly?
&lt;/h2&gt;

&lt;p&gt;Sometime we apply styles to some html elements but don't work as per our code and finally end of with bug in our code. To avoid this kind of bugs developers should clearly understand the concept of css selectors and it's specificity.&lt;/p&gt;

&lt;p&gt;The following are few other problems in applying styles to html elements.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;How to apply style to all elements which is nested inside one element.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;We face a challenge to select all odd and even li elements in a list and apply different styles to each.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;If we have more than one elements to apply same styles to all.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;We have to target only one element which should be unique in the entire html document.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;To solve above problems we use the different types of selectors and apply styles to html elements.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is selector in css ?
&lt;/h2&gt;

&lt;p&gt;In general english ,we can say a thing that selects something. So like that selector in css is also selects or find the HTML elements.Selectors are used to target the html elements to apply styles on it.&lt;/p&gt;

&lt;p&gt;Most commonly used and selectors are &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;HTMl element/Tag name Called as Type selector&lt;/li&gt;
&lt;li&gt;class&lt;/li&gt;
&lt;li&gt;id&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In Css,we can have more selectors which are little bit tricky to understand like &lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;pseudo classes&lt;/li&gt;
&lt;li&gt;pseudo element&lt;/li&gt;
&lt;li&gt;attribute selectors&lt;/li&gt;
&lt;li&gt;universal selector&lt;/li&gt;
&lt;li&gt;Combinator(multiple selectors combined)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let's explore each selector one by one &lt;/p&gt;

&lt;h2&gt;
  
  
  Type Selector(By tag name)
&lt;/h2&gt;

&lt;p&gt;We can select one or more elements by it's name.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;p{
    color:green;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;In the above code snippets, color green is applied to all p elements in html document.&lt;/p&gt;

&lt;h2&gt;
  
  
  Class(.)
&lt;/h2&gt;

&lt;p&gt;class(.) selector identifies all the elements have the attribute class.If you have multiple elements with same class name then same styles are applied to all elements.See the code below.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.box{
    width:200px;
    height:200px;
    border:1px solid #ccc
}

&amp;lt;div class="box"&amp;gt;
    I am box
&amp;lt;/div&amp;gt;
&amp;lt;div class="box"&amp;gt;
    I am 2nd box
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  Id(#)
&lt;/h2&gt;

&lt;p&gt;id(#) selector identifies only one element have the attribute name id.If you have multiple elements with same id then it selects the first element.Check the code below&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#avatar{
    width:100px;
    height:100px;
    border-radius:50%;
    border:1px solid #ccc
}
&amp;lt;div id="avatar"&amp;gt;
    avatar
&amp;lt;/div&amp;gt;
&amp;lt;div id="avatar"&amp;gt;
    avatar2
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;The above style is applied only to the first div element.&lt;/p&gt;

&lt;p&gt;All advanced selectors are identifies a specific element(s) when combined with commonly used selectors &lt;/p&gt;

&lt;h2&gt;
  
  
  Pseudo-Class(:)
&lt;/h2&gt;

&lt;p&gt;As you know pseudo class is used to define state of the html element such as mouse hover or link after visited. So this can be used as selector to style the element when element in a particular state.&lt;/p&gt;

&lt;p&gt;Common pseudo-classes are :hover,:visited,:link and :active.These are combined with other selectors to find the specific state of the element and apply style on it&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a:hover{
    color:tomato /* On mouse hover,color of a is tomato color */
}
a:visited{
    color:red /* On linked visited,color of a is red */
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;We can select the a particular numbered children of the parent element by using the :nth-child() and a particular numbered children of the parent element counted from last by :nth-last-child.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;li:nth-child(2){
    color:green
}

The above code selects every li element which is 2nd child of it's parent and apply color property to green.

li:nth-child(even){
    color:yellow /* selects the li element which is even child of it's parent */
}

li:nth-child(odd){
    color:yellow /* selects the li element which is odd child of it's parent */
}

li:nth-lat-child{
    color:blue /* selects the li element which is 2nd child but counting from last*/
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  Pseudo-Element(::)
&lt;/h2&gt;

&lt;p&gt;Mostly common pseudo elements are ::before  and ::after.These are used to place/add some content to specific part of the element such as before or after.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;span::before{
    content:url('left-arrow.png);
    padding:2px   
}

span::after{
    content:url('right-arrow.png);
    padding:2px
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Other rarely used pseudo elements are ::first-letter and ::first-line selects first letter of the word and first line of paragraph respectively.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;p::first-letter{
    font-size:36px;
    font-weight:bold
}

p::first-line{
    font-weight:bold
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  Attribute Selector([attribute])
&lt;/h2&gt;

&lt;p&gt;To apply styles to element that have specific attributes and attribute values,We can use attribute selector.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a[href="https://www.google.com"]{

    color:violet /* All a with href and it's value https://www.google.com are colored with violet. */
}

input[type="text"]{

    border:none /* No border property applied to all inputs with attribute type and it's value text. */
}

a[target]{
    background-color:cyan /* All a tags with attribute target have background color cyan */
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  Universal Selector(*)
&lt;/h2&gt;

&lt;p&gt;This selector selects all the elements when it defined.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;*{
    background:#f5f5f5
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;It selects all elements and apply background color as #f5f5f5&lt;/p&gt;

&lt;h2&gt;
  
  
  Combinator Selectors (+,&amp;gt;,space and ~)
&lt;/h2&gt;

&lt;p&gt;We can combine two elements with +,&amp;gt; space and ~ to identify relative elements of two combined elements&lt;/p&gt;

&lt;h3&gt;
  
  
  Descendant Selector(space)
&lt;/h3&gt;

&lt;p&gt;This type combination matches all the elements(element after space) which are descendants of specified element(element before space).See the example below.&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;div p{
    color:red /*It selects all the p elements which are inside div element*/
}
&amp;lt;div&amp;gt;
    &amp;lt;p&amp;gt;I am small paragraph.&amp;lt;/p&amp;gt;&amp;lt;!--Color is red--&amp;gt;
    &amp;lt;section&amp;gt;
        &amp;lt;p&amp;gt;I am paragraph inside section&amp;lt;/p&amp;gt;&amp;lt;!--Color is red--&amp;gt;
    &amp;lt;/section&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
  
  
  Children Selector(&amp;gt;)
&lt;/h3&gt;

&lt;p&gt;It matches all the elements(element after &amp;gt;) which are immediate children of specified element(element before &amp;gt;).&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;div &amp;gt; p{
    color:red /*It selects all the p elements which are only immediate children div element*/
}
&amp;lt;div&amp;gt;
    &amp;lt;p&amp;gt;I am small paragraph.&amp;lt;/p&amp;gt;&amp;lt;!--Color is red--&amp;gt;
    &amp;lt;section&amp;gt;
        &amp;lt;p&amp;gt;I am paragraph inside section&amp;lt;/p&amp;gt;&amp;lt;!--Color is black--&amp;gt;
    &amp;lt;/section&amp;gt;
&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
  
  
  Adjacent Sibling selector(+)
&lt;/h3&gt;

&lt;p&gt;It identifies the all elements(element after +) which are adjacent sibling elements of specific element(before +).&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;div + p{
    color:#ccc;/*selects all p elements that are placed immediately after div elements*/
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h3&gt;
  
  
  General Sibling Selector(~)
&lt;/h3&gt;

&lt;p&gt;This type of selector selects all elements that are siblings of a specified element.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;div ~ p{
    color:#ccc;/*selects all p elements that are siblings of div elements*/
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;
&lt;h2&gt;
  
  
  Selector Specificity(Priority to override other)
&lt;/h2&gt;

&lt;p&gt;Specificity means how browser calculate and apply style to html elements (Which type of selector high priority to override other selector's property)&lt;/p&gt;

&lt;p&gt;Find the list of selectors from high to low specificity/Overriding priority&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;id(#)&lt;/li&gt;
&lt;li&gt;class(.) ,pseudo class(:),pseudo element(::) and attribute selector&lt;/li&gt;
&lt;li&gt;Type Selector(Html Tag name)&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Universal selector (*) and combinators (+, &amp;gt;, ~, space) have no effect on specificity.&lt;/p&gt;

&lt;p&gt;We can not override the inline style from internal and external styles as inline style has high priority of overriding all external and internal styles.We can override inline styles from external and internal styles by using "!important" beside any property.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;p{
    color:cyan!important;
}

&amp;lt;p style="color:red"&amp;gt;I am paragraph&amp;lt;/p&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;Color of the paragraph is cyan as inline style color property is overridden by !important beside the property&lt;/p&gt;

&lt;p&gt;Note:-I have written this blog for the newbie developers and my intention is to make understood all commonly used selectors to new comers to web coding world as there are many more selectors in css which are not covered in this blog.&lt;/p&gt;

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