<?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: Katerina Braide</title>
    <description>The latest articles on DEV Community by Katerina Braide (@braide).</description>
    <link>https://dev.to/braide</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%2F774896%2Fc02ff89b-9239-4765-9721-093ef3c9bf4f.jpeg</url>
      <title>DEV Community: Katerina Braide</title>
      <link>https://dev.to/braide</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/braide"/>
    <language>en</language>
    <item>
      <title>Managing a team can often feel overwhelming, especially if you’re not a professional project manager but still need to organize work efficiently. This tool serves as a productivity booster by automating repetitive tasks and centralizing project management.</title>
      <dc:creator>Katerina Braide</dc:creator>
      <pubDate>Mon, 27 Jan 2025 08:45:07 +0000</pubDate>
      <link>https://dev.to/braide/managing-a-team-can-often-feel-overwhelming-especially-if-youre-not-a-professional-project-3pni</link>
      <guid>https://dev.to/braide/managing-a-team-can-often-feel-overwhelming-especially-if-youre-not-a-professional-project-3pni</guid>
      <description>&lt;div class="ltag__link"&gt;
  &lt;a href="/miracleio" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__pic"&gt;
      &lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F223230%2Fdf65afe6-a894-4b44-90b5-278da51b3b2c.png" alt="miracleio"&gt;
    &lt;/div&gt;
  &lt;/a&gt;
  &lt;a href="https://dev.to/miracleio/project-management-assembly-of-agents-built-with-agentai-3gih" class="ltag__link__link"&gt;
    &lt;div class="ltag__link__content"&gt;
      &lt;h2&gt;Project Management Assembly of Agents Built with Agent.ai&lt;/h2&gt;
      &lt;h3&gt;Miracleio ・ Jan 27&lt;/h3&gt;
      &lt;div class="ltag__link__taglist"&gt;
        &lt;span class="ltag__link__tag"&gt;#devchallenge&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#agentaichallenge&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#ai&lt;/span&gt;
        &lt;span class="ltag__link__tag"&gt;#machinelearning&lt;/span&gt;
      &lt;/div&gt;
    &lt;/div&gt;
  &lt;/a&gt;
&lt;/div&gt;


</description>
    </item>
    <item>
      <title>Variable Fonts for Dynamic Typography</title>
      <dc:creator>Katerina Braide</dc:creator>
      <pubDate>Tue, 03 Dec 2024 09:41:52 +0000</pubDate>
      <link>https://dev.to/braide/variable-fonts-for-dynamic-typography-ajm</link>
      <guid>https://dev.to/braide/variable-fonts-for-dynamic-typography-ajm</guid>
      <description>&lt;p&gt;Do you find it tedious to keep track of several font files for various weights and styles? Creating distinct files for ordinary, bold, italic, and other font variations can be challenging for web designers. This complicates the creative process and clogs their workflow. How about combining all these variants into one file?&lt;/p&gt;

&lt;p&gt;That's where &lt;a href="https://en.wikipedia.org/wiki/Variable_font#:~:text=A%20variable%20font%20(VF)%20is,fonts%20available%20to%20be%20sampled." rel="noopener noreferrer"&gt;variable fonts&lt;/a&gt; come in. Variable fonts are a groundbreaking advancement in &lt;a href="https://en.wikipedia.org/wiki/OpenType" rel="noopener noreferrer"&gt;OpenType&lt;/a&gt; font technology that allows one font file to contain multiple variations, such as regular, bold, and italic. This implies that designers just need to work with one file to access all the various weights, styles, and widths they require. This invention makes it simple to constantly and easily modify characteristics like weight, width, and tilt, which streamlines the design process and fosters creative freedom.&lt;/p&gt;

&lt;p&gt;Using the &lt;a href="https://www.behance.net/gallery/90690" rel="noopener noreferrer"&gt;Kyiv Sans&lt;/a&gt; font as an example, this article will look at the relevance of different fonts in CSS and demonstrate how important qualities like weight and even non-standard font variations like &lt;code&gt;MIDL&lt;/code&gt;. Using these tools, we will learn how to produce dynamic and aesthetically stunning typography in CSS.&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction to Variable Fonts
&lt;/h2&gt;

&lt;p&gt;Variable font technological architecture lets designers and developers instantly control these typographic characteristics using CSS, thus permitting exact changes to fit the particular requirements of a project. This improves web performance by greatly lowering load times and replacing many static font files with a single variable font file.&lt;/p&gt;

&lt;p&gt;With their degree of flexibility and accuracy formerly unheard of with conventional static font files, variable fonts constitute a major development in typographic technology. Unlike traditional fonts, which demand separate files for every style and weight, variable fonts capture several styles within one, scalable file. This is accomplished with the OpenType font style, which permits constant variation along one or more axes—such as weight, width, and optical size.&lt;/p&gt;

&lt;h3&gt;
  
  
  Benefits of Variable Fonts in CSS
&lt;/h3&gt;

&lt;p&gt;We'll walk you through how to create dynamic and aesthetically pleasing CSS typography using these tools. Let's examine a few examples:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Efficiency:&lt;/strong&gt; By combining several font styles into a single file, variable fonts minimize HTTP requests, speeding up page loads and overall efficiency.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Flexibility:&lt;/strong&gt; Designers may precisely modify typography to fit different design contexts and user preferences because of their fine-grained control over properties like &lt;code&gt;wght&lt;/code&gt; and custom properties like &lt;code&gt;MIDL&lt;/code&gt; and &lt;code&gt;CONT&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Smooth Transitions:&lt;/strong&gt; Variable fonts allow for dynamic changes to font styles, avoiding abrupt switches between discrete font files. As a result, transitions between font styles are smooth and fluid.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Responsive Typography:&lt;/strong&gt; Variable fonts enable responsive typography by allowing adjustments based on &lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Viewport_meta_tag" rel="noopener noreferrer"&gt;&lt;code&gt;viewport&lt;/code&gt;&lt;/a&gt; size or other user-defined parameters, ensuring optimal legibility and aesthetic appeal across devices.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Dynamic Typography:&lt;/strong&gt; Variable fonts provide real-time changes depending on user interaction or environmental conditions, therefore supporting dynamic, improving user involvement, and generating immersive experiences.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Accessibility:&lt;/strong&gt; A wider range of typographic options allows text customization and modification to ensure legibility and readability across various devices and user preferences.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Aesthetics:&lt;/strong&gt; On the web, variable fonts inspire creative design ideas and challenge typographic boundaries, opening up new opportunities for typographic expression and experimentation.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Scalability:&lt;/strong&gt; Variable fonts are perfect for responsive design and guarantee that text is clear and legible at any size or resolution since they are scalable without quality loss.&lt;/p&gt;

&lt;h3&gt;
  
  
  Introduction to the concept of responsive and dynamic typography using variable fonts
&lt;/h3&gt;

&lt;p&gt;Modern web design allows designers to create more flexible and captivating typographic experiences using responsive and dynamic typography with changing fonts, let us dissect the ideas:&lt;/p&gt;

&lt;p&gt;Variables in Fonts: Variable fonts are a single font file with several variants of a &lt;a href="https://www.myfonts.com/pages/fontscom-learning-fontology-level-1-type-families-about-typeface-families" rel="noopener noreferrer"&gt;&lt;code&gt;typeface&lt;/code&gt;&lt;/a&gt;, including &lt;code&gt;wght&lt;/code&gt; and special properties &lt;code&gt;MIDL&lt;/code&gt; and &lt;code&gt;CONT&lt;/code&gt;. Variable fonts give more freedom and efficiency in typography design than conventional fonts, which demand distinct files for every style and enable fluid transitions between these variants.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Responsive Typography:&lt;/strong&gt; Designing text to fit easily into many screen sizes, resolutions, and viewing environments is known as responsive typography. From big desktop computers to cellphones and everything in between, this guarantees the best readability and aesthetics across many devices. Dynamic font size, line spacing, and other typographic changes help responsive typography improve the user experience and accessibility.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Dynamic Typography:&lt;/strong&gt; Dynamic typography enhances responsive typography by incorporating interaction and animation into typographic design. JavaScript and CSS (Cascading Style Sheets) help designers develop typefaces that suit content changes, user interactions, or scrolling behavior. Dynamic typography uses components like &lt;code&gt;wght&lt;/code&gt;, &lt;code&gt;MIDL&lt;/code&gt;, and &lt;code&gt;CONT&lt;/code&gt; to generate visual attractiveness and interactivity, guiding users' attention and catching them.&lt;/p&gt;

&lt;p&gt;Designers create rich, versatile, and immersive online typographic experiences by combining dynamic and flexible typography methods with varying fonts. Whether it's dynamically changing typeface in response to user activity, animating text elements to highlight important information, or adjusting font weight and size based on screen dimensions, this approach offers many chances for creativity and invention in digital design.&lt;/p&gt;

&lt;p&gt;The various font properties of &lt;code&gt;Kyiv Sans&lt;/code&gt; allow designers to create intriguing and flawless typographic transitions. This enhances the interaction and user-friendliness of web materials by increasing their aesthetic appeal and utility.&lt;/p&gt;

&lt;h2&gt;
  
  
  Understanding Variable Font Properties
&lt;/h2&gt;

&lt;p&gt;Various typefaces offer a range of new characteristics that are absent in traditional static fonts. Knowing these characteristics is necessary to use the full potential of changeable typefaces. These are some basic ones:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Weight (&lt;code&gt;wght&lt;/code&gt;):&lt;/strong&gt; By varying their &lt;code&gt;wght&lt;/code&gt; along a continuous axis, variable typefaces enable seamless transitions between several thickness levels. Designers can indicate a range of weights within a single font file, from light to ultra-bold and, all points in between.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Middle Layer Effect (&lt;code&gt;MIDL&lt;/code&gt;):&lt;/strong&gt; This custom axis lets designers change a middle layer effect within the &lt;a href="https://www.myfonts.com/pages/fontscom-learning-fontology-level-1-type-families-about-typeface-families" rel="noopener noreferrer"&gt;&lt;code&gt;typeface&lt;/code&gt;&lt;/a&gt;. This can give the text a distinctive visual style, as well as an extra degree of design freedom and inventiveness.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Contrast (CONT):&lt;/strong&gt; Another custom axis is &lt;code&gt;CONT&lt;/code&gt;, which lets the font's contrast be changed. By dynamically altering the contrast depending on design requirements, this can help maximize the readability and visual attractiveness of the text.&lt;/p&gt;

&lt;p&gt;Understanding and applying these qualities will help designers produce visually striking typefaces. With its varied font characteristics, &lt;code&gt;Kyiv Sans&lt;/code&gt; presents special customizing choices that improve the usability and appearance of web typography.&lt;/p&gt;

&lt;h3&gt;
  
  
  Overview of additional axes and variations available in variable fonts
&lt;/h3&gt;

&lt;p&gt;Beyond the conventional weight, width, and optical size modifications, variable fonts provide a broad spectrum of personalizing choices. Below is a summary of the axes and variants that might be available:&lt;/p&gt;

&lt;p&gt;Several &lt;a href="https://learn.microsoft.com/en-us/typography/opentype/spec/dvaraxisreg" rel="noopener noreferrer"&gt;registered axes&lt;/a&gt; that variable font designers may use are defined by the OpenType specification:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_fonts/Variable_fonts_guide#width" rel="noopener noreferrer"&gt;Width&lt;/a&gt; (&lt;code&gt;wdth&lt;/code&gt;): This axis controls the horizontal expansion or condensation of the font, enabling designers to modify the width of characters. By adjusting this axis, designers can create fonts that appear narrower or wider without altering the overall height, allowing for a flexible range of condensed to extended styles.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_fonts/Variable_fonts_guide#slant" rel="noopener noreferrer"&gt;Slant&lt;/a&gt; (&lt;code&gt;slnt&lt;/code&gt;): This axis allows designers to apply an italic-like slant to the characters without altering the letterforms’ structure. The slant axis typically mimics the effect of traditional italics but retains the upright letterforms, making it useful for creating stylistic variations.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_fonts/Variable_fonts_guide#italic" rel="noopener noreferrer"&gt;Italic&lt;/a&gt; (&lt;code&gt;ital&lt;/code&gt;): The italic axis switches between upright and italic versions of a typeface. Unlike the slant axis, which only tilts the characters, the italic axis involves a complete redesign of the characters to reflect the cursive nature of true italics, providing a more authentic italic style.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_fonts/Variable_fonts_guide#optical_size" rel="noopener noreferrer"&gt;Optical Size&lt;/a&gt; (&lt;code&gt;opsz&lt;/code&gt;): This axis adjusts the font’s design to optimize readability at different sizes. For example, smaller sizes may feature thicker strokes and more open counters for better legibility, while larger sizes can be more refined and delicate. This axis is particularly useful for responsive typography across various media.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_fonts/Variable_fonts_guide#grade" rel="noopener noreferrer"&gt;Grade&lt;/a&gt; (&lt;code&gt;GRAD&lt;/code&gt;): The grade axis allows subtle adjustments to the font’s stroke weight without affecting the overall spacing. It is useful for improving readability in different print or screen environments, where a slight increase or decrease in weight can enhance contrast and clarity.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://fonts.google.com/knowledge/glossary/contrast" rel="noopener noreferrer"&gt;Contrast&lt;/a&gt; (&lt;code&gt;CNTR&lt;/code&gt;): This axis modifies the contrast between thick and thin strokes within a font. By adjusting the contrast, designers can create fonts with varying levels of emphasis and visual impact, from low-contrast, humanist styles to high-contrast, modern designs.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;a href="https://fonts.google.com/knowledge/glossary/x_height" rel="noopener noreferrer"&gt;X-height&lt;/a&gt; (&lt;code&gt;xhgt&lt;/code&gt;): This axis adjusts the height of lowercase letters in relation to the font’s capital letters. Increasing the x-height can improve legibility at small sizes or create a more modern appearance while decreasing it can evoke a more traditional or formal feel.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Apart from the registered axes, variable font creators may specify their own &lt;a href="https://v-fonts.com/" rel="noopener noreferrer"&gt;custom axes&lt;/a&gt;. Regarding &lt;code&gt;Kyiv Sans&lt;/code&gt;: these comprise:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;Middle Layer Effect (&lt;code&gt;MIDL&lt;/code&gt;): This custom axis gives designers more design versatility and allows them to change a specific middle layer effect inside the typeface, thereby adding original style aspects.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Contrast (&lt;code&gt;CONT&lt;/code&gt;): This custom axis helps to control the contrast between thick and thin strokes in the letterforms. Designers can dynamically change this characteristic to achieve a variety of degrees of typographic expressiveness, from subdued contrasts to more obvious variances.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Aside from the registered axes, the option to construct new axes allows font designers to achieve a high degree of customization and sophisticated control over a font’s appearance and traits. Custom axes like &lt;code&gt;MIDL&lt;/code&gt; and &lt;code&gt;CONT&lt;/code&gt;, for instance, enable designers to tailor the font’s special qualities, resulting in flexible and expressive typography. These customizations, combined with variable font registration, offer numerous ways to create diverse typographic effects. For example, the Middle Layer Effect (&lt;code&gt;MIDL&lt;/code&gt;) axis lets designers alter a unique middle layer within the typeface, adding distinctive visual qualities that enhance artistic freedom. The Contrast (&lt;code&gt;CONT&lt;/code&gt;) axis, on the other hand, controls the variation between thick and thin strokes, allowing for dynamic adjustments that range from subtle to pronounced contrasts. By interacting with axes like Weight and Middle Layer Effect, designers can create text with varying thicknesses and unique styles, achieving precise control over the typeface’s appearance. Similarly, combining variations in Weight and Contrast enables the creation of text with different degrees of boldness and stroke contrast, balancing visual impact with readability. These examples demonstrate the unmatched freedom that both registered and custom axes provide, empowering designers to align typefaces with their specific aesthetic preferences and design objectives.&lt;/p&gt;

&lt;h2&gt;
  
  
  Implementing Variable Fonts in CSS
&lt;/h2&gt;

&lt;p&gt;Now that you're enthralled with the possibilities of changeable fonts, let's investigate how to apply them in CSS-based web projects. CSS offers the means to properly use these adaptable typefaces' capabilities. Define the font first with &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face" rel="noopener noreferrer"&gt;&lt;code&gt;@font-face&lt;/code&gt;&lt;/a&gt;, which lets you provide the varying font file and its characteristics. Once the font is set, you can dynamically change the font's axes using different CSS attributes, thus maximizing the possibilities provided by varying fonts.&lt;/p&gt;

&lt;h3&gt;
  
  
  Obtaining the font
&lt;/h3&gt;

&lt;p&gt;First, we must download the variable font we want for our project.&lt;br&gt;
A few websites on the internet allow us to access varying font files. Some of the most frequently used font websites are as follows:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://typenetwork.com/" rel="noopener noreferrer"&gt;Type Network&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.fontsquirrel.com/" rel="noopener noreferrer"&gt;Font Squirrel&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://fonts.adobe.com/" rel="noopener noreferrer"&gt;Adobe Fonts&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.fontspring.com/" rel="noopener noreferrer"&gt;Font Spring&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://fonts.google.com/" rel="noopener noreferrer"&gt;Google fonts&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://v-fonts.com" rel="noopener noreferrer"&gt;Vfonts.com&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;For this example, we’ll go to &lt;a href="https://v-fonts.com/fonts/kyivtype" rel="noopener noreferrer"&gt;Vfonts.com&lt;/a&gt; to download our &lt;code&gt;Kyiv Sans&lt;/code&gt; variable font. The &lt;a href="https://www.fontspace.com/category/ttf" rel="noopener noreferrer"&gt;&lt;code&gt;ttf&lt;/code&gt;&lt;/a&gt; or &lt;a href="https://www.w3.org/TR/WOFF2/" rel="noopener noreferrer"&gt;&lt;code&gt;woff2&lt;/code&gt;&lt;/a&gt; file format works fine, but we'll be using a &lt;code&gt;ttf&lt;/code&gt; in this demonstration. If you need to convert your font file from &lt;code&gt;ttf&lt;/code&gt; to &lt;code&gt;woff2&lt;/code&gt;, then head to &lt;a href="https://everythingfonts.com" rel="noopener noreferrer"&gt;everythingfonts.com&lt;/a&gt;:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F97o7584i2utyypoytef4.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F97o7584i2utyypoytef4.png" alt="vfont2" width="800" height="405"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The screenshot above shows what you'll see when you arrive at Vfont.&lt;/p&gt;

