<?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: Aniket Deshbhratar</title>
    <description>The latest articles on Forem by Aniket Deshbhratar (@aniketmde).</description>
    <link>https://forem.com/aniketmde</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%2F57554%2F00a291a0-5470-4262-8402-914deb266d99.jpg</url>
      <title>Forem: Aniket Deshbhratar</title>
      <link>https://forem.com/aniketmde</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://forem.com/feed/aniketmde"/>
    <language>en</language>
    <item>
      <title>How to make webpage responsive ? 📱💻🖥️</title>
      <dc:creator>Aniket Deshbhratar</dc:creator>
      <pubDate>Tue, 20 Jun 2023 18:27:29 +0000</pubDate>
      <link>https://forem.com/aniketmde/how-to-make-webpage-responsive--4nn2</link>
      <guid>https://forem.com/aniketmde/how-to-make-webpage-responsive--4nn2</guid>
      <description>&lt;p&gt;Here are a few key points to consider when developing a responsive webpage 👨‍💻&lt;/p&gt;

&lt;p&gt;1.&lt;strong&gt;Use meta tags&lt;/strong&gt; ☝️:&lt;br&gt;
This is very important to include meta tags in the &lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt; element of your webpage.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;strong&gt;What is viewport&lt;/strong&gt; 🤔? &lt;br&gt;
The viewport is the visible area of a webpage on a display device.&lt;/p&gt;

&lt;p&gt;Why we have to declare width and initial scale for content 🤷‍♀️? &lt;br&gt;
Declaring the width and initial scale is important to instruct the browser on how to handle the content.&lt;br&gt;
&lt;strong&gt;- Width&lt;/strong&gt;: Specify that the content should have the same width as the current screen, similar to using 100vw.&lt;br&gt;
&lt;strong&gt;- Initial scale&lt;/strong&gt;: Set the zoom level of the webpage to the default, adjusting the content to fit within the screen during the initial load and also preventing zooming the page.&lt;/p&gt;

&lt;p&gt;2.&lt;strong&gt;Use dynamic units&lt;/strong&gt; 🔢:&lt;br&gt;
Avoid using pixel (px) values. Instead, consider using percentage (%) values for width and height. You can also use relative units like 'em' or 'rem', which adapt better to different screen sizes.&lt;/p&gt;

&lt;p&gt;3.&lt;strong&gt;Media Queries&lt;/strong&gt; 📳:&lt;br&gt;
Media queries are where the real magic happens. They allow you to override the CSS styles based on specific conditions, such as the width of the screen.&lt;/p&gt;

&lt;p&gt;For example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="k"&gt;@media&lt;/span&gt; &lt;span class="n"&gt;screen&lt;/span&gt; &lt;span class="n"&gt;and&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;min-width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1025px&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="n"&gt;and&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="n"&gt;max-width&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1200px&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nt"&gt;body&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;blue&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This media query will apply the color blue to the body when the screen width is between 1025px and 1200px.&lt;/p&gt;

&lt;p&gt;Media queries can also target specific orientations or media types.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@media screen and (orientation: landscape) {
  body {
    color: blue;
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;by using this we can target mobile, tablet landscape and portrait orientation.&lt;/p&gt;

&lt;p&gt;Most used media queries breakpoints : &lt;br&gt;
320px — 480px: Mobile devices&lt;br&gt;
481px — 768px: iPads, Tablets&lt;br&gt;
769px — 1024px: Small screens, laptops&lt;br&gt;
1025px — 1200px: Desktops, large screens&lt;br&gt;
1201px and more —  Extra large screens, TV&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Note:&lt;/strong&gt; Best practice to use media queries is to write at the bottom of stylesheet.&lt;/p&gt;

&lt;p&gt;4.&lt;strong&gt;Responsive images&lt;/strong&gt; 🍀 :&lt;br&gt;
To make images responsive, use CSS rules. Set the &lt;code&gt;max-width&lt;/code&gt; of the image to &lt;code&gt;100%&lt;/code&gt; and keep the &lt;code&gt;height&lt;/code&gt; as &lt;code&gt;auto&lt;/code&gt;. This allows the image to scale proportionally and fit within its container.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Using modern CSS layout properties such as flexbox and grid makes it much easier to create responsive elements.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Yeah 🥳🥳🥳&lt;br&gt;
That's all you need to make your webpage responsive :) &lt;br&gt;
So go ahead and make your webpage responsive and enjoy the benefits of a great user experience across different devices and screen sizes! 🎉🌟&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Additionally, here are some extra points to consider&lt;/strong&gt; 🤠 :&lt;/p&gt;

&lt;p&gt;1) Height specific &lt;code&gt;Viewport&lt;/code&gt; meta tag&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;meta name="viewport" content="height=device-height, initial-scale=1.0"&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;2) Meta tag property to allow user to zoom webpage ("0" or "no")&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;meta name="viewport" content="width=device-width, user-scalable=0"&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;3) Apply screen/device specific stylesheet.&lt;br&gt;
&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="screen and (min-width: 480px)" href="mobile.css"&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;4) @media types &lt;br&gt;
all — for all media types.&lt;br&gt;
print — printable css style.&lt;br&gt;
screen — for computer screens, tablets and, smart-phones.&lt;br&gt;
speech — this will help screen readers reads all punctuation out loud.&lt;/p&gt;

&lt;p&gt;5) Target multiples screen using "comma"&lt;br&gt;
//device width between 320px and 480px OR above 1024px&lt;br&gt;
&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: 320px) and (min-width: 470px), (min-width: 1024px) {}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;6) Target height to detect screen size.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@media screen and (min-height: 350px) {
  body {
    color: yellow;
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;7) Media queries to target device using screen aspect-ratio.&lt;br&gt;
calculation of the width-to-height aspect ratio of the viewport&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;@media (max-aspect-ratio: 3/2) {
  div {
    color: red;
  }
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--TDXV3Qrs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y6imhe4vhj9kq57i6cgt.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--TDXV3Qrs--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/y6imhe4vhj9kq57i6cgt.png" alt="done" width="600" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Best place to learn flexbox : &lt;br&gt;
&lt;a href="https://flexboxfroggy.com/"&gt;https://flexboxfroggy.com/&lt;/a&gt; &lt;br&gt;
&lt;a href="https://www.freecodecamp.org/news/learn-css-flexbox/"&gt;https://www.freecodecamp.org/news/learn-css-flexbox/&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Free Courses : &lt;br&gt;
&lt;a href="https://www.coursera.org/learn/responsive-web-design"&gt;https://www.coursera.org/learn/responsive-web-design&lt;/a&gt; &lt;br&gt;
&lt;a href="https://www.udacity.com/course/responsive-web-design-fundamentals--ud893"&gt;https://www.udacity.com/course/responsive-web-design-fundamentals--ud893&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Photo by &lt;a href="https://unsplash.com/@domenicoloia?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Domenico Loia&lt;/a&gt; on &lt;a href="https://unsplash.com/photos/EhTcC9sYXsw?utm_source=unsplash&amp;amp;utm_medium=referral&amp;amp;utm_content=creditCopyText"&gt;Unsplash&lt;/a&gt;&lt;/p&gt;

</description>
      <category>responsive</category>
      <category>frontend</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