&lt;p&gt;We divide the project into the following steps:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Navigate to vfont: Visit the website where variable font resources are available.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Select Kyiv* Type: Choose the Kyiv* Type font, which will redirect you to &lt;a href="https://www.behance.net/gallery/90690285/KyivType-variable-superfamily" rel="noopener noreferrer"&gt;Behance.net&lt;/a&gt; where the font is hosted.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Access the Download Link: On the Behance page, scroll all the way down to find a link to download the font.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Download from Google Drive: Click on the download link, which will take you to a Google Drive folder. Download the font file from there.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Unzip the File: After downloading, unzip the file to access its contents.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Review Font Options: The unzipped folder contains several options to choose from.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Icons&lt;/li&gt;
&lt;li&gt;No variable&lt;/li&gt;
&lt;li&gt;Variable&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Select the variable font: Focus on the files that include the variable font.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Serif&lt;/li&gt;
&lt;li&gt;Tilting&lt;/li&gt;
&lt;li&gt;Sans&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Use the Sans Font: Set up and use the Sans version of the font. Note that the Sans font weight file is 360 KB, which is equivalent to using eight non-variable font files.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Evaluate the trade-off: Consider if the use of variable fonts is worthwhile for your project. If you only need regular, bold, and italic styles, it might not be necessary to use variable fonts. However, if you require advanced control over variations, variable fonts can be very beneficial.&lt;/p&gt;&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Note: These files above are in &lt;code&gt;TTF&lt;/code&gt; format.&lt;/p&gt;

&lt;p&gt;Now we're going to head to &lt;a href="https://code.visualstudio.com/" rel="noopener noreferrer"&gt;VSCode&lt;/a&gt;, where we'll be using a &lt;a href="https://vitejs.dev/guide/#scaffolding-your-first-vite-project" rel="noopener noreferrer"&gt;&lt;code&gt;vanilla vite&lt;/code&gt;&lt;/a&gt; project.&lt;br&gt;
To begin working on the project, you must install the necessary packages. You have to follow the steps below:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;&lt;p&gt;Open a new &lt;code&gt;terminal&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Run the command&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight shell"&gt;&lt;code&gt;npm create vite@latest
&lt;/code&gt;&lt;/pre&gt;




&lt;/li&gt;

&lt;li&gt;&lt;p&gt;Name your project.&lt;/p&gt;&lt;/li&gt;

&lt;li&gt;&lt;p&gt;Name your package.&lt;/p&gt;&lt;/li&gt;

&lt;li&gt;&lt;p&gt;Select a &lt;code&gt;Vanilla&lt;/code&gt; framework.&lt;/p&gt;&lt;/li&gt;

&lt;li&gt;&lt;p&gt;Select the JavaScript variant.&lt;/p&gt;&lt;/li&gt;

&lt;li&gt;&lt;p&gt;Running &lt;code&gt;npm install&lt;/code&gt; will help you negotiate into the project and install the necessary modules.&lt;/p&gt;&lt;/li&gt;

&lt;li&gt;

&lt;p&gt;After setting up the dependencies, use the following command to launch the application:&lt;br&gt;
&lt;/p&gt;

&lt;pre class="highlight shell"&gt;&lt;code&gt;npm run dev
&lt;/code&gt;&lt;/pre&gt;




&lt;/li&gt;

&lt;li&gt;&lt;p&gt;Visit &lt;code&gt;&lt;a href="http://localhost:your-port-number" rel="noopener noreferrer"&gt;http://localhost:your-port-number&lt;/a&gt;&lt;/code&gt; to access the running program on your browser.&lt;/p&gt;&lt;/li&gt;

&lt;/ol&gt;

&lt;p&gt;Once we complete our project, we will have a wealth of mock code that we can modify to build our intended application. The downloaded variable font should be dropped into a &lt;code&gt;font&lt;/code&gt; folder, which will be dropped in the &lt;code&gt;public&lt;/code&gt; folder. We’ll be replacing all the unnecessary mock code in &lt;code&gt;style.css&lt;/code&gt;, &lt;code&gt;main.js&lt;/code&gt;,  and &lt;code&gt;index.html&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;index.html&lt;/code&gt; code should look something like this:&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="cp"&gt;&amp;lt;!doctype html&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;html&lt;/span&gt; &lt;span class="na"&gt;lang=&lt;/span&gt;&lt;span class="s"&gt;"en"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;charset=&lt;/span&gt;&lt;span class="s"&gt;"UTF-8"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"viewport"&lt;/span&gt; &lt;span class="na"&gt;content=&lt;/span&gt;&lt;span class="s"&gt;"width=device-width, initial-scale=1.0"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;

    &lt;span class="nt"&gt;&amp;lt;title&amp;gt;&lt;/span&gt;Variable font&lt;span class="nt"&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"app"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;type=&lt;/span&gt;&lt;span class="s"&gt;"module"&lt;/span&gt; &lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"/main.js"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;From the code above, we're setting up a simple HTML wrapper for our project where the JavaScript will render content in the &lt;code&gt;&amp;lt;div id="app"&amp;gt;&amp;lt;/div&amp;gt;&lt;/code&gt; element.&lt;/p&gt;

&lt;p&gt;The &lt;code&gt;main.js&lt;/code&gt; code should look something like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;./style.css&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;querySelector&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;#app&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;innerHTML&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;`
  &amp;lt;div&amp;gt;
    &amp;lt;h1 class="variable-font"&amp;gt;
      I am&amp;lt;br&amp;gt;
      Variable font&amp;lt;br&amp;gt;
      and I'm awesome
    &amp;lt;/h1&amp;gt;
  &amp;lt;/div&amp;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 is where we use &lt;code&gt;document.querySelector()&lt;/code&gt; to add content to the element we insert our content into using the id: &lt;code&gt;#&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;And the &lt;code&gt;style.css&lt;/code&gt; code should look something like this:&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="nt"&gt;body&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;font-family&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;'Kyiv Sans'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;@font-face&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;font-family&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;'Kyiv Sans'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;src&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sx"&gt;url('/font/KyivTypeSans-VarGX.ttf')&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;font-weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="m"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;font-display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;swap&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nt"&gt;h1&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#bd0c0c&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100vh&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;grid&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;place-content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;margin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;text-align&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.variable-font&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;font-family&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;'Kyiv Sans'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;5rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;line-height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1.1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;font-weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;font-variation-settings&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
   &lt;span class="s2"&gt;'wght'&lt;/span&gt; &lt;span class="m"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;'CONT'&lt;/span&gt; &lt;span class="m"&gt;250&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;'MIDL'&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;transition&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;font-variation-settings&lt;/span&gt; &lt;span class="m"&gt;500ms&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;  
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.variable-font&lt;/span&gt;&lt;span class="nd"&gt;:hover&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;font-weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;font-variation-settings&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="s2"&gt;'wght'&lt;/span&gt; &lt;span class="m"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;'CONT'&lt;/span&gt; &lt;span class="m"&gt;250&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;'MIDL'&lt;/span&gt; &lt;span class="m"&gt;-1000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now, let's explain what's going on in the code above:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Setting the Default Font for the Body:&lt;/strong&gt;&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="nt"&gt;body&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;font-family&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;'Kyiv Sans'&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;ul&gt;
&lt;li&gt;
&lt;strong&gt;Purpose&lt;/strong&gt;: This sets the default font for the entire document to 'Kyiv Sans'.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Impact&lt;/strong&gt;: All text elements within the body will inherit this font unless overridden by more specific styles.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Defining the Custom Font:&lt;/strong&gt;&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;@font-face&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;font-family&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;'Kyiv Sans'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;src&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sx"&gt;url('/font/KyivTypeSans-VarGX.ttf')&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;font-weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="m"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;font-display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;swap&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;ul&gt;
&lt;li&gt;
&lt;strong&gt;Purpose&lt;/strong&gt;: The &lt;code&gt;@font-face&lt;/code&gt; rule allows you to define a custom font.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Font Name&lt;/strong&gt;: The font is named 'Kyiv Sans'.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Source&lt;/strong&gt;: The font file is located at &lt;code&gt;/font/KyivTypeSans-VarGX.ttf&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Font Weight Range&lt;/strong&gt;: This font supports a range of weights from 0 to 1000, making it a variable font.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Font Display&lt;/strong&gt;: &lt;code&gt;swap&lt;/code&gt; ensures that text is displayed immediately using a fallback font until the custom font loads.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Styling the &lt;code&gt;&amp;lt;h1&amp;gt;&lt;/code&gt; Element:&lt;/strong&gt;&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="nt"&gt;h1&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#bd0c0c&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100vh&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;grid&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;place-content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;margin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;text-align&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Color&lt;/strong&gt;: Sets the text color to &lt;code&gt;#bd0c0c&lt;/code&gt;, a shade of red.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Height&lt;/strong&gt;: The height is set to &lt;code&gt;100vh&lt;/code&gt;, making the &lt;code&gt;&amp;lt;h1&amp;gt;&lt;/code&gt; element span the full height of the viewport.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Display&lt;/strong&gt;: &lt;code&gt;grid&lt;/code&gt; is used for layout, allowing the use of grid properties.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Centering Content&lt;/strong&gt;: &lt;code&gt;place-content: center&lt;/code&gt; centers the content both vertically and horizontally.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Margin&lt;/strong&gt;: Margin is set to &lt;code&gt;0&lt;/code&gt; to remove any default spacing around the &lt;code&gt;&amp;lt;h1&amp;gt;&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Text Alignment&lt;/strong&gt;: The text is centered horizontally.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Styling the &lt;code&gt;.variable-font&lt;/code&gt; Class:&lt;/strong&gt;&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="nc"&gt;.variable-font&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;font-family&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;'Kyiv Sans'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;5rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;line-height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1.1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;font-weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;font-variation-settings&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
   &lt;span class="s2"&gt;'wght'&lt;/span&gt; &lt;span class="m"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;'CONT'&lt;/span&gt; &lt;span class="m"&gt;250&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;'MIDL'&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;transition&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;font-variation-settings&lt;/span&gt; &lt;span class="m"&gt;500ms&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;ul&gt;
&lt;li&gt;
&lt;strong&gt;Font Family&lt;/strong&gt;: Uses 'Kyiv Sans' for the text.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Font Size&lt;/strong&gt;: Sets the font size to &lt;code&gt;5rem&lt;/code&gt; (relative to the root element’s font size).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Line Height&lt;/strong&gt;: &lt;code&gt;1.1&lt;/code&gt; ensures a slight spacing between lines.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Font Weight&lt;/strong&gt;: Initially set to &lt;code&gt;100&lt;/code&gt;.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Font Variation Settings&lt;/strong&gt;: Utilizes custom variation settings for the variable font:

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;'wght'&lt;/code&gt; controls the weight (initially 100).&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;'CONT'&lt;/code&gt; and &lt;code&gt;'MIDL'&lt;/code&gt; are custom axes for this font, initially set to 250 and 0, respectively.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;Transition&lt;/strong&gt;: Smoothly transitions the font variation settings over 500 milliseconds.&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;Adding Hover Effect for &lt;code&gt;.variable-font&lt;/code&gt;:&lt;/strong&gt;&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="nc"&gt;.variable-font&lt;/span&gt;&lt;span class="nd"&gt;:hover&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;font-weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;font-variation-settings&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="s2"&gt;'wght'&lt;/span&gt; &lt;span class="m"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;'CONT'&lt;/span&gt; &lt;span class="m"&gt;250&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;'MIDL'&lt;/span&gt; &lt;span class="m"&gt;-1000&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;ul&gt;
&lt;li&gt;
&lt;strong&gt;Font Weight on Hover&lt;/strong&gt;: Changes to &lt;code&gt;1000&lt;/code&gt; when the element is hovered over.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Font Variation Settings on Hover&lt;/strong&gt;: Updates the variation settings to:

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;'wght'&lt;/code&gt; to &lt;code&gt;1000&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;'CONT'&lt;/code&gt; remains &lt;code&gt;250&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;'MIDL'&lt;/code&gt; changes to &lt;code&gt;-1000&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;

&lt;strong&gt;Effect&lt;/strong&gt;: Creates a dynamic and interactive visual effect when the user hovers over the text, highlighting the flexibility of the variable font.&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;At the end of it we'll have our Result looking somewhat like this;&lt;br&gt;
&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6y8gogr9dzd45frjyzp2.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6y8gogr9dzd45frjyzp2.gif" alt="Variablefont" width="600" height="321"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h2&gt;
  
  
  Creating Responsive Typography with Variable Fonts
&lt;/h2&gt;

&lt;p&gt;By allowing designers to achieve perfect adaptation across many devices and screen sizes, responsive typography with varied fonts transforms online design. Unmatched versatility comes from variable fonts, which allow constant changes in font attributes including weight, width, and contrast within a single font file. Designers can dynamically change these font attributes to improve readability and aesthetic appeal using CSS and &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_media_queries/Using_media_queries" rel="noopener noreferrer"&gt;media queries&lt;/a&gt;, ensuring that text looks best on any device, from desktop monitors to cellphones. Because a single variable font can replace several stationary font files, it reduces the need for extensive font loading and improves website performance. This flexibility not only improves the user experience but also streamlines the design process. Without responsive typography—which becomes more appealing, efficient, and accessible with different fonts—modern web design cannot exist.&lt;/p&gt;
&lt;h3&gt;
  
  
  Media Queries: The Masters of Screen Size Adaptation
&lt;/h3&gt;

&lt;p&gt;Media queries are a cornerstone of responsive web design, acting as the masters of screen size adaptation. Based on the features of the user's device—such as screen width, height, resolution, and orientation—they let designers apply particular CSS styles. Media searches help designers make sure a website looks and operates as best it can across a variety of devices, from laptops and desktop monitors to smartphones and tablets.&lt;/p&gt;

&lt;p&gt;Media queries' power resides in their capacity to produce flexible and fluid layouts that fit various screen sizes. Media queries let a designer change font sizes, alter grid layouts, and even hide or show certain items based on the &lt;code&gt;viewport&lt;/code&gt; measurements. This ensures that the material maintains its aesthetic appeal and accessibility, regardless of the device in use.&lt;/p&gt;

&lt;p&gt;Media queries define breakpoints—specific places at which the layout adjusts to fit varying screen sizes. Targeting different devices, these breakpoints are set using &lt;code&gt;min-width&lt;/code&gt;, &lt;code&gt;max-width&lt;/code&gt;, and other CSS characteristics. For example, a media query might specify the use of a mobile-friendly layout for screen widths of 768 pixels or less and a different layout for larger displays.&lt;/p&gt;

&lt;p&gt;Incorporating media searches into web design improves accessibility and user experience. On all platforms, media queries assist in developing inclusive digital experiences by guaranteeing that text is readable, navigation is intuitive, and material is well organized. Any web designer hoping to create responsive, adaptable, and user-friendly websites must first learn media queries in the era of varied device use.&lt;/p&gt;

&lt;p&gt;Here's an 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="nt"&gt;body&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;font-family&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;'Kyiv Sans'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="k"&gt;@font-face&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;font-family&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;'Kyiv Sans'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;src&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sx"&gt;url('/font/KyivTypeSans-VarGX.ttf')&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;font-weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="m"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;font-display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;swap&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nt"&gt;h1&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#bd0c0c&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100vh&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;grid&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;place-content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;margin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;text-align&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.variable-font&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;font-family&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;'Kyiv Sans'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;5rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;line-height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1.1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;font-weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;font-variation-settings&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
   &lt;span class="s2"&gt;'wght'&lt;/span&gt; &lt;span class="m"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;'CONT'&lt;/span&gt; &lt;span class="m"&gt;250&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;'MIDL'&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;transition&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;font-variation-settings&lt;/span&gt; &lt;span class="m"&gt;500ms&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.variable-font&lt;/span&gt;&lt;span class="nd"&gt;:hover&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;font-weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;font-variation-settings&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="s2"&gt;'wght'&lt;/span&gt; &lt;span class="m"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;'CONT'&lt;/span&gt; &lt;span class="m"&gt;250&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;'MIDL'&lt;/span&gt; &lt;span class="m"&gt;-1000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c"&gt;/* Media Queries */&lt;/span&gt;
&lt;span class="c"&gt;/* Small screens */&lt;/span&gt;
&lt;span class="k"&gt;@media&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;600px&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nc"&gt;.variable-font&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;3rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="py"&gt;font-variation-settings&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
     &lt;span class="s2"&gt;'wght'&lt;/span&gt; &lt;span class="m"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;'CONT'&lt;/span&gt; &lt;span class="m"&gt;150&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;'MIDL'&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nc"&gt;.variable-font&lt;/span&gt;&lt;span class="nd"&gt;:hover&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;font-weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;900&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="py"&gt;font-variation-settings&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="s2"&gt;'wght'&lt;/span&gt; &lt;span class="m"&gt;900&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;'CONT'&lt;/span&gt; &lt;span class="m"&gt;150&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;'MIDL'&lt;/span&gt; &lt;span class="m"&gt;-900&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nt"&gt;h1&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;2rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c"&gt;/* Medium screens */&lt;/span&gt;
&lt;span class="k"&gt;@media&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;601px&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="nc"&gt;.variable-font&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;4rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="py"&gt;font-variation-settings&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
     &lt;span class="s2"&gt;'wght'&lt;/span&gt; &lt;span class="m"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;'CONT'&lt;/span&gt; &lt;span class="m"&gt;200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;'MIDL'&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nc"&gt;.variable-font&lt;/span&gt;&lt;span class="nd"&gt;:hover&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;font-weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;950&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="py"&gt;font-variation-settings&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="s2"&gt;'wght'&lt;/span&gt; &lt;span class="m"&gt;950&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;'CONT'&lt;/span&gt; &lt;span class="m"&gt;200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;'MIDL'&lt;/span&gt; &lt;span class="m"&gt;-950&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nt"&gt;h1&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;3rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c"&gt;/* Large screens */&lt;/span&gt;
&lt;span class="k"&gt;@media&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;1201px&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nc"&gt;.variable-font&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;5rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="py"&gt;font-variation-settings&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
     &lt;span class="s2"&gt;'wght'&lt;/span&gt; &lt;span class="m"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;'CONT'&lt;/span&gt; &lt;span class="m"&gt;250&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;'MIDL'&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nc"&gt;.variable-font&lt;/span&gt;&lt;span class="nd"&gt;:hover&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;font-weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="py"&gt;font-variation-settings&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="s2"&gt;'wght'&lt;/span&gt; &lt;span class="m"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;'CONT'&lt;/span&gt; &lt;span class="m"&gt;250&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;'MIDL'&lt;/span&gt; &lt;span class="m"&gt;-1000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nt"&gt;h1&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;4rem&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;In this example, we used media queries to adjust the &lt;code&gt;font-variation-settings&lt;/code&gt; and weight of our font based on screen size. For devices with a maximum width of &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/font-size" rel="noopener noreferrer"&gt;&lt;code&gt;600px&lt;/code&gt;&lt;/a&gt;, the font size is reduced to &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/font-size" rel="noopener noreferrer"&gt;&lt;code&gt;3rem&lt;/code&gt;&lt;/a&gt;. The weight and other variations are adjusted accordingly for &lt;code&gt;:hover&lt;/code&gt; effects, For devices with a width between &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/font-size" rel="noopener noreferrer"&gt;&lt;code&gt;601px&lt;/code&gt;&lt;/a&gt; and &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/font-size" rel="noopener noreferrer"&gt;&lt;code&gt;1200px&lt;/code&gt;&lt;/a&gt;, the font size is set to &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/font-size" rel="noopener noreferrer"&gt;&lt;code&gt;4rem&lt;/code&gt;&lt;/a&gt;, with adjusted weight and variations. For devices with a width of &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/font-size" rel="noopener noreferrer"&gt;&lt;code&gt;1201px&lt;/code&gt;&lt;/a&gt; and above, the font size is &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/font-size" rel="noopener noreferrer"&gt;&lt;code&gt;5rem&lt;/code&gt;&lt;/a&gt;, maintaining the original settings.&lt;br&gt;
These media queries ensure that the font adapts to different screen sizes, improving readability and the user experience across various devices.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqeuedz5sbh9x15zi1v4r.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqeuedz5sbh9x15zi1v4r.PNG" alt="small screen" width="518" height="951"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The image above shows the display for Small screens&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft1i0yip4sj1bnitxf2zc.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Ft1i0yip4sj1bnitxf2zc.PNG" alt="med screen" width="549" height="796"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The image above shows the display for Medium screens&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj1vm4chc2tzsa7fnm3a4.PNG" class="article-body-image-wrapper"&gt;&lt;img src="https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fj1vm4chc2tzsa7fnm3a4.PNG" alt="large screen" width="800" height="581"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The image above shows the display for Large screens&lt;/p&gt;
&lt;h3&gt;
  
  
  Viewport Units: Making Layouts Fluid
&lt;/h3&gt;

&lt;p&gt;Viewport units are a powerful tool in modern web design, enabling the creation of fluid and responsive layouts that adapt seamlessly to different screen sizes. Viewport units include &lt;a href="https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Values_and_units#numbers_lengths_and_percentages" rel="noopener noreferrer"&gt;&lt;code&gt;vw&lt;/code&gt;&lt;/a&gt; (viewport width) and &lt;a href="https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Values_and_units#numbers_lengths_and_percentages" rel="noopener noreferrer"&gt;&lt;code&gt;vh&lt;/code&gt;&lt;/a&gt; (viewport height), which are relative to the dimensions of the browser's viewport. One &lt;a href="https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Values_and_units#numbers_lengths_and_percentages" rel="noopener noreferrer"&gt;&lt;code&gt;vw&lt;/code&gt;&lt;/a&gt; equals 1% of the viewport's width, and one &lt;a href="https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Values_and_units#numbers_lengths_and_percentages" rel="noopener noreferrer"&gt;&lt;code&gt;vh&lt;/code&gt;&lt;/a&gt; equals 1% of the viewport's height. These units help designers guarantee that elements scale according to the size of the user's screen, therefore producing a more dynamic and adaptable design. Setting the font size, padding, or margins in viewport units, for example, lets text and objects resize automatically, therefore preserving a consistent look on several devices. This adaptability enhances the user experience by ensuring content remains readable and aesthetically pleasing, regardless of the site's display on a large desktop monitor or a small mobile screen. Viewport units let designers create adaptable layouts that move easily to fit the always-changing terrain of digital gadgets.&lt;/p&gt;

&lt;p&gt;Here's an example of how to use &lt;code&gt;vw&lt;/code&gt; to adjust font size based on viewport width:&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="nt"&gt;body&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;font-family&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;'Kyiv Sans'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="k"&gt;@font-face&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;font-family&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;'Kyiv Sans'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;src&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="sx"&gt;url('/font/KyivTypeSans-VarGX.ttf')&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;font-weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="m"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;font-display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;swap&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nt"&gt;h1&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#bd0c0c&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100vh&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;grid&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;place-content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;margin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;text-align&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nc"&gt;.variable-font&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;font-family&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;'Kyiv Sans'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;5vw&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
    &lt;span class="c"&gt;/* Using viewport width for font size */&lt;/span&gt;
  &lt;span class="nl"&gt;line-height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1.1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;font-weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;font-variation-settings&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
   &lt;span class="s2"&gt;'wght'&lt;/span&gt; &lt;span class="m"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;'CONT'&lt;/span&gt; &lt;span class="m"&gt;250&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;'MIDL'&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;transition&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;font-variation-settings&lt;/span&gt; &lt;span class="m"&gt;500ms&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="nc"&gt;.variable-font&lt;/span&gt;&lt;span class="nd"&gt;:hover&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;font-weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;font-variation-settings&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="s2"&gt;'wght'&lt;/span&gt; &lt;span class="m"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;'CONT'&lt;/span&gt; &lt;span class="m"&gt;250&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;'MIDL'&lt;/span&gt; &lt;span class="m"&gt;-1000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c"&gt;/* Media Queries */&lt;/span&gt;
&lt;span class="c"&gt;/* Small screens */&lt;/span&gt;
&lt;span class="k"&gt;@media&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;600px&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nc"&gt;.variable-font&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;8vw&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
      &lt;span class="c"&gt;/* Larger font size for small screens */&lt;/span&gt;
    &lt;span class="py"&gt;font-variation-settings&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
     &lt;span class="s2"&gt;'wght'&lt;/span&gt; &lt;span class="m"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;'CONT'&lt;/span&gt; &lt;span class="m"&gt;150&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;'MIDL'&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="nc"&gt;.variable-font&lt;/span&gt;&lt;span class="nd"&gt;:hover&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;font-weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;900&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="py"&gt;font-variation-settings&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="s2"&gt;'wght'&lt;/span&gt; &lt;span class="m"&gt;900&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;'CONT'&lt;/span&gt; &lt;span class="m"&gt;150&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;'MIDL'&lt;/span&gt; &lt;span class="m"&gt;-900&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="nt"&gt;h1&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;6vw&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
      &lt;span class="c"&gt;/* Adjust h1 size for small screens */&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="c"&gt;/* Medium screens */&lt;/span&gt;
&lt;span class="k"&gt;@media&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;601px&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="nc"&gt;.variable-font&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;6vw&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
      &lt;span class="c"&gt;/* Adjust font size for medium screens */&lt;/span&gt;
    &lt;span class="py"&gt;font-variation-settings&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
     &lt;span class="s2"&gt;'wght'&lt;/span&gt; &lt;span class="m"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;'CONT'&lt;/span&gt; &lt;span class="m"&gt;200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;'MIDL'&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nc"&gt;.variable-font&lt;/span&gt;&lt;span class="nd"&gt;:hover&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;font-weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;950&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="py"&gt;font-variation-settings&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="s2"&gt;'wght'&lt;/span&gt; &lt;span class="m"&gt;950&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;'CONT'&lt;/span&gt; &lt;span class="m"&gt;200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;'MIDL'&lt;/span&gt; &lt;span class="m"&gt;-950&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="nt"&gt;h1&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;5vw&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
      &lt;span class="c"&gt;/* Adjust h1 size for medium screens */&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c"&gt;/* Large screens */&lt;/span&gt;
&lt;span class="k"&gt;@media&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;1201px&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nc"&gt;.variable-font&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;5vw&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
      &lt;span class="c"&gt;/* Adjust font size for large screens */&lt;/span&gt;
    &lt;span class="py"&gt;font-variation-settings&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
     &lt;span class="s2"&gt;'wght'&lt;/span&gt; &lt;span class="m"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;'CONT'&lt;/span&gt; &lt;span class="m"&gt;250&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;'MIDL'&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="nc"&gt;.variable-font&lt;/span&gt;&lt;span class="nd"&gt;:hover&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;font-weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="py"&gt;font-variation-settings&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
      &lt;span class="s2"&gt;'wght'&lt;/span&gt; &lt;span class="m"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;'CONT'&lt;/span&gt; &lt;span class="m"&gt;250&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;'MIDL'&lt;/span&gt; &lt;span class="m"&gt;-1000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="nt"&gt;h1&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;4vw&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
      &lt;span class="c"&gt;/* Adjust h1 size for large screens */&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;In this example, from the code above, the font-size property of &lt;code&gt;.variable-font&lt;/code&gt; is set using viewport width &lt;a href="https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Values_and_units#numbers_lengths_and_percentages" rel="noopener noreferrer"&gt;&lt;code&gt;vw&lt;/code&gt;&lt;/a&gt; units, making the text size responsive to the viewport's width.&lt;/p&gt;

&lt;p&gt;We can combine media searches and viewport units with varying font characteristics to create truly responsive typography that elegantly fits every device or screen size. This enables us to provide an outstanding user experience, independent of the method of access someone chooses for our website.&lt;/p&gt;

&lt;h2&gt;
  
  
  Advanced Typographic Effects with Variable Fonts
&lt;/h2&gt;

&lt;p&gt;Variable fonts enable designers to create highly customized and dynamic text styles by opening up a new field of complex typographic effects. Designers can now create seamless transitions and unusual visual effects that were previously difficult with stationary fonts by continuously adjusting characteristics such as weight, width, and custom axes. The weight, contrast, and midline dynamically can be changed by adjusting the font, offering complex control over the text look. This adaptability is very strong in responsive design, in which typefaces can easily adjust to various screen sizes and orientations. Moreover, interactive animations allow text to respond to user actions such as hovering or clicking, producing intriguing and immersive encounters. Viewport units, combined with varying font characteristics, ensure that typography remains fluid and scalable, improving readability and appearance on all kinds of devices. Using these sophisticated features, designers can create visually striking digital material by stretching the possibilities of conventional typography. Let's explore some fascinating methods for stretching the bounds of online typography:&lt;/p&gt;

&lt;h3&gt;
  
  
  Fluid Typography
&lt;/h3&gt;

&lt;p&gt;Fluid typography is a design method whereby text scales dynamically with the viewport's size, therefore offering a smooth and responsive reading experience across many devices. Viewport units, media searches, and changeable fonts let fluid typography ensure that text stays intelligible and visually balanced, independent of screen size. This method eliminates the need for fixed font sizes and allows for seamless changes, thereby improving readability and appearance in a way that fits very different display conditions.&lt;/p&gt;

&lt;p&gt;Here's an 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="c"&gt;/* Base font styles */&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;font-family&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;'Kyiv Sans'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nb"&gt;sans-serif&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;line-height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1.5&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;margin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;padding&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;background-color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#f4f4f4&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#333&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c"&gt;/* Fluid Typography for Heading and Body Text */&lt;/span&gt;
&lt;span class="nt"&gt;h1&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;calc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;2rem&lt;/span&gt; &lt;span class="err"&gt;+&lt;/span&gt; &lt;span class="m"&gt;2vw&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; 
    &lt;span class="c"&gt;/* Fluid font size that scales with viewport width */&lt;/span&gt;
  &lt;span class="nl"&gt;margin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;text-align&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#bd0c0c&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nt"&gt;h2&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;calc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;1.5rem&lt;/span&gt; &lt;span class="err"&gt;+&lt;/span&gt; &lt;span class="m"&gt;1.5vw&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; 
    &lt;span class="c"&gt;/* subheadings Fluid font size */&lt;/span&gt;
  &lt;span class="nl"&gt;margin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1rem&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;#555&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nt"&gt;p&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;calc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;1rem&lt;/span&gt; &lt;span class="err"&gt;+&lt;/span&gt; &lt;span class="m"&gt;0.5vw&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; 
    &lt;span class="c"&gt;/* paragraphs Fluid font size */&lt;/span&gt;
  &lt;span class="nl"&gt;margin&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt; &lt;span class="m"&gt;1rem&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;line-height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1.6&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="c"&gt;/* Fluid Typography for Variable Fonts */&lt;/span&gt;
&lt;span class="nc"&gt;.variable-font&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;font-family&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;'Kyiv Sans'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;calc&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;1rem&lt;/span&gt; &lt;span class="err"&gt;+&lt;/span&gt; &lt;span class="m"&gt;1vw&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; 
    &lt;span class="c"&gt;/* Fluid font size */&lt;/span&gt;
  &lt;span class="py"&gt;font-variation-settings&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="s2"&gt;'wght'&lt;/span&gt; &lt;span class="m"&gt;400&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;'CONT'&lt;/span&gt; &lt;span class="m"&gt;200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;'MIDL'&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;transition&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;font-variation-settings&lt;/span&gt; &lt;span class="m"&gt;500ms&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.variable-font&lt;/span&gt;&lt;span class="nd"&gt;:hover&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="py"&gt;font-variation-settings&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="s2"&gt;'wght'&lt;/span&gt; &lt;span class="m"&gt;700&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;'CONT'&lt;/span&gt; &lt;span class="m"&gt;250&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;'MIDL'&lt;/span&gt; &lt;span class="m"&gt;-100&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;How it works:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;calc() Function:&lt;/strong&gt; This function generates a fluid scaling effect by combining relative units &lt;code&gt;vw&lt;/code&gt;, with fixed values &lt;code&gt;rem&lt;/code&gt;. &lt;code&gt;font-size&lt;/code&gt;, for instance, &lt;code&gt;calc(2rem + 2vw)&lt;/code&gt; reacts to the viewport width and assures a base size.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Fluid Typography for Various Elements:&lt;/strong&gt; Many elements such as &lt;code&gt;h1&lt;/code&gt;, &lt;code&gt;h2&lt;/code&gt;, and &lt;code&gt;p&lt;/code&gt; guarantee text scaled suitably across devices using fluid typeography. The &lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/calc" rel="noopener noreferrer"&gt;&lt;code&gt;calc()&lt;/code&gt;&lt;/a&gt; function provides a base size with a scaling factor that changes with the viewport width.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Variable Fonts:&lt;/strong&gt;  By combining fluid typography with changeable fonts, you can achieve dynamic changes in text attributes depending on viewport size.&lt;br&gt;
This method guarantees that text stays aesthetically pleasing and readable across a large spectrum of devices and screen sizes.&lt;/p&gt;

&lt;p&gt;By animating text, kinetic typography gives it life and generates interesting and dynamic visual effects that enthrall viewers. This method adds motion and interaction by changing text attributes using JavaScript and CSS animations. Using a &lt;code&gt;:hover&lt;/code&gt; effect to animate the font weight in our example with the variable font, we demonstrated kinetic typography—that is, seamlessly from lighter to bolder weights. This not only emphasizes the content but also shows how, with fluid, real-time changes, varying fonts may improve user interactions. Kinetic typography allows designers to improve the visual attractiveness and usability of their text, enhancing its fundamental role in an interactive and interesting digital environment.&lt;/p&gt;

&lt;h3&gt;
  
  
  Example: Animating Weight on Hover
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight css"&gt;&lt;code&gt;&lt;span class="nc"&gt;.variable-font&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;font-family&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="s2"&gt;'Kyiv Sans'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;font-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;5rem&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;line-height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1.1&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;font-weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;font-variation-settings&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
   &lt;span class="s2"&gt;'wght'&lt;/span&gt; &lt;span class="m"&gt;100&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;'CONT'&lt;/span&gt; &lt;span class="m"&gt;250&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;'MIDL'&lt;/span&gt; &lt;span class="m"&gt;0&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;transition&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;font-variation-settings&lt;/span&gt; &lt;span class="m"&gt;500ms&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;

&lt;span class="nc"&gt;.variable-font&lt;/span&gt;&lt;span class="nd"&gt;:hover&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;font-weight&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; 
    &lt;span class="c"&gt;/* Animate the weight from light to bold on hover */&lt;/span&gt;
  &lt;span class="py"&gt;font-variation-settings&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;
    &lt;span class="s2"&gt;'wght'&lt;/span&gt; &lt;span class="m"&gt;1000&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;'CONT'&lt;/span&gt; &lt;span class="m"&gt;250&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;'MIDL'&lt;/span&gt; &lt;span class="m"&gt;-1000&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;Here, we use a smooth transition to animate the weight of the &lt;code&gt;.variable-font&lt;/code&gt; element from regular 100 to bold 1000 on &lt;code&gt;:hover&lt;/code&gt;, creating a subtle yet impactful effect.&lt;/p&gt;

&lt;p&gt;These are only a handful of the imaginative opportunities that different fonts offer. From dynamic animations to fluid layouts, there is ample opportunity for distinctive and intriguing typefaces. With a little inventiveness and CSS understanding, we can challenge web design norms and produce rather remarkable user experiences.&lt;/p&gt;

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

&lt;p&gt;Variable fonts—best demonstrated by &lt;code&gt;Kyiv Sans&lt;/code&gt; transform typography on the web by grouping several font styles into a single file. By lowering the number of HTTP queries, this invention simplifies processes, increases design flexibility, and boosts performance. Designers can fully utilize changeable fonts in CSS to produce responsive, dynamic typefaces that fit perfectly with various screen sizes and user interactions.&lt;br&gt;
Designers can create visually appealing and easily accessible typographic experiences using attributes such as weight, middle layer effects, and contrast, as well as responsive approaches such as media queries and viewport units. Variable fonts are a necessary tool for contemporary web design since their fluidity enables new directions for artistic expression.&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;Check out the &lt;a href="https://stunning-meerkat-afcad8.netlify.app/" rel="noopener noreferrer"&gt;live preview hosted on Netlify&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;&lt;a href="https://github.com/miracleonyenma/variable-fonts-vite" rel="noopener noreferrer"&gt;View Source code &lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://en.wikipedia.org/wiki/Variable_font#:~:text=A%20variable%20font%20(VF)%20is,fonts%20available%20to%20be%20sampled." rel="noopener noreferrer"&gt;variable fonts&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://en.wikipedia.org/wiki/OpenType" rel="noopener noreferrer"&gt;OpenType&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.behance.net/gallery/90690" rel="noopener noreferrer"&gt;Kyiv Sans&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Viewport_meta_tag" rel="noopener noreferrer"&gt;&lt;code&gt;viewport&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.myfonts.com/pages/fontscom-learning-fontology-level-1-type-families-about-typeface-families" rel="noopener noreferrer"&gt;&lt;code&gt;typeface&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://learn.microsoft.com/en-us/typography/opentype/spec/dvaraxisreg" rel="noopener noreferrer"&gt;registered axes&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://v-fonts.com/" rel="noopener noreferrer"&gt;custom axes&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/@font-face" rel="noopener noreferrer"&gt;&lt;code&gt;@font-face&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://typenetwork.com/" rel="noopener noreferrer"&gt;Type Network&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.fontsquirrel.com/" rel="noopener noreferrer"&gt;Font Squirrel&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://fonts.adobe.com/" rel="noopener noreferrer"&gt;Adobe Fonts&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.fontspring.com/" rel="noopener noreferrer"&gt;Font Spring&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://fonts.google.com/" rel="noopener noreferrer"&gt;Google fonts&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://v-fonts.com/" rel="noopener noreferrer"&gt;Vfonts.com&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.fontspace.com/category/ttf" rel="noopener noreferrer"&gt;&lt;code&gt;ttf&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.w3.org/TR/WOFF2/" rel="noopener noreferrer"&gt;&lt;code&gt;woff2&lt;/code&gt;&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;&lt;a href="https://everythingfonts.com/" rel="noopener noreferrer"&gt;everythingfonts.com&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.behance.net/gallery/90690285/KyivType-variable-superfamily" rel="noopener noreferrer"&gt;Behance.net&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/CSS_media_queries/Using_media_queries" rel="noopener noreferrer"&gt;media queries&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/font-size" rel="noopener noreferrer"&gt;&lt;code&gt;px&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/font-size" rel="noopener noreferrer"&gt;&lt;code&gt;rem&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Values_and_units#numbers_lengths_and_percentages" rel="noopener noreferrer"&gt;&lt;code&gt;vw&lt;/code&gt;&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;
&lt;a href="https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Values_and_units#numbers_lengths_and_percentages" rel="noopener noreferrer"&gt;&lt;code&gt;vh&lt;/code&gt;&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/CSS/calc" rel="noopener noreferrer"&gt;&lt;code&gt;calc()&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>webdev</category>
      <category>tutorial</category>
      <category>css</category>
      <category>web3</category>
    </item>
    <item>
      <title>Building Progressive Web Applications using SvelteKit</title>
      <dc:creator>Katerina Braide</dc:creator>
      <pubDate>Fri, 02 Aug 2024 10:09:42 +0000</pubDate>
      <link>https://dev.to/braide/building-progressive-web-applications-using-sveltekit-58gj</link>
      <guid>https://dev.to/braide/building-progressive-web-applications-using-sveltekit-58gj</guid>
      <description>&lt;p&gt;This article is all about simplifying your path to web development. We will build amazing websites with with &lt;a href="https://kit.svelte.dev/" rel="noopener noreferrer"&gt;SvelteKit&lt;/a&gt;, a tool akin to your coding friend. We will quickly set things up, create a basic site with little coding, and easily turn it into a &lt;a href="https://developer.mozilla.org/en-US/docs/Web/Progressive_web_apps" rel="noopener noreferrer"&gt;Progressive Web App (PWA)&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction to SvelteKit for Building Progressive Web Applications (PWAs)
&lt;/h2&gt;

&lt;p&gt;&lt;a href="https://svelte.dev/" rel="noopener noreferrer"&gt;Svelte&lt;/a&gt;, a front-end JavaScript tool, enables the creation and management of user interfaces akin to &lt;a href="https://react.dev/" rel="noopener noreferrer"&gt;React&lt;/a&gt; and &lt;a href="https://vuejs.org/" rel="noopener noreferrer"&gt;Vue&lt;/a&gt;, while SvelteKit serves as a framework. It enhances this potential by offering a framework that enables the development of more comprehensive websites with features such as routing, &lt;a href="https://kit.svelte.dev/docs/glossary#ssr" rel="noopener noreferrer"&gt;server-side rendering&lt;/a&gt;, and presence of an API. Before its release, developers used a framework known as &lt;a href="https://sapper.svelte.dev/" rel="noopener noreferrer"&gt;Sapper&lt;/a&gt; for similar purposes. It can thus be considered a consolidated and improved form of sapper. Making comparisons, one may relate SvelteKit to Svelte, &lt;a href="https://nextjs.org/" rel="noopener noreferrer"&gt;Next.js&lt;/a&gt; to React, or &lt;a href="https://nuxt.com/" rel="noopener noreferrer"&gt;Nuxt.js&lt;/a&gt; to Vue. Svelte primarily focuses on &lt;a href="https://kit.svelte.dev/docs/glossary#csr" rel="noopener noreferrer"&gt;client-side rendering&lt;/a&gt; and UI updates in the browser, similar to React or Vue, but it combines server-side rendering with client-side rendering to build fast, high-performance dynamic websites, thereby matching the approach of Next.js and Nuxt.js with React or Vue.&lt;/p&gt;

&lt;h3&gt;
  
  
  Benefits of using SvelteKit
&lt;/h3&gt;

&lt;p&gt;Using SvelteKit to create websites offers a multitude of benefits.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;It makes use of both client-side and server-side rendering. As a result, you can receive an HTML page based on your first query to the server. Because it enables page access and full indexing, this is excellent for SEO.&lt;/li&gt;
&lt;li&gt;The routing system is quite simple, as it utilizes its routing system for handling multiple pages and routing.&lt;/li&gt;
&lt;li&gt;Since it handles the server side, you can use its API to work with the website's front end.&lt;/li&gt;
&lt;li&gt;Just like other major JavaScript frameworks, it also makes use of &lt;a href="https://kit.svelte.dev/docs/performance" rel="noopener noreferrer"&gt;code splitting&lt;/a&gt;. This can help increase your application's response time.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;As you use most of the popular frameworks, such as React, Vue, or Svelte, while creating web applications, you will notice that most of the time, the result is a single-page application (SPA). This is due to the browser rendering only one HTML page. It could be a blank page. All of this is known as client-side rendering.&lt;/p&gt;

&lt;p&gt;With SvelteKit, though, client-side rendering in the browser and server-side rendering mix together. Upon performing a first query to the server, it returns a pre-generated, fully constructed HTML page rather than a blank one. Search engines and site crawlers benefit from this server-side technique because the HTML page sent to the browser already contains content. When users move between pages on the site, Svelte detects requests for new pages, looks at the target pages, and deftly changes content in the browser without further HTML page requests.&lt;/p&gt;

&lt;p&gt;These also include server-side rendering and a routing mechanism for pages and components, which improves the idea of a single-page application. Additionally, your application's front end can utilize a custom API to access your server-side logic. We build it on &lt;a href="https://vitejs.dev/" rel="noopener noreferrer"&gt;Vite&lt;/a&gt;, a front-end tool capable of compiling code and performing &lt;a href="https://github.com/sveltejs/vite-plugin-svelte/blob/main/docs/config.md#hot" rel="noopener noreferrer"&gt;hot module replacement&lt;/a&gt;. This can allow for live updates in the browser during both code changes and previews.&lt;/p&gt;

&lt;h2&gt;
  
  
  Project Overview
&lt;/h2&gt;

&lt;p&gt;In this article, we will work on a quote application. When you click a button, this application will randomly render each quote using an external API. We will also use service workers to cache the application and make it available offline for you or your users to use. We will utilize SvelteKit and the quotes API from &lt;a href="https://api-ninjas.com/api/quotes" rel="noopener noreferrer"&gt;API Ninjas&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Setting Up Your SvelteKit Project
&lt;/h2&gt;

&lt;p&gt;Now that we have a clear understanding of the project, we can proceed to the primary phase, which involves the project setup. This will contain some installations and configurations. You can follow the steps below.&lt;/p&gt;

&lt;h3&gt;
  
  
  Installing SvelteKit and setting up a new project
&lt;/h3&gt;

&lt;p&gt;To begin working on the project, you must install the necessary packages. You can use the command:&lt;/p&gt;

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

npm create svelt@latest


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

&lt;/div&gt;

&lt;p&gt;You can install the project with all the files and folders, and it will give you the most recent package version of Svelte. You can also follow the steps below to get started:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Open a new terminal.&lt;/li&gt;
&lt;li&gt;Install the necessary packages, files, and folders by running the command: 
```shell
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;npm generate svelt@latest&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;* Select the current directory.
* Choose the skeletal template.
* Choose JavaScript.
* Use the handy plugins `eslint` and `prettier`.
* Running `npm install` will help you negotiate into the project and install the necessary modules.
* After setting up the dependencies, use the following command to launch the application:
```shell


npm run dev


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

&lt;/div&gt;

&lt;ul&gt;
&lt;li&gt;Visit &lt;code&gt;http://localhost:your-port-number&lt;/code&gt; to access the running program on your browser.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Once we complete our project, we will have a wealth of mock code that we can modify to build our intended application.&lt;/p&gt;

&lt;h3&gt;
  
  
  Configuring SvelteKit for PWA development
&lt;/h3&gt;

&lt;p&gt;Although SvelteKit projects are usually built with Vite and already include a &lt;code&gt;vite.config.js&lt;/code&gt; file with appropriate plugins, configuring SvelteKit for PWA (Progressive Web App) development takes a few extra steps beyond the basic project setup with: &lt;/p&gt;

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

npm create svelt@latest


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

&lt;/div&gt;

&lt;p&gt;You can go as follows:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create a custom &lt;code&gt;service-worker.js&lt;/code&gt; file within your project's &lt;code&gt;src&lt;/code&gt; directory.&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://https://kit.svelte.dev/docs/service-workers" rel="noopener noreferrer"&gt;Service Worker&lt;/a&gt; Registration will register the service worker automatically during the building process.&lt;/li&gt;
&lt;li&gt;Ensure that you have configured your Svelte components to handle PWA features, such as installable app prompts, dynamic caching, and offline support.&lt;/li&gt;
&lt;li&gt;As necessary, apply service worker registration and cache techniques to your Svelte parts.&lt;/li&gt;
&lt;li&gt;Build your SvelteKit app using the command:
```shell
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;npm run build&lt;/p&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Once configured, install it in your hosting environment.

Following these guidelines will help you set it up properly for PWA development, allowing features such as [offline capability](https://kit.svelte.dev/docs/service-workers) and better user experiences.

## Building the PWA Features
Acting as a background process inside the browser, a service worker essentially lets JavaScript run in a multi-threaded way. Service workers have many outstanding examples; among them are [Cloudflare workers](https://workers.cloudflare.com/). Cloudflare has turned the web standard for service workers into a JavaScript runtime environment. Tools like [PartyKit](https://www.partykit.io/), which use service workers to subtly load analytics in the background, may be recognizable to you. Service providers provide a wide spectrum of advantages and capabilities; in this case, we will use them to improve our Progressive Web App (PWA).

Create a file named [`+page.svelte`](https://kit.svelte.dev/docs/routing#page); within the file, you must write the code to develop the PWA. We would be building a JavaScript application with quote display capability. The project we will build will retrieve the quotes using an external API. By doing this, you will get many quotes and have a large data set to work with. In your project, all the user has to do is click a button that will fetch and display each quote randomly, making it enjoyable.

```javascript


&amp;lt;script&amp;gt;
    let name = 'World';
    const apiKey = import.meta.env.VITE_API_KEY;

    /**
     * @type {string | null}
     */
    let error = null;

    /**
     * @type {string }
     */
    let title = 'Please click on the button to get a quote.';

    /**
     * @type {boolean}
     */
    let isLoading = false;

    const fetchQuote = async () =&amp;gt; {
        try {
            isLoading = true;

            const response = await fetch('https://api.api-ninjas.com/v1/quotes?', {
                headers: { 'x-api-key': apiKey }
            });

            if (!response.ok) {
                error = 'An error ocurred, failed to get quotes.';
                console.log(error);
                return;
            }

            const data = await response.json();
            title = data[0].quote || 'No quote available';
        } catch (err) {
            error = 'An error ocurred, failed to get quotes.';
            console.log(error);
        } finally {
            isLoading = false;
        }
    };
&amp;lt;/script&amp;gt;

&amp;lt;div class="index"&amp;gt;
    &amp;lt;h1&amp;gt;Hello, {name}&amp;lt;/h1&amp;gt;
    &amp;lt;p&amp;gt;
        {#if error}
            {error}
        {:else}
            {title}
        {/if}
    &amp;lt;/p&amp;gt;

    &amp;lt;button on:click={fetchQuote}&amp;gt;
        {#if isLoading}
            {'Fetching...'}
        {:else}
            {'Change Quote'}
        {/if}
    &amp;lt;/button&amp;gt;
&amp;lt;/div&amp;gt;

&amp;lt;style&amp;gt;
    div {
        text-align: center;
        padding: 1em;
        max-width: 240px;
        margin: 0 auto;
    }

    h1 {
        color: #ff3e00;
        text-transform: uppercase;
        font-size: 4em;
        font-weight: 100;
    }

    @media (min-width: 640px) {
        div {
            max-width: none;
        }
    }
&amp;lt;/style&amp;gt;


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

&lt;/div&gt;

&lt;p&gt;In the code, we made use of an API that will give us data in real-time. The API keys are written in a &lt;code&gt;.env&lt;/code&gt; file, so you have to make sure to create one in your project and get your API key, too.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Note: If you are managing your project using a version control system such as &lt;a href="https://git-scm.com/" rel="noopener noreferrer"&gt;git&lt;/a&gt;, please do not track the &lt;code&gt;.env&lt;/code&gt; file. To ensure that you don't unintentionally reveal your secrets to the public, add &lt;code&gt;.env&lt;/code&gt; to your &lt;code&gt;.gitignore&lt;/code&gt; file.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Implementing Service Workers for Offline Capabilities
&lt;/h3&gt;

&lt;p&gt;Consider a service worker to be a middleman between your client and servers, capable of handling all requests passed between them. You might have come across &lt;a href="https://mswjs.io/" rel="noopener noreferrer"&gt;mock service workers&lt;/a&gt;, which let you test through several situations. Service providers have enormous power that allows a broad spectrum of possibilities. To simplify the use of service workers, SvelteKit requires only the inclusion of a &lt;code&gt;service-worker.js&lt;/code&gt; file in the source directory. It automatically handles the registration process, thereby eliminating the need for manual registration that is typically required with other systems. This simplified strategy replaces the need for outside libraries to support this process.&lt;/p&gt;

&lt;p&gt;To establish a service worker, go to your project directory, specifically the &lt;code&gt;src&lt;/code&gt; folder, and then create your service worker file under &lt;code&gt;service-worker.js&lt;/code&gt;. Despite their initial complexity, service providers can simplify into three basic steps:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Firstly, you install the service worker, followed by its activation.&lt;/li&gt;
&lt;li&gt;Secondly, you intercept traffic by listening for fetch events and then substituting the URL with content from the cache, enabling offline functionality. &lt;/li&gt;
&lt;li&gt;Thirdly, you can enhance your service worker by allowing communication to notify users of updates, prompting them to reload the page.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Turning on offline mode lets your page run free from an internet connection. If a critical problem necessitates a restart, you can access storage to unregister your service providers. It becomes crucial to monitor the cache storage, as its use triggers the display of cached content.&lt;/p&gt;

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

&lt;span class="c1"&gt;/// &amp;lt;reference types="@sveltejs/kit" /&amp;gt;&lt;/span&gt;
&lt;span class="k"&gt;import&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;build&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;files&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;version&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;from&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;$service-worker&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Create a unique cache name for this deployment&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;CACHE&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="s2"&gt;`cache-&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;version&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="s2"&gt;`&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;ASSETS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="nx"&gt;build&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="c1"&gt;// the app itself&lt;/span&gt;
    &lt;span class="p"&gt;...&lt;/span&gt;&lt;span class="nx"&gt;files&lt;/span&gt; &lt;span class="c1"&gt;// everything in `static`&lt;/span&gt;
&lt;span class="p"&gt;];&lt;/span&gt;

&lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;install&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Create a new cache and add all files to it&lt;/span&gt;
    &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;addFilesToCache&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;cache&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;caches&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;CACHE&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;cache&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addAll&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;ASSETS&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;installing service worker for version&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;version&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;caching assets&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;ASSETS&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;caching build&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;build&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

    &lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;waitUntil&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;addFilesToCache&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;activate&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Remove previous cached data from disk&lt;/span&gt;
    &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;deleteOldCaches&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="k"&gt;for &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;key&lt;/span&gt; &lt;span class="k"&gt;of&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;caches&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;keys&lt;/span&gt;&lt;span class="p"&gt;())&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="nx"&gt;CACHE&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;caches&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="k"&gt;delete&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;key&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;waitUntil&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;deleteOldCaches&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="nb"&gt;self&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;fetch&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// ignore POST requests etc&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;method&lt;/span&gt; &lt;span class="o"&gt;!==&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;GET&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="k"&gt;return&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

    &lt;span class="k"&gt;async&lt;/span&gt; &lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;respond&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;url&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;URL&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;url&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;cache&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;caches&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;CACHE&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

        &lt;span class="c1"&gt;// `build`/`files` can always be served from the cache&lt;/span&gt;
        &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;ASSETS&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;includes&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;url&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;pathname&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;cache&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;match&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;url&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;pathname&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

            &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;

        &lt;span class="c1"&gt;// for everything else, try the network first, but&lt;/span&gt;
        &lt;span class="c1"&gt;// fall back to the cache if we're offline&lt;/span&gt;
        &lt;span class="k"&gt;try&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nf"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;request&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

            &lt;span class="c1"&gt;// if we're offline, fetch can return a value that is not a Response&lt;/span&gt;
            &lt;span class="c1"&gt;// instead of throwing - and we can't pass this non-Response to respondWith&lt;/span&gt;
            &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;response&lt;/span&gt; &lt;span class="k"&gt;instanceof&lt;/span&gt; &lt;span class="nx"&gt;Response&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;Error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;invalid response from fetch&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;

            &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;status&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="nx"&gt;cache&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;put&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;request&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;clone&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;

            &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;catch &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
            &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;cache&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;match&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;request&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

            &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
                &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="s2"&gt;`Returning from Cache`&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;request&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;url&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
                &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
            &lt;span class="p"&gt;}&lt;/span&gt;

            &lt;span class="c1"&gt;// if there's no cache, then just error out&lt;/span&gt;
            &lt;span class="c1"&gt;// as there is nothing we can do to respond to this request&lt;/span&gt;
            &lt;span class="k"&gt;throw&lt;/span&gt; &lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
        &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;respondWith&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;respond&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;h3&gt;
  
  
  Adding manifest file
&lt;/h3&gt;

&lt;p&gt;When we discuss the manifest, it refers to a document or file that encompasses all the metadata of related files. It includes the title, version, licensing data, and other parts of your project. When building and running projects, this file provides crucial information about the necessary files, assets, and pieces.&lt;/p&gt;

&lt;p&gt;Following the steps below, you will be able to add a manifest file to your project.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Create a &lt;code&gt;manifest.json&lt;/code&gt; file in your project's &lt;code&gt;static&lt;/code&gt; directory.&lt;/li&gt;
&lt;li&gt;Ensure the manifest file contains essential details such as icons, names, and shortcuts for your Progressive Web App (PWA).&lt;/li&gt;
&lt;li&gt;Link the &lt;code&gt;manifest.json&lt;/code&gt; file to your project's &lt;code&gt;src/app.html&lt;/code&gt; file.&lt;/li&gt;
&lt;li&gt;Confirm your &lt;code&gt;service-worker.js&lt;/code&gt; file is in your &lt;code&gt;src&lt;/code&gt; directory.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Svelte will register the service worker found in the root of the &lt;code&gt;src&lt;/code&gt; folder automatically during the build process.&lt;br&gt;
Following these rules will help you easily include a manifest file in your project, allowing PWA functionalities.&lt;/p&gt;
&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="w"&gt;

&lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"QG"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"description"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"Quote Generator"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"short_name"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"quote"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"display"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"standalone"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"start_url"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"/"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"background_color"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"#808080"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"theme_color"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"#ff3f20"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="nl"&gt;"icons"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="p"&gt;[&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"src"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"logo1.avif"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"sizes"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"512x512"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"type"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"image/png"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
            &lt;/span&gt;&lt;span class="nl"&gt;"purpose"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="s2"&gt;"any maskable"&lt;/span&gt;&lt;span class="w"&gt;
        &lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;
    &lt;/span&gt;&lt;span class="p"&gt;]&lt;/span&gt;&lt;span class="w"&gt;
&lt;/span&gt;&lt;span class="p"&gt;}&lt;/span&gt;&lt;span class="w"&gt;


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

&lt;/div&gt;

&lt;p&gt;The manifest file, which contains the code above, provides information about the name, description, and icon of our project.&lt;/p&gt;

&lt;h2&gt;
  
  
  Enhancing the PWA with SvelteKit
&lt;/h2&gt;

&lt;p&gt;Improving a Progressive Web App (PWA) means using the features of the framework to improve performance, user experience, and development process simplification. It provides capabilities for responsive design, flawless UI interactions, and effective routing, thereby allowing the creation of dynamic and aesthetically striking PWAs. Developers can improve the functionality and responsiveness of PWAs by using their features for server-side rendering, client-side rendering, and custom API integration, therefore guaranteeing a flawless and immersive experience over several devices. Furthermore, SvelteKit's capabilities include live updates, hot module replacement, and SEO optimization, which help to create high-performance PWAs.&lt;/p&gt;

&lt;h3&gt;
  
  
  Utilizing SvelteKit's features for responsive design and smooth UI interactions
&lt;/h3&gt;

&lt;p&gt;The framework offers many features that can help improve the design of websites. These features can fit screen widths, providing users with a responsive design and improving their user experience. An important part is that you can also add animations and interactive elements to increase the user experience. This can help provide a user-friendly interface. Since we won't be looking at design in this article, check out this &lt;a href="https://adamgreen.tech/blog/responsive-views-in-svelte-js" rel="noopener noreferrer"&gt;website&lt;/a&gt;. They explain how to use Svelte and SvelteKit to create responsive views.&lt;/p&gt;

&lt;h3&gt;
  
  
  Benefits of building PWAs with SvelteKit
&lt;/h3&gt;

&lt;p&gt;SvelteKit enables one to design Progressive Web Apps (PWAs) with several benefits:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Improved Performance:&lt;/strong&gt; By integrating both client-side and server-side rendering, you can improve the speed of your application.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Enhanced SEO:&lt;/strong&gt; HTML pages being rendered first can help improve search engine optimization (SEO). This can make your project more visible and rank higher when hosted.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Adaptive Layouts:&lt;/strong&gt; Its responsive features make it easier for developers to create responsive designs on different screen sizes.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Streamlined Routing Mechanism:&lt;/strong&gt; Its routing mechanism makes routing straightforward and makes setting up multiple-page routing easier.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Personalized API Integration:&lt;/strong&gt; It also includes the ability to create a custom API for backend logic. You can use this logic on the frontend.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Real-Time Updates and Hot Module Replacement:&lt;/strong&gt; Built on Vue, it provides real-time updates and hot module replacements.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each feature makes it simple for developers to create progressive web applications (PWAs), which, in turn, improves design, routing, SEO, routing, and workflows.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhp4r0pp9svu9x7br9ewu.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fhp4r0pp9svu9x7br9ewu.gif" alt="Image description"&gt;&lt;/a&gt;&lt;br&gt;
The GIF above shows an installable PWA.&lt;/p&gt;

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

&lt;p&gt;This article shows the importance of Progressive Web Apps (PWAs), their comparisons to native apps, and the advantages of employing SvelteKit for PWA development. It is a framework based on Svelte for website construction and includes functionalities such as routing, server-side rendering, and API integration. Using SvelteKit enables one to design Progressive Web Apps (PWAs) with different benefits, such as combining client-side and server-side rendering speed, loading time, and improved performance. Hence, the first rendering phase becomes more user-friendly.&lt;/p&gt;

&lt;h2&gt;
  
  
  References
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;&lt;a href="https://kit.svelte.dev/" rel="noopener noreferrer"&gt;SvelteKit&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://developer.mozilla.org/en-US/docs/Web/Progressive_web_apps" rel="noopener noreferrer"&gt;Progressive Web App (PWA)&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://svelte.dev/" rel="noopener noreferrer"&gt;Svelte&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://react.dev/" rel="noopener noreferrer"&gt;React&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://vuejs.org/" rel="noopener noreferrer"&gt;Vue&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://kit.svelte.dev/docs/glossary#ssr" rel="noopener noreferrer"&gt;server-side rendering&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://sapper.svelte.dev/" rel="noopener noreferrer"&gt;Sapper&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://nextjs.org/" rel="noopener noreferrer"&gt;Next.js&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;
&lt;a href="https://nuxt.com/" rel="noopener noreferrer"&gt;Nuxt.js&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;&lt;a href="https://kit.svelte.dev/docs/glossary#csr" rel="noopener noreferrer"&gt;client-side rendering&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://kit.svelte.dev/docs/performance" rel="noopener noreferrer"&gt;code splitting&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://vitejs.dev/" rel="noopener noreferrer"&gt;Vite&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://www.sanity.io/glossary/hot-module-replacement" rel="noopener noreferrer"&gt;hot module replacement&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;a href="https://api-ninjas.com/api/quotes" rel="noopener noreferrer"&gt;API Ninjas&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://https://kit.svelte.dev/docs/service-workers" rel="noopener noreferrer"&gt;Service Worker&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;
&lt;a href="https://kit.svelte.dev/docs/service-workers" rel="noopener noreferrer"&gt;offline capability&lt;/a&gt; &lt;/li&gt;
&lt;li&gt;
&lt;a href="https://workers.cloudflare.com/" rel="noopener noreferrer"&gt;Cloudflare workers&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;&lt;a href="https://www.partykit.io/" rel="noopener noreferrer"&gt;PartyKit&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://kit.svelte.dev/docs/routing#page" rel="noopener noreferrer"&gt;&lt;code&gt;+page.svelte&lt;/code&gt;&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://git-scm.com/" rel="noopener noreferrer"&gt;git&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://mswjs.io/" rel="noopener noreferrer"&gt;mock service workers&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="https://adamgreen.tech/blog/responsive-views-in-svelte-js" rel="noopener noreferrer"&gt;website&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;

</description>
      <category>webdev</category>
      <category>programming</category>
      <category>sveltekit</category>
    </item>
    <item>
      <title>Exploring CSS Units</title>
      <dc:creator>Katerina Braide</dc:creator>
      <pubDate>Fri, 03 May 2024 08:56:49 +0000</pubDate>
      <link>https://dev.to/braide/exploring-css-units-1e98</link>
      <guid>https://dev.to/braide/exploring-css-units-1e98</guid>
      <description>&lt;p&gt;🚀 Big Announcement! 🚀&lt;/p&gt;

&lt;p&gt;📝 Thrilled to unveil my newest article! Delve into Exploring CSS Units as I explore the different CSS units and their use cases. 💡 Ready for an insightful read? Dive in here! 👀&lt;/p&gt;

&lt;p&gt;&lt;a href="https://blog.openreplay.com/exploring-css-units/"&gt;https://blog.openreplay.com/exploring-css-units/&lt;/a&gt;&lt;/p&gt;

</description>
      <category>design</category>
      <category>css</category>
      <category>webdev</category>
      <category>beginners</category>
    </item>
    <item>
      <title>A Tiny Peep into CSS Houdini</title>
      <dc:creator>Katerina Braide</dc:creator>
      <pubDate>Sat, 13 Jan 2024 20:29:31 +0000</pubDate>
      <link>https://dev.to/braide/a-tiny-peep-into-css-houdini-3o7b</link>
      <guid>https://dev.to/braide/a-tiny-peep-into-css-houdini-3o7b</guid>
      <description>&lt;h2&gt;
  
  
  What is CSS Houdini
&lt;/h2&gt;

&lt;p&gt;CSS Houdini is a set of low-level APIs (Application Programming Interfaces) that enable developers to access and interact with the CSS (Cascading Style Sheets) rendering engine. It allows developers to create and use their own custom CSS properties and values, as well as manipulate the styling and layout of a webpage in ways that were not previously possible with standard CSS.&lt;br&gt;
CSS Houdini consists of several APIs, each serving a specific purpose. Some of the key APIs include: Paint Worklet API, Layout Worklet API, Animation Worklet API, Typed OM (Object Model) API, etc. &lt;br&gt;
CSS Houdini is designed to enhance the extensibility of CSS, allowing developers to experiment with new layout and styling features. It enables the creation of more dynamic and interactive web experiences by giving developers greater control over the rendering process.&lt;/p&gt;

&lt;h2&gt;
  
  
  Brief Info on CSS Houdini and its core concept of extending CSS capabilities with JavaScript.
&lt;/h2&gt;

&lt;p&gt;CSS Houdini is a set of powerful tools that allows web developers to use JavaScript to create and customize new features in CSS. It enables them to go beyond the standard capabilities of CSS, essentially extending the language with their own creative additions. With CSS Houdini, developers can use JavaScript to define new ways of drawing, layout, and animations on a webpage, providing more flexibility and control over the visual design. It's like adding magical abilities to CSS, making it a more dynamic and expressive tool for building engaging and interactive websites.&lt;/p&gt;

&lt;h2&gt;
  
  
  More Info.
&lt;/h2&gt;

&lt;p&gt;CSS Houdini has the potential to bring groundbreaking effects and functionalities to web development by empowering developers to go beyond the limitations of traditional CSS. Some key areas where it can make a significant impact include:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1.    Custom Effects:&lt;/strong&gt; Developers can create unique and visually stunning effects that were previously difficult or impossible to achieve with standard CSS. This opens up new possibilities for creating immersive and engaging user interfaces.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2.    Performance Optimization:&lt;/strong&gt; With CSS Houdini, developers can offload certain tasks to separate threads, improving performance and making it possible to create smoother animations and transitions. This helps in delivering a better user experience, especially on complex and interactive web applications.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3.    Layout Innovation:&lt;/strong&gt; The Layout Worklet API allows developers to define custom layout behaviors, enabling them to break free from the constraints of traditional layout models. This can lead to innovative and responsive designs that adapt more seamlessly to various screen sizes and orientations.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4.    Dynamic Styling:&lt;/strong&gt; CSS Houdini enables dynamic styling changes based on user interactions or other events. This can be leveraged to create dynamic, personalized, and context-aware user interfaces, enhancing the overall user experience.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5.    Cross-browser Consistency:&lt;/strong&gt; By using JavaScript to define styling logic, developers can achieve more consistent visual results across different web browsers. This helps in reducing the challenges associated with browser compatibility and ensuring a uniform experience for users.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;6.    Community-driven Innovation:&lt;/strong&gt; CSS Houdini encourages experimentation and sharing of custom CSS features within the development community. This fosters innovation, allowing developers to learn from each other and collectively push the boundaries of what is possible in web design.&lt;/p&gt;

&lt;p&gt;It’s safe to say, CSS Houdini offers the potential for groundbreaking effects and functionalities by empowering developers to be more creative, optimize performance, and overcome the limitations of traditional CSS. It represents a significant step forward in making the web development process more dynamic, expressive, and adaptable to the ever-evolving demands of modern web applications.&lt;/p&gt;

&lt;h2&gt;
  
  
  Benefits and Challenges
&lt;/h2&gt;

&lt;p&gt;CSS Houdini brings several advantages to web developers, offering enhanced flexibility, customization capabilities, and potential performance gains. Here are the key advantages:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;1.    Flexibility:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;• Extensibility: Houdini allows developers to extend CSS with their own custom properties, values, and behaviors. This means they can create styling rules tailored to their specific needs, fostering innovation and creativity in web design.&lt;/p&gt;

&lt;p&gt;• Dynamic Styling: Developers can use JavaScript to dynamically modify styles based on user interactions or other events, providing a more dynamic and personalized user experience.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;2.    Customization:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;• Custom Paint Worklets: With the Paint API, developers can define custom paint worklets, enabling the creation of unique shapes, patterns, and visual effects that go beyond the capabilities of standard CSS. This level of customization was not possible before Houdini.&lt;/p&gt;

&lt;p&gt;• Layout Control: The Layout API allows developers to define custom layout behaviors, giving them more control over how elements are positioned and sized. This customization is particularly valuable for creating responsive and adaptive layouts.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;3.    Performance Gains:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;• Offloading to Worklets: CSS Houdini allows certain tasks, such as painting and animations, to be offloaded to separate threads using worklets. This can lead to significant performance gains by leveraging parallelism and making web pages more responsive.&lt;/p&gt;

&lt;p&gt;• Optimized Animation: The Animation Worklet API enables developers to create highly performant animations by offloading animation logic to a separate thread. This can result in smoother animations and transitions, enhancing the overall user experience.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;4.    Consistent Cross-browser Results:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;• Reduced Browser Compatibility Issues: Using Houdini, developers can achieve more consistent visual results across different browsers. This helps mitigate common challenges associated with browser compatibility, ensuring a uniform experience for users.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;5.    Community Collaboration:&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;• Open for Experimentation: CSS Houdini encourages developers to experiment with new features and share their creations with the community. This collaborative environment fosters innovation and allows the web development community to collectively explore the possibilities of enhanced styling capabilities.&lt;/p&gt;

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

&lt;p&gt;CSS Houdini represents a transformative leap in web development, offering developers the ability to extend and customize CSS using JavaScript. With a suite of low-level APIs, CSS Houdini empowers developers to break free from traditional CSS constraints.&lt;br&gt;
While the development of CSS Houdini was ongoing, browsers like Chrome led in adoption, and the web development community continued to explore and experiment with the new possibilities it brought. As CSS Houdini evolves, it holds the promise of driving further innovation, collaboration, and creativity in the realm of web design, enabling developers to craft more dynamic and engaging user interfaces.&lt;/p&gt;

</description>
      <category>css</category>
      <category>javascript</category>
      <category>webdev</category>
      <category>frontend</category>
    </item>
    <item>
      <title>The Impact and Necessity of Dark Mode on User Experience</title>
      <dc:creator>Katerina Braide</dc:creator>
      <pubDate>Mon, 01 Jan 2024 07:34:12 +0000</pubDate>
      <link>https://dev.to/braide/the-impact-and-necessity-of-dark-mode-on-user-experience-521n</link>
      <guid>https://dev.to/braide/the-impact-and-necessity-of-dark-mode-on-user-experience-521n</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--QPAo5TW---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bilg6lfuyzk0v1xi6bu5.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--QPAo5TW---/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bilg6lfuyzk0v1xi6bu5.jpg" alt="Image description" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Ever felt your eyes getting tired from staring at your screen for too long? It's a common issue—a consequence of how bright most screens have become. However, there is a solution to give your eyes a break, and that's where dark mode comes in.&lt;/p&gt;

&lt;p&gt;In this article, we'll see how Dark Mode helps with eye strain, user accessibility, and in aesthetics interface. We'll keep it simple, discussing how it works and why you should consider using it in your next website project.&lt;/p&gt;

&lt;h3&gt;
  
  
  Light or Regular Mode
&lt;/h3&gt;

&lt;p&gt;Light mode, also known as regular mode or default mode, refers to the standard appearance or theme of a user interface (UI) where the background is predominantly light or bright, and the text and other elements are typically displayed in darker colors.&lt;/p&gt;

&lt;p&gt;Light mode is the traditional or default setting for many applications, websites, and operating systems. It is commonly associated with a clean and crisp aesthetic, and it's often favored in well-lit environments where high contrast and visibility are key considerations.  &lt;/p&gt;

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

&lt;h3&gt;
  
  
  Dark Mode
&lt;/h3&gt;

&lt;p&gt;Dark mode, at its core, is a design choice that flips the traditional color scheme. Instead of light backgrounds and dark text, dark mode opts for dark backgrounds with light or contrasting text. This shift isn't merely aesthetic; it's a strategic decision that impacts how users consume content and interact with digital interfaces.&lt;/p&gt;

&lt;p&gt;Dark mode in web design has come a long way. It started as a preference for coding environments and late-night browsing but is now a popular trend in apps and websites. Knowing how and why this change happened helps us understand its effect on user experience.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--B-oMXsZp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/okstt8krgtfh7ejxg43x.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--B-oMXsZp--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/okstt8krgtfh7ejxg43x.png" alt="Image description" width="800" height="689"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Why you should consider using Dark mode
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Reduced Eye Strain:&lt;/strong&gt; Dark mode reduces the amount of light emitted by screens, which can help alleviate eye strain, particularly in low-light conditions. This is especially beneficial for users who spend extended periods in front of screens.&lt;br&gt;
&lt;strong&gt;Improved Visibility in Low-Light Environments:&lt;/strong&gt; In dimly lit or nighttime environments, dark mode enhances visibility and readability by minimizing glare. Users are less likely to be blinded or disturbed by the brightness of a light background.&lt;br&gt;
&lt;strong&gt;Energy Efficiency for OLED Screens:&lt;/strong&gt; Dark mode is more energy-efficient on devices with OLED screens. In this mode, individual pixels are turned off to display black, saving power and potentially extending battery life on devices.&lt;br&gt;
&lt;strong&gt;Enhanced Focus on Content:&lt;/strong&gt; Dark mode places emphasis on the content by reducing the prominence of UI elements. This can result in a more immersive and focused user experience as users engage more directly with the information or media.&lt;br&gt;
&lt;strong&gt;Aesthetically Pleasing Design:&lt;/strong&gt; Many users find dark mode visually appealing. The high contrast between text and background can create a sleek and modern look. This aesthetic preference has led many applications and websites to offer dark mode as an alternative.&lt;br&gt;
&lt;strong&gt;Reduced Blue Light Exposure:&lt;/strong&gt; Dark mode typically reduces the amount of blue light emitted by screens. Blue light exposure, especially during nighttime use, has been associated with disruptions in circadian rhythms and can affect sleep patterns. Dark mode mitigates these concerns.&lt;br&gt;
&lt;strong&gt;Accessibility Improvements:&lt;/strong&gt; For users with certain visual impairments or sensitivities, dark mode can enhance accessibility by providing better contrast and reducing eye strain. Customization options, such as text size and font choice, may also be more effective in dark mode.&lt;br&gt;
&lt;strong&gt;Suitability for Certain Content Types:&lt;/strong&gt; Dark mode can be particularly suitable for content consumption, such as watching videos or viewing images. The dark background allows the content to stand out, creating a more engaging and enjoyable experience.&lt;br&gt;
&lt;strong&gt;Preservation of Night Vision:&lt;/strong&gt; Dark mode can help users maintain their night vision when transitioning from a well-lit environment to a dark one. The eyes are less likely to experience discomfort or take longer to adjust when using dark mode in low-light conditions.&lt;br&gt;
&lt;strong&gt;Trend and User Preference:&lt;/strong&gt; Dark mode has become a popular design trend, and many users now expect applications and websites to offer it as an option. Meeting user expectations and preferences can contribute to a positive overall user experience.&lt;/p&gt;

&lt;h2&gt;
  
  
  Guidelines to Follow When Converting UI Designs to Dark Mode
&lt;/h2&gt;

&lt;p&gt;&lt;strong&gt;Step 1: Understand Dark Mode Principles&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Before diving into the transformation, get familiar with the principles of dark mode design. This includes the use of a dark color palette, optimized contrast, and strategic accent placements.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 2: Assess Existing Color Scheme&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Evaluate the colors used in your regular UI design. Identify primary, secondary, and background colors. This assessment will guide your adjustments for dark mode.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 3: Choose a Dark Color Palette&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Select a dark color palette that complements your existing design. Consider dark grays, blues, or blacks. Ensure there's enough contrast for readability.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 4: Adjust Background Elements&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Update background elements like the main canvas, panels, and cards to reflect the chosen dark color scheme. Consistency across different sections is crucial.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 5: Modify Text Colors&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Adjust text colors to maintain readability against the dark background. Ensure text has sufficient contrast and consider using lighter shades for better legibility.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 6: Refine Icons and UI Elements&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Modify icons and UI elements to fit the dark mode aesthetics. Ensure they stand out clearly against the dark background. Adjust stroke weights and fill colors accordingly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 7: Implement High Contrast&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Leverage high contrast to highlight interactive elements. Make buttons, links, and actionable items pop against the dark background to guide users seamlessly.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 8: Optimize Imagery&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If your UI includes images, optimize them for dark mode. Check their appearance against the dark background and adjust brightness, contrast, or apply color filters if necessary.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 9: Consider Adaptive Design&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Implement adaptive design principles to allow for automatic switching between light and dark modes based on user preferences or environmental conditions.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 10: Test for Accessibility&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Ensure your dark mode design is accessible. Test for readability, especially for users with visual impairments. Evaluate color contrast ratios and consider customization options for diverse needs.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 11: Iterate and Gather Feedback&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Iterate on your dark mode design based on feedback. Conduct usability testing to identify issues or areas for improvement. User feedback is invaluable for refining the dark mode experience.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Step 12: Consider Platform Guidelines&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;If your UI is for a specific platform, adhere to platform-specific dark mode guidelines for a more cohesive user experience.&lt;/p&gt;

&lt;h2&gt;
  
  
  Use Case
&lt;/h2&gt;

&lt;p&gt;Now, let's bring the benefits of dark mode into focus by exploring a real-world use case, i will be converting a testimonial card from a light mode to a dark mode step by step. lets get started!&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--yqe57zJ3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1ukxyc4i4wat5n9pvsnr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--yqe57zJ3--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1ukxyc4i4wat5n9pvsnr.png" alt="Image description" width="800" height="444"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 1: Change the background to a dark shade
&lt;/h3&gt;

&lt;p&gt;Don't ever use plain black or #0000 in your dark mode except it's intentional and of necessity. For this design, lets use #13131A for the card background. it's not too dark but yet dark enough to contrast well with other shades of color. &lt;/p&gt;

&lt;p&gt;We have;&lt;br&gt;
&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--UhNKY75R--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8oziy5w7g372smfkwvj3.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--UhNKY75R--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8oziy5w7g372smfkwvj3.png" alt="Image description" width="800" height="416"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 2: Brighten Up the elements within
&lt;/h3&gt;

&lt;p&gt;From the look of things from the previous card design, only the avatar was contrasting well. so we need to brighten up the text elements for user accessibility. Also, it's not a good choice to use a plain white color to brighten up elements in a dark mode, any shade of white that fit best is more better. lets try #B0B0B0 for the body text and #E4E4E4 for the heading.  &lt;/p&gt;

&lt;p&gt;We have;&lt;/p&gt;

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

&lt;h3&gt;
  
  
  Final Touches
&lt;/h3&gt;

&lt;p&gt;It's looking nice already, so to wrap things up. lets indicate an activeness for the navigating arrows below by adding a more brighter shade of white to the forward arrow. For this one, lets use the same shade of white we used for the header - #E4E4E4&lt;/p&gt;

&lt;p&gt;And finally we have;&lt;/p&gt;

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

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

&lt;p&gt;For more hands on practice on how to convert your next light mode designs into dark mode, you can check out this resources.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;For more understanding of the basis and principles behind dark modes, &lt;a href="https://youtu.be/CZqcnxLd978?si=XNG7z-SA0WBsMdWb"&gt;watch this&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Designers: For quick conversion of your Figma UI into dark modes - &lt;a href="https://youtu.be/DJrQbmH75lY?si=MuNyj1U9byZb9xuK"&gt;watch this&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Developers: To follow a simple tutorial on how to implement this - &lt;a href="https://youtu.be/9LZGB3OLXNQ?si=-QzgV4x0K7OK4uWg"&gt;watch this&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;The adoption of dark mode goes beyond a mere stylistic choice; it actively contributes to a more comfortable, efficient, and inclusive user experience. By reducing eye strain, improving readability, and aligning with user preferences, dark mode has become a valuable tool for designers and developers seeking to elevate the overall digital experience for their audience.&lt;/p&gt;

&lt;p&gt;As always, I would love to see what you have to say regarding this. lets chat about your experience with dark and light modes and which one you prefer in the comment box below 😊&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>ui</category>
      <category>developer</category>
    </item>
    <item>
      <title>Optimizing User Experience: Using Ajax for Dynamic Web Page Loading</title>
      <dc:creator>Katerina Braide</dc:creator>
      <pubDate>Sun, 31 Dec 2023 01:04:53 +0000</pubDate>
      <link>https://dev.to/braide/optimizing-user-experience-using-ajax-for-dynamic-web-page-loading-3g43</link>
      <guid>https://dev.to/braide/optimizing-user-experience-using-ajax-for-dynamic-web-page-loading-3g43</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F22gdf686k8z34d116od2.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F22gdf686k8z34d116od2.jpg" alt="Image description"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;Imagine browsing a website, and each click feels like a smooth dance between pages—no annoying loading screens. That's the power of Ajax, a game-changer in web development. &lt;/p&gt;

&lt;p&gt;In this article, we're going to demystify Ajax. No complex jargon, no head-scratching. Just a simple guide to help you understand what Ajax is all about and why it's a big deal in web development. We'll be taking a hands-on approach, Prepare to wave goodbye to those annoying full-page reloads.&lt;/p&gt;

&lt;h2&gt;
  
  
  What is Ajax?
&lt;/h2&gt;

&lt;p&gt;Ajax short form for Asynchronous JavaScript and XML (or JSON). The key here is "asynchronous." Unlike traditional web requests that reload the entire page, Ajax allows your web page to communicate with the server in the background, fetching or sending data without disrupting the user's experience.&lt;/p&gt;

&lt;h3&gt;
  
  
  Key Components of Ajax
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;XMLHttpRequest
Think of this as Ajax's messenger. The XMLHttpRequest object is the bridge between your web page and the server, handling requests and responses behind the scenes.&lt;/li&gt;
&lt;li&gt;Callback Functions
Callback functions are the way Ajax keeps things in order. They're functions that get executed once a certain task, like fetching data from the server, is complete. This asynchronous nature is what makes Ajax so powerful.&lt;/li&gt;
&lt;li&gt;Handling Server Responses
Getting data is one thing; understanding what to do with it is another. We'll explore how Ajax handles server responses and how you can use that data to update your web page dynamically.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Why Ajax Matters
&lt;/h2&gt;

&lt;p&gt;Every time a traditional web page reloads, it's like hitting a reset button. The entire page has to be loaded again, images, scripts, and all. This process not only disrupts the user's experience but can also be time-consuming, especially on slower internet connections.&lt;/p&gt;

&lt;h3&gt;
  
  
  Advantages of Ajax
&lt;/h3&gt;

&lt;ol&gt;
&lt;li&gt;Seamless User Experience
Imagine clicking on a button, and only the relevant part of the page updates, all without a visible pause or reload. That's the magic of Ajax. Users can interact with your web page without interruptions, creating a more seamless and engaging experience.&lt;/li&gt;
&lt;li&gt;Faster Page Loading
By fetching and updating only the necessary data, Ajax significantly reduces the amount of information transferred between the user and the server. This results in faster loading times, making your web page feel more responsive and snappy.&lt;/li&gt;
&lt;li&gt;Reduced Server Load
Ajax minimizes the workload on the server. Instead of reloading the entire page, only the required data is exchanged, reducing server resources and improving overall efficiency.&lt;/li&gt;
&lt;/ol&gt;

&lt;h2&gt;
  
  
  Use Case: Loading Dynamic Content
&lt;/h2&gt;

&lt;p&gt;A. Scenario: Building a News Feed&lt;br&gt;
Let's put Ajax into action with a practical scenario. Picture this: you're creating a social media platform, and you want to implement a dynamic news feed. Users should be able to scroll through their feed without the page constantly refreshing. &lt;/p&gt;

&lt;h2&gt;
  
  
  Traditional Approach vs. Ajax Approach
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Traditional Approach:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Clicking on "Load More" triggers a full-page reload.&lt;/li&gt;
&lt;li&gt;Users experience a delay as the entire page reloads.&lt;/li&gt;
&lt;li&gt;Not the most seamless or user-friendly experience.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Ajax Approach:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Clicking on "Load More" triggers an asynchronous request.&lt;/li&gt;
&lt;li&gt;Only the new content is fetched from the server.&lt;/li&gt;
&lt;li&gt;The page updates dynamically, maintaining a smooth user experience.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Step-by-Step Implementation
&lt;/h2&gt;

&lt;p&gt;&lt;em&gt;1. Setting Up the HTML Structure&lt;/em&gt;&lt;/p&gt;

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

&lt;span class="cp"&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;html&lt;/span&gt; &lt;span class="na"&gt;lang=&lt;/span&gt;&lt;span class="s"&gt;"en"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;head&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;charset=&lt;/span&gt;&lt;span class="s"&gt;"UTF-8"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;meta&lt;/span&gt; &lt;span class="na"&gt;name=&lt;/span&gt;&lt;span class="s"&gt;"viewport"&lt;/span&gt; &lt;span class="na"&gt;content=&lt;/span&gt;&lt;span class="s"&gt;"width=device-width, initial-scale=1.0"&lt;/span&gt; &lt;span class="nt"&gt;/&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;title&amp;gt;&lt;/span&gt;Document&lt;span class="nt"&gt;&amp;lt;/title&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/head&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;body&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"news-feed"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;h1&amp;gt;&lt;/span&gt;Greening Cities: The Rise of Urban Gardening&lt;span class="nt"&gt;&amp;lt;/h1&amp;gt;&lt;/span&gt;
      &lt;span class="nt"&gt;&amp;lt;p&amp;gt;&lt;/span&gt;
        Urbanites worldwide are transforming limited spaces into green
        sanctuaries—balconies, rooftops, and community plots. From small-scale
        innovations like Sarah's balcony garden to citywide initiatives, urban
        gardening is reshaping city life. Embracing challenges with hydroponics
        and vertical solutions, this movement goes beyond a trend, fostering a
        connection with nature, promoting sustainability, and building
        communities in the heart of urban chaos. Join the flourishing green
        revolution urban gardening welcomes all, from seasoned gardeners to
        novices.
      &lt;span class="nt"&gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;button&lt;/span&gt; &lt;span class="na"&gt;id=&lt;/span&gt;&lt;span class="s"&gt;"load-more"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Load More&lt;span class="nt"&gt;&amp;lt;/button&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/body&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;script &lt;/span&gt;&lt;span class="na"&gt;src=&lt;/span&gt;&lt;span class="s"&gt;"./script.js"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/script&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/html&amp;gt;&lt;/span&gt;



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

&lt;/div&gt;

&lt;p&gt;&lt;em&gt;2. Writing JavaScript for Ajax&lt;/em&gt;&lt;/p&gt;

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

&lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;load-more&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;addEventListener&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;click&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nf"&gt;function &lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// Create a new XMLHttpRequest object&lt;/span&gt;
  &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;xhr&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nc"&gt;XMLHttpRequest&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

  &lt;span class="c1"&gt;// Define the callback function to handle the server response&lt;/span&gt;
  &lt;span class="nx"&gt;xhr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;onreadystatechange&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;function &lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;xhr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;readyState&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="c1"&gt;// Check if the request was successful (status code 200)&lt;/span&gt;
      &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;xhr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;status&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// Process the server response and update the news feed&lt;/span&gt;
        &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;news-feed&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nx"&gt;innerHTML&lt;/span&gt; &lt;span class="o"&gt;+=&lt;/span&gt; &lt;span class="nx"&gt;xhr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;responseText&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// Handle errors gracefully (display an error message, log, etc.)&lt;/span&gt;
        &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Error loading more content. Status:&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;xhr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;status&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;};&lt;/span&gt;

  &lt;span class="c1"&gt;// Open a GET request to the server endpoint&lt;/span&gt;
  &lt;span class="nx"&gt;xhr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;open&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;GET&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;your-server-endpoint&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;true&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="c1"&gt;// Send the request to the server&lt;/span&gt;
  &lt;span class="nx"&gt;xhr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;send&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="p"&gt;});&lt;/span&gt;



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

&lt;/div&gt;

&lt;p&gt;&lt;em&gt;3. Handling Server Response&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Now, let's dive into handling the server's response. In the previously defined callback function, we successfully appended the server's response to the news-feed element. However, let's enhance this process by ensuring we handle different response types appropriately.&lt;/p&gt;

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

&lt;span class="c1"&gt;// Define the callback function to handle the server response&lt;/span&gt;
&lt;span class="nx"&gt;xhr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;onreadystatechange&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;function &lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;xhr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;readyState&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;4&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="c1"&gt;// Check if the request was successful (status code 200)&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;xhr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;status&lt;/span&gt; &lt;span class="o"&gt;===&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="c1"&gt;// Process the server response and update the news feed&lt;/span&gt;
      &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;response&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;xhr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;responseText&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt; &lt;span class="c1"&gt;// Assuming the response is in JSON format&lt;/span&gt;

      &lt;span class="c1"&gt;// Check if the response is an array (adjust as per your server response structure)&lt;/span&gt;
      &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nb"&gt;Array&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;isArray&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="c1"&gt;// Loop through the response and append each item to the news feed&lt;/span&gt;
        &lt;span class="nx"&gt;response&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;forEach&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nf"&gt;function &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
          &lt;span class="nf"&gt;appendNewsFeedItem&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
        &lt;span class="p"&gt;});&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Invalid server response format.&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="p"&gt;}&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="k"&gt;else&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="c1"&gt;// Handle errors gracefully (display an error message, log, etc.)&lt;/span&gt;
      &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Error loading more content. Status:&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;xhr&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;status&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="c1"&gt;// Function to append a news feed item to the DOM&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt; &lt;span class="nf"&gt;appendNewsFeedItem&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// Create a new div element for the news feed item&lt;/span&gt;
  &lt;span class="kd"&gt;var&lt;/span&gt; &lt;span class="nx"&gt;newsFeedItem&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;createElement&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;div&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="c1"&gt;// Assuming each item has a 'content' property (adjust as per your server response structure)&lt;/span&gt;
  &lt;span class="nx"&gt;newsFeedItem&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;textContent&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;content&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

  &lt;span class="c1"&gt;// Append the news feed item to the 'news-feed' element&lt;/span&gt;
  &lt;span class="nb"&gt;document&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getElementById&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;news-feed&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;appendChild&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;newsFeedItem&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;



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

&lt;/div&gt;

&lt;p&gt;&lt;em&gt;Result&lt;/em&gt;&lt;/p&gt;

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

&lt;h2&gt;
  
  
  Challenges and Solutions
&lt;/h2&gt;

&lt;p&gt;Ajax, while powerful, comes with its own set of challenges. Let's explore common issues and how to tackle them:&lt;/p&gt;

&lt;h3&gt;
  
  
  Cross-Origin Requests (CORS)
&lt;/h3&gt;

&lt;p&gt;Challenge:&lt;br&gt;
Browsers often restrict requests to a different domain for security reasons.&lt;/p&gt;

&lt;p&gt;Solution:&lt;br&gt;
Configure your server to include appropriate CORS headers to allow cross-origin requests. This ensures your Ajax requests can reach different domains.&lt;/p&gt;

&lt;h3&gt;
  
  
  Handling Errors
&lt;/h3&gt;

&lt;p&gt;Challenge:&lt;br&gt;
Errors during Ajax requests need to be handled gracefully to maintain a smooth user experience.&lt;/p&gt;

&lt;p&gt;Solution:&lt;br&gt;
Implement robust error-handling mechanisms. Display user-friendly error messages, log errors to the console, or use a combination of both to ensure issues don't go unnoticed.&lt;/p&gt;

&lt;h3&gt;
  
  
  SEO Concerns
&lt;/h3&gt;

&lt;p&gt;Challenge:&lt;br&gt;
Search engines may struggle to index dynamically loaded content, impacting your site's SEO.&lt;/p&gt;

&lt;p&gt;Solution:&lt;br&gt;
Consider server-side rendering or pre-rendering to provide search engines with static content. This ensures your dynamically loaded content doesn't get overlooked during indexing.&lt;/p&gt;

&lt;h2&gt;
  
  
  Best Practices for Overcoming Challenges
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;Cross-Origin Resource Sharing (CORS): Configure your server to include the appropriate headers for CORS.&lt;/li&gt;
&lt;li&gt;Error Handling: Implement clear and user-friendly error messages. Log errors for developer insights.&lt;/li&gt;
&lt;li&gt;SEO-Friendly Implementation: Combine dynamic loading with server-side rendering or pre-rendering for optimal SEO.&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;In a nutshell, Ajax can turn your web pages from static to dynamic, providing users with a more enjoyable experience. We've covered the basics, dabbled in some code, and even tackled a few challenges. Now it's your turn to shine as a web developer!&lt;br&gt;
Get ready to make your web pages feel a little more lighter and user focused. &lt;/p&gt;

&lt;p&gt;lemme know in the comment section if this is the first time you are reading of Ajax or have you been using this before now, share your experience too.  &lt;/p&gt;

</description>
      <category>webdev</category>
      <category>javascript</category>
      <category>productivity</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>CSS Grid vs. Flexbox: Choosing the Right Layout Technique</title>
      <dc:creator>Katerina Braide</dc:creator>
      <pubDate>Sat, 30 Dec 2023 21:42:38 +0000</pubDate>
      <link>https://dev.to/braide/css-grid-vs-flexbox-choosing-the-right-layout-technique-1hfa</link>
      <guid>https://dev.to/braide/css-grid-vs-flexbox-choosing-the-right-layout-technique-1hfa</guid>
      <description>&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fax6nim80k85kwmzzog3s.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fax6nim80k85kwmzzog3s.jpg" alt="Image description" width="800" height="400"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;The choice between CSS Grid and Flexbox is like choosing between pizza and tacos – they're both awesome, but you need the right one for the moment. It's a common challenge for web developers trying to create effective and responsive layouts.&lt;/p&gt;

&lt;p&gt;After reading this article, you will know and understanding their strengths, use cases, and considerations associated with CSS Grid and Flexbox. &lt;/p&gt;

&lt;h2&gt;
  
  
  CSS Grid
&lt;/h2&gt;

&lt;p&gt;CSS Grid is a powerful two-dimensional layout system for creating complex grid-based designs. It offers precise control over both rows and columns, making it ideal for organizing content in intricate layouts. With explicit column and row definitions, developers can easily achieve precise element placement, making it well-suited for designs that demand meticulous control.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqs8ulx0sjq3atcicuahs.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqs8ulx0sjq3atcicuahs.gif" alt="Image description" width="400" height="300"&gt;&lt;/a&gt;&lt;br&gt;
&lt;em&gt;Code sample&lt;/em&gt;&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="nc"&gt;.grid-container&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;grid&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="py"&gt;grid-template-columns&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;repeat&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="m"&gt;3&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="m"&gt;1&lt;/span&gt;&lt;span class="n"&gt;fr&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="py"&gt;gap&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;10px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Flexbox
&lt;/h2&gt;

&lt;p&gt;Flexbox, short for Flexible Box, is a one-dimensional layout system designed for handling content distribution in a single direction—either horizontally or vertically. Flexbox excels in creating flexible and dynamic layouts, especially useful for arranging items within a container, accommodating various screen sizes and devices. Its simplicity and powerful alignment capabilities make it an excellent choice for handling the challenges of responsive design.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuuoxmr3ouxygayt9xl87.gif" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/cdn-cgi/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fuuoxmr3ouxygayt9xl87.gif" alt="Image description" width="800" height="417"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;em&gt;code sample&lt;/em&gt;&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="nc"&gt;.flex-container&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="nl"&gt;display&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;flex&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;justify-content&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="n"&gt;space-around&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;align-items&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nb"&gt;center&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;height&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;100vh&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;span class="p"&gt;}&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Use Cases and Strengths
&lt;/h2&gt;

&lt;p&gt;Understanding the use cases and strengths of CSS Grid and Flexbox is important in making informed layout decisions for web development projects.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;CSS Grid:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Ideal for complex layouts requiring precise control over both rows and columns.&lt;/li&gt;
&lt;li&gt;Suited for designs with a grid-based structure, such as card layouts, image galleries, and multi-column interfaces.&lt;/li&gt;
&lt;li&gt;Facilitates the creation of responsive layouts with minimal media queries due to its two-dimensional nature.&lt;/li&gt;
&lt;/ul&gt;


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

&lt;p&gt;Flexbox:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Perfect for one-dimensional layouts where content needs to be distributed along a single axis.&lt;/li&gt;
&lt;li&gt;Well-suited for arranging items in a row or column, such as navigation menus, form elements, and flexible content containers.&lt;/li&gt;
&lt;li&gt;Offers powerful alignment properties, making it easy to center content both vertically and horizontally.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Responsive Design Considerations
&lt;/h2&gt;

&lt;p&gt;In the realm of responsive web design, the choice between CSS Grid and Flexbox plays a crucial role in creating layouts that adapt seamlessly to various screen sizes and devices.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;CSS Grid:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Excel in handling complex, multi-dimensional layouts for large screens.&lt;/li&gt;
&lt;li&gt;Allows for easy reordering of grid items, enhancing flexibility in adapting to different viewports.&lt;/li&gt;
&lt;li&gt;Enables the creation of responsive designs without excessive reliance on media queries.&lt;/li&gt;
&lt;/ul&gt;


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

&lt;p&gt;Flexbox:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Particularly effective for handling one-dimensional layouts that require flexibility in content distribution.&lt;/li&gt;
&lt;li&gt;Simplifies the creation of responsive designs for smaller screens by easily stacking or aligning items along a single axis.&lt;/li&gt;
&lt;li&gt;Provides an intuitive way to reorder and restructure content based on the available screen real estate.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Browser Compatibility and Support
&lt;/h2&gt;

&lt;p&gt;While both CSS Grid and Flexbox are widely supported in modern browsers, it's essential for developers to consider compatibility when choosing a layout technique.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;CSS Grid:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Generally well-supported in modern browsers, including Chrome, Firefox, Safari, and Edge.&lt;/li&gt;
&lt;li&gt;Considerations for partial support in older versions of Internet Explorer may be necessary, depending on the project's target audience.&lt;/li&gt;
&lt;/ul&gt;


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

&lt;p&gt;Flexbox:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Widely supported in modern browsers, making it a reliable choice for most web projects.&lt;/li&gt;
&lt;li&gt;May require vendor prefixes for older versions of certain browsers, and developers should be mindful of potential quirks in Internet Explorer.&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Which one is better?
&lt;/h2&gt;

&lt;p&gt;The choice between CSS Grid and Flexbox depends on the specific requirements of your layout. Neither is inherently "better" than the other; they serve different purposes.&lt;/p&gt;

&lt;p&gt;CSS Grid is well-suited for complex, two-dimensional layouts where precise control over rows and columns is necessary. It's great for grid-based designs and offers features like item placement and reordering.&lt;/p&gt;

&lt;p&gt;Flexbox is more suitable for one-dimensional layouts, providing a simpler way to distribute space along a single axis. It's excellent for aligning items within a container and handling flexible content structures.&lt;/p&gt;

&lt;p&gt;In many cases, projects use a combination of both CSS Grid and Flexbox to leverage the strengths of each in different parts of the layout. Understanding the requirements of your design and applying the appropriate technique based on those needs will lead to the most effective and efficient results.&lt;/p&gt;

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

&lt;p&gt;For hands on practices and deeper understanding of what you just read, you might consider&lt;/p&gt;

&lt;p&gt;Reading this &lt;a href="https://medium.com/@michgoldennathan17/css-grid-vs-flexbox-a-critique-524638e36e67"&gt;here&lt;/a&gt;&lt;br&gt;
Or watching &lt;a href="https://youtu.be/3elGSZSWTbM?si=u9Qcd2IlHagclL9G"&gt;this&lt;/a&gt;&lt;/p&gt;

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

&lt;p&gt;Both are perfect choice depending on what you want to achieve. &lt;/p&gt;

&lt;p&gt;As I've explained, CSS Grid shines in scenarios demanding intricate two-dimensional layouts. Its explicit control over rows and columns makes it an excellent choice for projects with complex grid structures, reducing the need for extensive media queries. The ability to reorder grid items effortlessly enhances responsiveness across various screen sizes.&lt;/p&gt;

&lt;p&gt;In contrast, Flexbox excels in handling one-dimensional layouts, providing an intuitive solution for content distribution along a single axis. Its simplicity and powerful alignment properties make it a go-to choice for responsive designs, allowing easy adaptation to different viewports by stacking or aligning items.&lt;/p&gt;

&lt;p&gt;i love reading your comments and knowing what you think too, which one do you use frequently and why?&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>css</category>
      <category>productivity</category>
    </item>
    <item>
      <title>Secure Web Authentication with a Serverless API: A Quick Guide</title>
      <dc:creator>Katerina Braide</dc:creator>
      <pubDate>Sun, 17 Dec 2023 17:59:54 +0000</pubDate>
      <link>https://dev.to/braide/css-deep-4d76</link>
      <guid>https://dev.to/braide/css-deep-4d76</guid>
      <description>&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--BZNaw4vn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1xd72exo6xkahmedj8sc.jpeg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--BZNaw4vn--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_800/https://dev-to-uploads.s3.amazonaws.com/uploads/articles/1xd72exo6xkahmedj8sc.jpeg" alt="" width="800" height="450"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;h2&gt;
  
  
  Introduction
&lt;/h2&gt;

&lt;p&gt;In the realm of web development, robust security measures are crucial, particularly when it comes to user authentication. This article will guide you through the process of implementing a secure web authentication system using a Serverless API. &lt;/p&gt;

&lt;p&gt;By the end, you'll have the knowledge and tools to create a scalable and resilient authentication system for your web applications.&lt;/p&gt;

&lt;h3&gt;
  
  
  What Is Web Authentication?
&lt;/h3&gt;

&lt;p&gt;Web authentication verifies the identity of users accessing a web application, ensuring that they are who they claim to be. Achieved through credentials like usernames and passwords, it often includes multi-factor authentication (MFA) for added security. The goal is to protect sensitive data and restrict access to authorized individuals.&lt;/p&gt;

&lt;h3&gt;
  
  
  Benefits of Web Authentication
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Security: Web authentication provides a crucial layer of security by preventing unauthorized access to sensitive user data and application features.&lt;/li&gt;
&lt;li&gt;Data Protection: By verifying user identities, web authentication safeguards personal and confidential information, protecting users from potential data breaches.&lt;/li&gt;
&lt;li&gt;User Accountability: Authentication enables the tracking and accountability of user actions, helping administrators monitor and manage user activity within the application.&lt;/li&gt;
&lt;li&gt;Trust and User Confidence: Robust authentication mechanisms build trust among users, enhancing their confidence in the application's ability to protect their data and privacy.&lt;/li&gt;
&lt;li&gt;Compliance: Many regulatory frameworks and industry standards require robust authentication practices to ensure compliance with data protection and privacy regulations.&lt;/li&gt;
&lt;li&gt; Customization of User Experience: Authentication allows for personalized user experiences, tailoring access and permissions based on user roles and responsibilities.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  What Is an API?
&lt;/h3&gt;

&lt;p&gt;An API, or Application Programming Interface, is a set of rules and tools that allows different software applications to communicate with each other. It defines the methods and data formats that applications can use to request and exchange information. APIs facilitate the integration of different systems, enabling them to work together seamlessly.&lt;/p&gt;

&lt;h3&gt;
  
  
  What Is a Serverless API?
&lt;/h3&gt;

&lt;p&gt;A serverless API, also known as a serverless function or serverless endpoint, is a type of backend service that runs in a serverless computing environment. Unlike traditional server-based architectures, serverless APIs do not require the provisioning or management of servers. Instead, they automatically scale in response to demand and execute functions in ephemeral, stateless containers. Serverless APIs are event-driven, responding to triggers such as HTTP requests, database changes, or file uploads. Commonly hosted on cloud platforms, serverless APIs simplify infrastructure management, reduce costs, and allow developers to focus on code functionality rather than server maintenance.&lt;/p&gt;

&lt;h3&gt;
  
  
  Why Use a Serverless API?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Scalability: Serverless APIs automatically scale to handle varying workloads, ensuring optimal performance without manual intervention.&lt;/li&gt;
&lt;li&gt;Cost Efficiency: With serverless, you pay only for the compute resources used during function execution, leading to potential cost savings compared to maintaining dedicated servers.&lt;/li&gt;
&lt;li&gt;Simplified Deployment: Serverless APIs simplify deployment with rapid development cycles, automatic scaling, and effortless management of infrastructure.&lt;/li&gt;
&lt;li&gt;Focus on Code: Developers can concentrate on writing code and building features without the burden of server provisioning, maintenance, or scaling concerns.&lt;/li&gt;
&lt;li&gt;Event-Driven Architecture: Serverless APIs thrive on event-driven architectures, responding to specific events or triggers, making them well-suited for various use cases, including web authentication.&lt;/li&gt;
&lt;li&gt;Reduced Operational Overhead: Serverless APIs abstract away infrastructure management tasks, reducing the operational overhead traditionally associated with maintaining servers.&lt;/li&gt;
&lt;li&gt;Flexibility and Agility: Serverless architecture allows for quick development and deployment, fostering an agile development process and enabling faster time-to-market for applications.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  A Step-by-Step Guide On How To Use One
&lt;/h2&gt;

&lt;h3&gt;
  
  
  Step 1: Define Authentication Requirements
&lt;/h3&gt;

&lt;p&gt;Before diving into implementation, it's essential to clearly define your authentication requirements. Consider the following aspects:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;User Roles and Access Levels: Identify different user roles and define their respective access levels. Consider the actions each role should be able to perform and the data they can access.&lt;/li&gt;
&lt;li&gt;Authentication Methods: Choose the appropriate authentication methods for your application, such as Username/Password, OAuth, or JSON Web Tokens (JWT).&lt;/li&gt;
&lt;li&gt;Security Requirements: Specify security measures, including secure password storage, token-based authentication, and the use of HTTPS to protect data in transit.&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Step 2: Choose a Serverless Provider
&lt;/h3&gt;

&lt;p&gt;Select a serverless provider that aligns with your application's needs. Let's use &lt;a href="https://aws.amazon.com/pm/lambda/?trk=3da65280-58c3-4e9f-8d04-5402461fedce&amp;amp;sc_channel=ps&amp;amp;ef_id=CjwKCAiAyp-sBhBSEiwAWWzTnodXPB9uSc2y6Nv9TQrzXyO49_hDvI11uwme9cukNI94i8bjdFt5wBoC1JQQAvD_BwE:G:s&amp;amp;s_kwcid=AL!4422!3!651612444455!e!!g!!aws%20lambda!19836376555!148728891764&amp;amp;gclid=CjwKCAiAyp-sBhBSEiwAWWzTnodXPB9uSc2y6Nv9TQrzXyO49_hDvI11uwme9cukNI94i8bjdFt5wBoC1JQQAvD_BwE"&gt;AWS Lambda&lt;/a&gt; for this example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Install AWS SDK
npm install aws-sdk 
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Configure your AWS credentials:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;&lt;span class="c1"&gt;// serverlessFunctions.js&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;AWS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;aws-sdk&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;AWS&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;config&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;update&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;region&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;your-region&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;accessKeyId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;your-access-key&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;secretAccessKey&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;your-secret-key&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 3: Set Up Serverless Functions
&lt;/h3&gt;

&lt;p&gt;Create serverless functions to handle user registration, login, and token generation. Use Node.js and the AWS SDK:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;
&lt;span class="c1"&gt;// serverlessFunctions.js&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;AWS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;aws-sdk&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;bcrypt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;bcrypt&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;jwt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;jsonwebtoken&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;dynamoDB&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;AWS&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;DynamoDB&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;DocumentClient&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;tableName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;UsersTable&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// Function to register a new user&lt;/span&gt;
&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;registerUser&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;username&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;password&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;hashedPassword&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;bcrypt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;hash&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;password&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;params&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;TableName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;tableName&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;Item&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;username&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;password&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;hashedPassword&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;};&lt;/span&gt;

  &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;dynamoDB&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;put&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;params&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;promise&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;statusCode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;User registered successfully&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;}),&lt;/span&gt;
  &lt;span class="p"&gt;};&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="c1"&gt;// Function to authenticate and generate a JWT token&lt;/span&gt;
&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;login&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;username&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;password&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;params&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;TableName&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;tableName&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;Key&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;username&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;};&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;userData&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;dynamoDB&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;get&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;params&lt;/span&gt;&lt;span class="p"&gt;).&lt;/span&gt;&lt;span class="nf"&gt;promise&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;

  &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="nx"&gt;userData&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Item&lt;/span&gt; &lt;span class="o"&gt;||&lt;/span&gt; &lt;span class="o"&gt;!&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;bcrypt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;compare&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;password&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;userData&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Item&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;password&lt;/span&gt;&lt;span class="p"&gt;)))&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;statusCode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;401&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Invalid username or password&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;}),&lt;/span&gt;
    &lt;span class="p"&gt;};&lt;/span&gt;
  &lt;span class="p"&gt;}&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;token&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;jwt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sign&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;username&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;your-secret-key&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;expiresIn&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;1h&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;

  &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;statusCode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;token&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;h3&gt;
  
  
  Step 4: Use a Database for User Management
&lt;/h3&gt;

&lt;p&gt;Configure DynamoDB:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;
&lt;span class="c1"&gt;// serverlessFunctions.js&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;AWS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;aws-sdk&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="nx"&gt;AWS&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;config&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;update&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;region&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;your-region&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;accessKeyId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;your-access-key&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;secretAccessKey&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;your-secret-key&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;dynamoDB&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;AWS&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;DynamoDB&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;DocumentClient&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;tableName&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;UsersTable&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 5: Implement Secure Password Storage
&lt;/h3&gt;

&lt;p&gt;Ensure secure password storage using bcrypt:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Install bcrypt library
npm install bcrypt
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Integrate bcrypt into the registration function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;
&lt;span class="c1"&gt;// serverlessFunctions.js&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;bcrypt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;bcrypt&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// ... &lt;/span&gt;

&lt;span class="c1"&gt;// Function to register a new user&lt;/span&gt;
&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;registerUser&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;username&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;password&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;hashedPassword&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;await&lt;/span&gt; &lt;span class="nx"&gt;bcrypt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;hash&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;password&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="mi"&gt;10&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="c1"&gt;// ... &lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 6: Token-based Authentication with JWT
&lt;/h3&gt;

&lt;p&gt;Implement &lt;a href="https://jwt.io/introduction"&gt;JWT &lt;/a&gt;for token-based authentication:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Install jsonwebtoken library
npm install jsonwebtoken
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Integrate JWT into the login function:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;
&lt;span class="c1"&gt;// serverlessFunctions.js&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;jwt&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;jsonwebtoken&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// ... &lt;/span&gt;

&lt;span class="c1"&gt;// Function to authenticate and generate a JWT token&lt;/span&gt;
&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;login&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;username&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;password&lt;/span&gt; &lt;span class="p"&gt;}&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;parse&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;body&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="c1"&gt;// ...&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;token&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;jwt&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;sign&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;username&lt;/span&gt; &lt;span class="p"&gt;},&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;your-secret-key&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt; &lt;span class="na"&gt;expiresIn&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;1h&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;

  &lt;span class="c1"&gt;// ...&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 7: Set Up API Gateway
&lt;/h3&gt;

&lt;p&gt;Configure an &lt;a href="https://aws.amazon.com/api-gateway/"&gt;API Gateway&lt;/a&gt; for communication:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Create an API in the AWS API Gateway.&lt;/li&gt;
&lt;li&gt;Set up resource and method for each function (GET for login, POST for registration).&lt;/li&gt;
&lt;li&gt;Secure the API using AWS Identity and Access Management (IAM) roles.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Step 8: Implement Secure HTTPS
&lt;/h3&gt;

&lt;p&gt;Ensure secure communication by configuring the API Gateway to use HTTPS:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;In the API Gateway console, select your API.&lt;/li&gt;
&lt;li&gt;Under "Stages," select the desired stage (e.g., "prod").&lt;/li&gt;
&lt;li&gt;In the "Settings" tab, enable "HTTPS Only.”&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Step 9: Implement Multi-Factor Authentication (Optional)
&lt;/h3&gt;

&lt;p&gt;Explore the implementation of MFA using services like Amazon Cognito or Auth0.&lt;/p&gt;

&lt;p&gt;Multi-Factor Authentication (MFA) adds an extra layer of security by requiring users to verify their identity through multiple methods. This step is optional but highly recommended for applications that prioritize enhanced security. We'll explore the implementation of MFA using Amazon Cognito, a service that simplifies identity management.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;1. Setting Up Amazon Cognito:&lt;/em&gt;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Go to the &lt;a href="https://console.aws.amazon.com/cognito/"&gt;Amazon Cognito Console&lt;/a&gt;.&lt;/li&gt;
&lt;li&gt;Create a new user pool, specifying settings like MFA and account recovery.&lt;/li&gt;
&lt;li&gt;Note the User Pool ID and create an app client.&lt;/li&gt;
&lt;li&gt;Integrate Cognito in Serverless Functions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Update your server-less functions to integrate with Amazon Cognito:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight javascript"&gt;&lt;code&gt;
&lt;span class="c1"&gt;// serverlessFunctions.js&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;AWS&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;aws-sdk&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;AmazonCognitoIdentity&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nf"&gt;require&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;amazon-cognito-identity-js&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;poolData&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="na"&gt;UserPoolId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;your-user-pool-id&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="na"&gt;ClientId&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;your-app-client-id&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;userPool&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;AmazonCognitoIdentity&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;CognitoUserPool&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;poolData&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

&lt;span class="c1"&gt;// Function to register a new user with MFA&lt;/span&gt;
&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;registerUserWithMFA&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// ... &lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;attributeList&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;[&lt;/span&gt;
    &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;AmazonCognitoIdentity&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;CognitoUserAttribute&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt;
      &lt;span class="na"&gt;Name&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;email&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;Value&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;user@example.com&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="p"&gt;}),&lt;/span&gt;
  &lt;span class="p"&gt;];&lt;/span&gt;

  &lt;span class="nx"&gt;userPool&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;signUp&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;username&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;password&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;attributeList&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="kc"&gt;null&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;if &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;statusCode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;500&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Error registering user&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;error&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;message&lt;/span&gt; &lt;span class="p"&gt;}),&lt;/span&gt;
      &lt;span class="p"&gt;};&lt;/span&gt;
    &lt;span class="p"&gt;}&lt;/span&gt;

    &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;cognitoUser&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;result&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;user&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
    &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;User registered with ID &lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="o"&gt;+&lt;/span&gt; &lt;span class="nx"&gt;cognitoUser&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getUsername&lt;/span&gt;&lt;span class="p"&gt;());&lt;/span&gt;

    &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="na"&gt;statusCode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
      &lt;span class="na"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;User registered successfully with MFA&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;}),&lt;/span&gt;
    &lt;span class="p"&gt;};&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;

&lt;span class="c1"&gt;// Function to authenticate and generate a JWT token with MFA&lt;/span&gt;
&lt;span class="nx"&gt;module&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;exports&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;loginWithMFA&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;async &lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;event&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="c1"&gt;// ... &lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;authenticationData&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;Username&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;username&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;Password&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;password&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;};&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;authenticationDetails&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;AmazonCognitoIdentity&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;AuthenticationDetails&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;authenticationData&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;userData&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;Username&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;username&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
    &lt;span class="na"&gt;Pool&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;userPool&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
  &lt;span class="p"&gt;};&lt;/span&gt;

  &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;cognitoUser&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;new&lt;/span&gt; &lt;span class="nx"&gt;AmazonCognitoIdentity&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nc"&gt;CognitoUser&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;userData&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

  &lt;span class="nx"&gt;cognitoUser&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;authenticateUser&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;authenticationDetails&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="na"&gt;onSuccess&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;session&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="kd"&gt;const&lt;/span&gt; &lt;span class="nx"&gt;token&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="nx"&gt;session&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;getIdToken&lt;/span&gt;&lt;span class="p"&gt;().&lt;/span&gt;&lt;span class="nf"&gt;getJwtToken&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
      &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Authentication successful, JWT token:&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;token&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;statusCode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="nx"&gt;token&lt;/span&gt; &lt;span class="p"&gt;}),&lt;/span&gt;
      &lt;span class="p"&gt;};&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="na"&gt;onFailure&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;error&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Authentication failed:&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;err&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;statusCode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;401&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;Invalid username or password&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;}),&lt;/span&gt;
      &lt;span class="p"&gt;};&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
    &lt;span class="na"&gt;mfaRequired&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;codeDeliveryDetails&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="o"&gt;=&amp;gt;&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
      &lt;span class="nx"&gt;console&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;log&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;MFA required, confirmation code sent to&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;codeDeliveryDetails&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;Destination&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;

      &lt;span class="c1"&gt;// Prompt user for MFA code and call cognitoUser.sendMFACode(code) to confirm MFA&lt;/span&gt;
      &lt;span class="k"&gt;return&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
        &lt;span class="na"&gt;statusCode&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="mi"&gt;200&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;
        &lt;span class="na"&gt;body&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;JSON&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nf"&gt;stringify&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;message&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;MFA required&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt; &lt;span class="p"&gt;}),&lt;/span&gt;
      &lt;span class="p"&gt;};&lt;/span&gt;
    &lt;span class="p"&gt;},&lt;/span&gt;
  &lt;span class="p"&gt;});&lt;/span&gt;
&lt;span class="p"&gt;};&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 10: Test and Monitor
&lt;/h3&gt;

&lt;p&gt;Thoroughly test your authentication system using tools like &lt;a href="https://www.postman.com"&gt;Postman&lt;/a&gt;. Implement logging and monitoring for suspicious activities.&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;Get AWS API Gateway tutorial &lt;a href="https://youtu.be/qnVfWG8N7Fw?si=4ipCdn2tWWpIeXZS"&gt;here&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Setting Up Amazon Cognito &lt;a href="https://youtu.be/8a0vtkWJIA4?si=h8UVbmRcLe4ZJN-m"&gt;here&lt;/a&gt;
&lt;/li&gt;
&lt;li&gt;Token-based Authentication with JWT Look &lt;a href="https://youtu.be/iHNkGQyJxJs?si=0Sz7jJiHqvWp4qRn"&gt;here&lt;/a&gt;
&lt;/li&gt;
&lt;/ul&gt;

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

&lt;p&gt;In summary, adhering to best practices and staying vigilant about security updates is crucial for maintaining the continuous protection of your web application. It's important to recognize that security is a dynamic field, and regular updates play a pivotal role in sustaining a robust authentication system.&lt;/p&gt;

</description>
      <category>webdev</category>
      <category>security</category>
      <category>programming</category>
      <category>aws</category>
    </item>
    <item>
      <title>TCP/IP Overview</title>
      <dc:creator>Katerina Braide</dc:creator>
      <pubDate>Thu, 30 Dec 2021 11:36:39 +0000</pubDate>
      <link>https://dev.to/braide/tcpip-overview-58hg</link>
      <guid>https://dev.to/braide/tcpip-overview-58hg</guid>
      <description>&lt;h2&gt;
  
  
  TCP/IP model
&lt;/h2&gt;

&lt;p&gt;Transmission Control Protocol and Internet Protocol (TCP/IP) is a network model using current internet architecture to standardize computer networking, just like the Open System Interconnection (OSI) model. OSI is widely referenced but TCP/IP is a more recommended model. The main idea of TCP/IP is to allow an application on a computer to send data packets or communicate to another application running on a different computer.&lt;/p&gt;

&lt;h2&gt;
  
  
  Layers of TCP/IP
&lt;/h2&gt;

&lt;p&gt;4 Application layer&lt;br&gt;
3 Transport layer&lt;br&gt;
2 Internet layer&lt;br&gt;
1 Data link and physical layer&lt;/p&gt;

&lt;p&gt;These are the original layers numbered from the bottom up just like the OSI model. However the layers have been updated to:&lt;/p&gt;

&lt;p&gt;5 Application layer&lt;br&gt;
4 Transport layer&lt;br&gt;
3 Network layer&lt;br&gt;
2 Data link layer&lt;br&gt;
1 Physical layer&lt;/p&gt;

&lt;p&gt;One splitted layer and one renamed layer. The application, presentation and session layers of the OSI model are compressed to form just the application layer for the TCP/IP model.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Layer 5/Application:&lt;/strong&gt; This is mainly used for data representation and application interface. Here we have application protocols such as Hypertext Transfer Protocol (HTTP), File Transfer Protocol (FTP) and Simple Mail Transfer Protocol (SMTP).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Layer 4/Transport:&lt;/strong&gt; This s a process to process communication with the use of port addresses (source and destination) to identify services or applications. The two most common transport protocols are Transmission Control Protocol (TCP) and User Data-gram Protocol (UDP).&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Layer 3/Network:&lt;/strong&gt; This is a node to node communication with the help of IP address to identify devices on a network, routers operate on this layer.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Layer 2/Data link:&lt;/strong&gt; This contains Ethernet and switches. Ethernet also has source and destination addresses but they’re physical addresses, that means they are burned addresses from the company that can’t be changed by user. This layer also helps with flow control and error control.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Layer 1/Physical:&lt;/strong&gt; This is every device that we can felt and touched, like network interface cards and cables. Physical layer takes bits and produces a signal to carry them.&lt;/p&gt;

&lt;h2&gt;
  
  
  How the layers work.
&lt;/h2&gt;

&lt;p&gt;As we send data, each layer will add it’s own bit of information, this is the encapsulation process, where the physical layer transmits the data over to the receiving device, the receiving device then starts to decapsulate the data.&lt;br&gt;
Staring from the application layer which is simply the data, it is passed down to the next layer where the transport information is added, an example could be a TCP header, the data has now been transformed into a segment by breaking the data into pieces, then it moves to the network layer where the IP header is added, causing the segment to become a packet, then moves to the data link layer, Here it’s given a header and a trailer, The header contains mainly the source and destination MAC address and the trailer contains some error checking information to make sure the receiver receives the data correctly, and our packet has been made a frame. Lastly the physical layer, the data is then physically transmitted, thereby completing the encapsulation process.&lt;br&gt;
The encapsulation process has been completed once the data has been transmitted to the receiving computer. To start the decapsulation process, It will check the destination MAC address for that frame and if the frame is correct it will process further to checks the IP information of the packets, again if the packet is correct it will process further to the transport information where it is read and the application data is sent to the receiving application.&lt;/p&gt;

&lt;h2&gt;
  
  
  How some protocols work efficiently well with the TCP/IP model:
&lt;/h2&gt;

&lt;p&gt;Application protocol HTTP shows how web browsers can get contents of a web page from a web server, HTTP has the functionality to ask for contents of web pages by enabling the web browser to request files from the server and giving the server a way to return the contents of those files with the help of uniform resource locators (URL) or universal resource identifiers (URI). This HTTP header includes the request to get a file, the request typically contains the name of the file.&lt;/p&gt;

&lt;p&gt;Transport protocol TCP is widely know for it’s feature of error recovery, it’s works as the error recovery service provided to application layer. TCP/IP needs a mechanism to guarantee successful delivery of data across a network. the TCP header shows a sequence number (SEQ) with each message the network has a problem and fails to deliver the TCP message called a segment with example sequence number7, message7 was lost, that realization by TCP logic causes TCP to send a TCP segment back to the server asking to resend message7. &lt;/p&gt;

&lt;p&gt;Network protocol IP provides several features most importantly addressing and routing. Routers are networking devices that connect the parts of the TCP/IP network together for the purpose of routing IP packets to the correct destination. Routers receive IP packets on various physical interfaces, make decisions based on the IP address included with the packet and then physically forward the packet out to other network interfaces. The TCP/IP network layer using the IP protocol provides a service of forwarding IP packets from one device to another. Sending data back and forth to IP addresses is called IP routing.&lt;/p&gt;

&lt;p&gt;Data link layer and physical layers define the protocols and hardware required to deliver data across some physical network. The physical layer defines the electrical signals that flow over the cables, rules and conventions exist when sending data over the cable however those rules exist in the data link layer, when a host or router’s IP process chooses to send an IP packet to another router or host, the host or router then uses data link layer details to send that packet to the next host/router.&lt;/p&gt;

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

&lt;p&gt;TCP/IP  is very modular, this makes it easy to add additional protocols and hardware when they are developed. TCP/IP was produced to make sure that data is reliable on the Internet because with ARPANET everything was very sensitive. This model shows a grand overview of how systems on a network behaves. It helps make everything user-friendly, It also avoids repeating work already done by  some other standards body or vendor consortium by simply referring to standards or protocols created by those groups.&lt;br&gt;
Layer 7, 6 and 5 of the OSI model are grouped in to produce PDU for the transport layer of the TCP/IP model called data. The PDU is mostly in the form of binary. PDU is the data that is broken into segments. We segment our data for security and multiplexing.&lt;/p&gt;

</description>
      <category>model</category>
      <category>network</category>
      <category>beginners</category>
    </item>
    <item>
      <title>Basic OSI</title>
      <dc:creator>Katerina Braide</dc:creator>
      <pubDate>Sun, 26 Dec 2021 21:31:16 +0000</pubDate>
      <link>https://dev.to/braide/basic-osi-1pa4</link>
      <guid>https://dev.to/braide/basic-osi-1pa4</guid>
      <description>&lt;h2&gt;
  
  
  &lt;strong&gt;What is OSI?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;OSI stands for Open System Interconnection, it’s a conceptual framework for how application communicate over a network. The purpose of the OSI model is to facilitate communication between different systems without requiring changes to the logic of the underlying hardware and software. OSI has a stack of seven layers within the model and the layers are used to help user identify what is happening within a networking system.&lt;/p&gt;

&lt;h2&gt;
  
  
  &lt;strong&gt;What is OSI layer?&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;The OSI layer are typically described from the top layer down. With the help of layering we decompose the problem of building a network into manageable components (layers), these layers help with modular design and easy troubleshooting. Going down and up the stack is called encapsulating and decapsulating respectfully. The layers are:&lt;/p&gt;

&lt;p&gt;7-  Application&lt;br&gt;
6-  Presentation&lt;br&gt;
5-  Session&lt;br&gt;
4-  Transport&lt;br&gt;
3-  Network&lt;br&gt;
2-  Data link&lt;br&gt;
1-  Physical&lt;/p&gt;

&lt;p&gt;These layers are provided by a mixture of network card drivers, application, operating system, and networking hardware that enable the transmission of signals over  WI-fi, Ethernet, fiber optic, and other wireless protocols. We’ll describe the layer from the top down as the top layer is the application layer or layer 7.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Layer 7/Application&lt;/strong&gt;: This is the layer that users interact with. The application layer provides protocols as network services to the end user, that work with the data the client is using. An example of these protocols may be Hypertext Transfer Protocol (HTTP) that is used with web browsers such as google chrome and internet explorer. Another example is Simple Mail Transfer Protocol (SMTP), a protocol for emails and such, All of those interactive application provide a set of services that allow the application layer to supply data to and receive data from the presentation layer. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Layer 6/Presentation&lt;/strong&gt;: This performs the task of syntax processing or converting data from one format to another. For example, consider you are buying a concert ticket. These transactions are handled in a secure transmission which means that the data passing between the website application will transmit encrypted data to the presentation layer that will need to be decrypted and processed. This layer translates the data from the top layer, which is presented in application format, to network format and vice versa. After the presentation layer processes the data and changes it’s format from one to another, the information is then passed to the session layer or the application layer depending on if the data is transmitting or receiving. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Layer 5/Session&lt;/strong&gt;: This is where the conclusion of connections between devices occur. This layer supports multiple types of connections as well as being responsible for authentication and re-connection when and if a network interruption occurs. After this session is established the data then passes to or from the transport layer.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Layer 4/Transport&lt;/strong&gt;: This is responsible for the transmission of data across network connections. This layer coordinates how much data to send, speed of data, direction of data, and such. These services may be provided by Transmission Control Protocol (TCP) and User Data-gram Protocol (UDP), which are the most widely known protocols for internet applications. Other protocols may provide additional functionalities such as error recovery and re-transmission. Once the transport layer has completed it’s function, the data is then passed to or from the network layer.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Layer 3/Network&lt;/strong&gt;: This handles the routing of the data. After the data gets to this layer, each frame of data is examined to check if the data has  arrived at it’s ultimate target. The layer sends data to the correct destination on outgoing transmissions and receives incoming transmissions as well. The IP portion of TCP/IP is the commonly known network layer for the internet. This layer also manages the mapping between logical addresses and physical addresses, for IP addresses, this is accomplished through Address Resolution Protocol (ARP). The data is then passed to the next required layer.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Layer 2/Data link&lt;/strong&gt;: This layer is often divided into sub-layers called Media Access Control (MAC) or Logical Link Control (LLC). The layer sets up links across the physical network. When this layer receives data from the physical layer, it checks for transmission errors and then packages the bits into data frames. From there, this layer manages the physical addressing methods for MAC or LLC layers. An example of MAC layer includes 802.11 wireless specifications as well as Ethernet. At the data link layer, the data passes to or from the final layer.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Layer 1/Physical&lt;/strong&gt;: This is the electrical layer of the model. This layer includes all the network cables, wireless radio frequencies, receivers, repeaters, connectors, transceivers, pulses of light, electric voltages, power plugs, cable pin-outs, etc. When troubleshooting problems, this is the first place to start. Is the device plugged in? Is the wireless card working? At this layer, the model transmits the digital data bits from source or sending devices physical layer, over network communications media, which can be electrical, mechanical, or radio, to the receiving or destination devices physical layer.&lt;/p&gt;

&lt;p&gt;Layer 7, 6 and 5 can be grouped in, the sole responsibility for the three of these is to produce protocol data unit (PDU) for the transport layer.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;How the layers work!&lt;/strong&gt;&lt;br&gt;
Let’s say you send an email, the data travels through the OSI model, adding and processing data on each layer, this process is called encapsulation&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;step 1: Our work creates the data. the email you wrote, the email addresses, etc and gets ready to send it using Simple Mail Transfer Protocol (SMTP).&lt;/li&gt;
&lt;li&gt;Step 2: The data is formatted in a way the receiving device will understand, in this example let’s say &lt;a href="mailto:QsR3@4Fgg"&gt;QsR3@4Fgg&lt;/a&gt;. This layer could also encrypt the data if needed.&lt;/li&gt;
&lt;li&gt;step 3:  A session with receiving mail server is started.&lt;/li&gt;
&lt;li&gt;step 4: This is where it decides to use TCP or UDP. In this example we’ll use TCP to make sure every packet gets delivered also the source and destination port is added to the data.&lt;/li&gt;
&lt;li&gt;step 5: The IP address of the mail server is added as the destination and the source IP address is also added to the data.&lt;/li&gt;
&lt;li&gt;step 6: The MAC address of the router and the source MAC address of the host is added to the data.&lt;/li&gt;
&lt;li&gt;step 7: The data is sent out on the network using Ethernet so when the data reaches the other side the receiving device will process the data in the same way but in reverse starting from the bottom up.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;&lt;strong&gt;OSI helps with troubleshooting!&lt;/strong&gt;&lt;br&gt;
It’s easier to diagnose the problem with the network if you go through this model, checking every layer step by step for example, layer1: are all the cables plugs in? is the network card functioning?. Layer2: is the switch bad?. Layer3: is the route functioning? Do i have the correct address? And the process goes on and on from there&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;conclusion&lt;/strong&gt;&lt;br&gt;
The OSI model is more of a reference, a guideline for developers and vendors to smoothen the delegation of responsibilities  to enable us understand what the communication process entails and the progress of developing communication products and software programs that will work in cooperation with a commonly established model. Once you understand the model, you can then understand which protocol and devices will be compatible with one another.&lt;/p&gt;

</description>
      <category>network</category>
      <category>troubleshooting</category>
      <category>beginners</category>
    </item>
  </channel>
</rss>
