<?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: Rajat Yadav</title>
    <description>The latest articles on DEV Community by Rajat Yadav (@rajat_yadav_).</description>
    <link>https://dev.to/rajat_yadav_</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%2F3181428%2F310e1c57-374d-40dd-8524-9500ccd30bad.jpg</url>
      <title>DEV Community: Rajat Yadav</title>
      <link>https://dev.to/rajat_yadav_</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/rajat_yadav_"/>
    <language>en</language>
    <item>
      <title>CSS Selectors 101: Targeting Elements with Precision</title>
      <dc:creator>Rajat Yadav</dc:creator>
      <pubDate>Thu, 12 Feb 2026 20:04:02 +0000</pubDate>
      <link>https://dev.to/rajat_yadav_/css-selectors-101-targeting-elements-with-precision-4eo6</link>
      <guid>https://dev.to/rajat_yadav_/css-selectors-101-targeting-elements-with-precision-4eo6</guid>
      <description>&lt;p&gt;When you write CSS, you’re always answering one important question:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;“Which elements do I actually want to style?”&lt;/strong&gt;&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Because honestly… without a way to point at specific elements in your HTML, you couldn’t change colors, fonts, spacing etc. Everything would just look default and boring.&lt;/p&gt;

&lt;p&gt;That’s where &lt;strong&gt;CSS selectors&lt;/strong&gt; comes inn.&lt;/p&gt;

&lt;p&gt;Selectors are simply the way you choose which elements get which styles.&lt;/p&gt;

&lt;p&gt;We’ll use a simple “addressing people in a room” analogy, and also show small before/after examples so you can actually see what’s happening.&lt;/p&gt;




&lt;h2&gt;
  
  
  Why CSS Selectors Are Needed
&lt;/h2&gt;

&lt;h3&gt;
  
  
  The Basic Problem
&lt;/h3&gt;

&lt;p&gt;Your HTML page has:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;headings&lt;/li&gt;
&lt;li&gt;paragraphs&lt;/li&gt;
&lt;li&gt;buttons&lt;/li&gt;
&lt;li&gt;links&lt;/li&gt;
&lt;li&gt;lists&lt;/li&gt;
&lt;li&gt;sections&lt;/li&gt;
&lt;li&gt;and many more things&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Your CSS needs to say things like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;“Make all paragraphs blue.”&lt;/li&gt;
&lt;li&gt;“Make this button red.”&lt;/li&gt;
&lt;li&gt;“Make everything inside the sidebar smaller.”&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you had no way to target specific elements, then either:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You style everything the same&lt;/li&gt;
&lt;li&gt;Or you don’t style anything&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Selectors are what lets you say:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Apply these styles to &lt;em&gt;these&lt;/em&gt; elements not all of them.”&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Real-World Analogy: Addressing People
&lt;/h2&gt;

&lt;p&gt;Imagine a room full of people.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;“Everyone named John” → selecting by name (like element selector)&lt;/li&gt;
&lt;li&gt;“Everyone wearing red shirt” → selecting by class&lt;/li&gt;
&lt;li&gt;“The person with badge #42” → selecting by ID&lt;/li&gt;
&lt;li&gt;“Everyone named John sitting in the left corner” → selecting by location (descendant selector)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;CSS selectors work exactly like this. They are just different ways of addressing elements.&lt;/p&gt;




&lt;h2&gt;
  
  
  The Structure of a CSS Rule
&lt;/h2&gt;

&lt;p&gt;Every CSS rule has two parts:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;selector {
  property: value;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Selector&lt;/strong&gt; → which elements&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Declaration block&lt;/strong&gt; → what styles to apply&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you don’t understand selectors, you can’t control where styles go. So honestly, selectors are foundation of CSS.&lt;/p&gt;




&lt;h1&gt;
  
  
  1. Element Selector – Style by Tag Name
&lt;/h1&gt;

&lt;h3&gt;
  
  
  What It Does
&lt;/h3&gt;

&lt;p&gt;An &lt;strong&gt;element selector&lt;/strong&gt; (also called type selector) selects every element that matches a given HTML tag.&lt;/p&gt;

&lt;p&gt;You just write the tag name. No dot. No hash.&lt;/p&gt;

&lt;h3&gt;
  
  
  Syntax
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;elementname {
  /* styles */
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Example
&lt;/h3&gt;

&lt;p&gt;Select all paragraphs:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;p {
  color: blue;
  font-size: 16px;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Select all &lt;code&gt;&amp;lt;h1&amp;gt;&lt;/code&gt;:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;h1 {
  color: darkgreen;
  font-size: 2rem;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now every &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt; becomes blue. Every &lt;code&gt;&amp;lt;h1&amp;gt;&lt;/code&gt; becomes dark green. You didn’t touch the HTML at all.&lt;/p&gt;

&lt;h3&gt;
  
  
  When To Use It
&lt;/h3&gt;

&lt;p&gt;Use element selector when you want &lt;strong&gt;every instance of that tag&lt;/strong&gt; to look same.&lt;/p&gt;

&lt;p&gt;It’s broad and simple.&lt;/p&gt;




&lt;h1&gt;
  
  
  2. Class Selector – Style by Class Name
&lt;/h1&gt;

&lt;h3&gt;
  
  
  What It Does
&lt;/h3&gt;

&lt;p&gt;A &lt;strong&gt;class selector&lt;/strong&gt; selects every element that has a specific class.&lt;/p&gt;

&lt;p&gt;In HTML:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;p class="highlight"&amp;gt;Important text&amp;lt;/p&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;In CSS, you target class using a dot (&lt;code&gt;.&lt;/code&gt;).&lt;/p&gt;

&lt;h3&gt;
  
  
  Syntax
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.classname {
  /* styles */
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The dot means “this is a class”.&lt;/p&gt;

&lt;h3&gt;
  
  
  Example
&lt;/h3&gt;

&lt;p&gt;HTML:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;p class="highlight"&amp;gt;This is important.&amp;lt;/p&amp;gt;
&amp;lt;p&amp;gt;This is normal.&amp;lt;/p&amp;gt;
&amp;lt;p class="highlight"&amp;gt;This is important too.&amp;lt;/p&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;CSS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.highlight {
  background-color: yellow;
  font-weight: bold;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now only the paragraphs with &lt;code&gt;class="highlight"&lt;/code&gt; get yellow background.&lt;/p&gt;

&lt;p&gt;The middle one stays normal.&lt;/p&gt;




&lt;h3&gt;
  
  
  Multiple Classes
&lt;/h3&gt;

&lt;p&gt;You can do:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;class="button primary"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then in CSS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.button.primary { }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This means:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Only elements that have BOTH classes.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Or:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.primary { }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This means:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Any element that has class primary.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Classes are flexible. Many elements can share one class.&lt;/p&gt;




&lt;h3&gt;
  
  
  When To Use Class
&lt;/h3&gt;

&lt;p&gt;Use class when you want to style:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A group of elements&lt;/li&gt;
&lt;li&gt;Reusable components&lt;/li&gt;
&lt;li&gt;Things like buttons, cards, highlights&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Think:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Class = “this type of thing”&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h1&gt;
  
  
  3. ID Selector – Style by ID
&lt;/h1&gt;

&lt;h3&gt;
  
  
  What It Does
&lt;/h3&gt;

&lt;p&gt;An &lt;strong&gt;ID selector&lt;/strong&gt; selects the one element that has a specific id.&lt;/p&gt;

&lt;p&gt;ID should be unique on the page.&lt;/p&gt;

&lt;p&gt;In CSS, ID uses hash (&lt;code&gt;#&lt;/code&gt;).&lt;/p&gt;

&lt;h3&gt;
  
  
  Syntax
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#idvalue {
  /* styles */
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Example
&lt;/h3&gt;

&lt;p&gt;HTML:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;header id="main-header"&amp;gt;Welcome&amp;lt;/header&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;CSS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;#main-header {
  background-color: navy;
  color: white;
  padding: 1rem;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Only that one header gets styled.&lt;/p&gt;




&lt;h3&gt;
  
  
  Class vs ID (Simple Table)
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Feature&lt;/th&gt;
&lt;th&gt;Class&lt;/th&gt;
&lt;th&gt;ID&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Symbol&lt;/td&gt;
&lt;td&gt;&lt;code&gt;.&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;&lt;code&gt;#&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Can reuse?&lt;/td&gt;
&lt;td&gt;Yes&lt;/td&gt;
&lt;td&gt;No (should be unique)&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Use for&lt;/td&gt;
&lt;td&gt;Group&lt;/td&gt;
&lt;td&gt;One specific element&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Rule of thumb:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Use &lt;strong&gt;class&lt;/strong&gt; for reusable styling&lt;/li&gt;
&lt;li&gt;Use &lt;strong&gt;ID&lt;/strong&gt; for one specific section&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  4. Group Selectors – Style Multiple Things
&lt;/h1&gt;

&lt;p&gt;Sometimes you want same style for multiple selectors.&lt;/p&gt;

&lt;p&gt;Instead of repeating:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;h1 { color: #333; }
h2 { color: #333; }
h3 { color: #333; }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can group:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;h1,
h2,
h3 {
  color: #333;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Comma means:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Apply to all of these.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Less code. Cleaner CSS. Easier to maintain.&lt;/p&gt;

&lt;p&gt;You can mix types too:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;h1,
.intro,
#main-title {
  color: navy;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h1&gt;
  
  
  5. Descendant Selectors – Style Inside Something
&lt;/h1&gt;

&lt;p&gt;Now things get little more interesting.&lt;/p&gt;

&lt;p&gt;A &lt;strong&gt;descendant selector&lt;/strong&gt; targets elements inside another element.&lt;/p&gt;

&lt;h3&gt;
  
  
  Syntax
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ancestor descendant {
  /* styles */
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Space means:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Inside&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  Example
&lt;/h3&gt;

&lt;p&gt;HTML:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;article&amp;gt;
  &amp;lt;p&amp;gt;Inside article&amp;lt;/p&amp;gt;
&amp;lt;/article&amp;gt;

&amp;lt;p&amp;gt;Outside article&amp;lt;/p&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;CSS:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Only the paragraph inside &lt;code&gt;&amp;lt;article&amp;gt;&lt;/code&gt; becomes blue.&lt;/p&gt;

&lt;p&gt;The outside one stays normal.&lt;/p&gt;

&lt;p&gt;So now location matters.&lt;/p&gt;




&lt;h3&gt;
  
  
  Deeper Nesting
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;header nav ul li a {
  color: white;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This means:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;a&amp;gt;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;inside &lt;code&gt;&amp;lt;li&amp;gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;inside &lt;code&gt;&amp;lt;ul&amp;gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;inside &lt;code&gt;&amp;lt;nav&amp;gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;inside &lt;code&gt;&amp;lt;header&amp;gt;&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can be very specific.&lt;/p&gt;

&lt;p&gt;But careful — too much nesting can become messy.&lt;/p&gt;




&lt;h2&gt;
  
  
  Visual Flow (Conceptual)
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;HTML Element
     ↓
Match ID selector? → Yes → Apply ID styles
     ↓ No
Match Class selector? → Yes → Apply class styles
     ↓ No
Match Element selector? → Yes → Apply element styles
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h1&gt;
  
  
  6. Basic Selector Priority (Specificity)
&lt;/h1&gt;

&lt;p&gt;Now important question:&lt;/p&gt;

&lt;p&gt;What happens when two rules conflict?&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;If a paragraph has class highlight, which color wins?&lt;/p&gt;

&lt;p&gt;Answer: &lt;strong&gt;Class wins.&lt;/strong&gt;&lt;/p&gt;




&lt;h2&gt;
  
  
  Strength Order (High Level)
&lt;/h2&gt;

&lt;p&gt;From weakest to strongest:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Element selector&lt;/li&gt;
&lt;li&gt;Class selector&lt;/li&gt;
&lt;li&gt;ID selector&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;So:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;ID &amp;gt; Class&lt;/li&gt;
&lt;li&gt;Class &amp;gt; Element&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  Example
&lt;/h3&gt;

&lt;p&gt;HTML:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;p id="intro" class="highlight"&amp;gt;Hello&amp;lt;/p&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;CSS:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Final color?&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Green.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Because ID wins.&lt;/p&gt;




&lt;h3&gt;
  
  
  Same Strength Case
&lt;/h3&gt;

&lt;p&gt;If specificity is equal:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;.highlight { color: red; }
.highlight { color: blue; }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The last rule wins.&lt;/p&gt;

&lt;p&gt;So order matters too.&lt;/p&gt;




&lt;h1&gt;
  
  
  Final Complete Example
&lt;/h1&gt;

&lt;p&gt;HTML:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;header id="site-header"&amp;gt;
  &amp;lt;h1&amp;gt;My Blog&amp;lt;/h1&amp;gt;
  &amp;lt;p class="tagline"&amp;gt;Thoughts and code.&amp;lt;/p&amp;gt;
&amp;lt;/header&amp;gt;

&amp;lt;main&amp;gt;
  &amp;lt;article&amp;gt;
    &amp;lt;h2&amp;gt;First Post&amp;lt;/h2&amp;gt;
    &amp;lt;p&amp;gt;Content here.&amp;lt;/p&amp;gt;
    &amp;lt;p class="highlight"&amp;gt;Key point.&amp;lt;/p&amp;gt;
  &amp;lt;/article&amp;gt;
&amp;lt;/main&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;CSS:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;p {
  font-size: 1rem;
  color: #333;
}

.highlight {
  background-color: #ffc;
  padding: 0.25rem;
}

#site-header {
  background-color: #333;
  color: white;
  padding: 1rem;
}

#site-header p {
  font-size: 0.9rem;
  color: #ccc;
}

main h1,
main h2 {
  font-family: Georgia, serif;
  color: #222;
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And now you can see:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;All paragraphs get base style&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;.highlight&lt;/code&gt; gets extra styling&lt;/li&gt;
&lt;li&gt;Header gets unique style&lt;/li&gt;
&lt;li&gt;Only paragraphs inside header become smaller&lt;/li&gt;
&lt;li&gt;Headings inside main get specific font&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Everything is controlled by selectors.&lt;/p&gt;




&lt;h1&gt;
  
  
  Final Thoughts
&lt;/h1&gt;

&lt;p&gt;If you really think about it, CSS is not first about colors or animations or flexbox.&lt;/p&gt;

&lt;p&gt;It’s about:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Who am I styling?”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Selectors are how you answer that.&lt;/p&gt;

&lt;p&gt;Once you understand element, class, ID, grouping, and descendant selectors you’ve already understood the core of CSS. Rest things builds on this only.&lt;/p&gt;

&lt;p&gt;Happy styling&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>css</category>
      <category>frontend</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Emmet for HTML: A Beginner’s Guide to Writing Faster Markup</title>
      <dc:creator>Rajat Yadav</dc:creator>
      <pubDate>Thu, 12 Feb 2026 10:36:46 +0000</pubDate>
      <link>https://dev.to/rajat_yadav_/emmet-for-html-a-beginners-guide-to-writing-faster-markup-483c</link>
      <guid>https://dev.to/rajat_yadav_/emmet-for-html-a-beginners-guide-to-writing-faster-markup-483c</guid>
      <description>&lt;p&gt;Let me ask you something honestly…&lt;/p&gt;

&lt;p&gt;Have you ever felt tired just by looking at HTML?&lt;/p&gt;

&lt;p&gt;You open your editor.&lt;br&gt;
You start typing.&lt;br&gt;
Open tag. Close tag.&lt;br&gt;
Indent. Nest. Repeat.&lt;/p&gt;

&lt;p&gt;And suddenly a “simple” navbar becomes 10 lines of code and 5 chances to mess up something.&lt;/p&gt;

&lt;p&gt;Let’s see the problem first.&lt;/p&gt;


&lt;h2&gt;
  
  
  The Problem: Writing HTML is Slow (And Sometimes Painful)
&lt;/h2&gt;

&lt;p&gt;Imagine you're building a simple navigation bar. You need:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A &lt;code&gt;&amp;lt;nav&amp;gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Inside it a &lt;code&gt;&amp;lt;ul&amp;gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Inside that 5 &lt;code&gt;&amp;lt;li&amp;gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Each &lt;code&gt;&amp;lt;li&amp;gt;&lt;/code&gt; with an &lt;code&gt;&amp;lt;a&amp;gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Each &lt;code&gt;&amp;lt;a&amp;gt;&lt;/code&gt; with &lt;code&gt;class&lt;/code&gt; and &lt;code&gt;href&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Without Emmet, you’d type 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="nt"&gt;&amp;lt;nav&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;ul&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&amp;lt;a&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"#"&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"nav-link"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Home&lt;span class="nt"&gt;&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&amp;lt;a&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"#"&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"nav-link"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;About&lt;span class="nt"&gt;&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&amp;lt;a&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"#"&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"nav-link"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Services&lt;span class="nt"&gt;&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&amp;lt;a&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"#"&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"nav-link"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Portfolio&lt;span class="nt"&gt;&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
    &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&amp;lt;a&lt;/span&gt; &lt;span class="na"&gt;href=&lt;/span&gt;&lt;span class="s"&gt;"#"&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"nav-link"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&lt;/span&gt;Contact&lt;span class="nt"&gt;&amp;lt;/a&amp;gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;/ul&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/nav&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That’s multiple lines.&lt;br&gt;
Multiple opening and closing tags.&lt;br&gt;
Multiple places where you can forget something.&lt;/p&gt;

&lt;p&gt;Now look at this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;nav&amp;gt;ul&amp;gt;li*5&amp;gt;a.nav-link[href="#"]{Link}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Press &lt;strong&gt;Tab&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Boom.....;..&lt;/p&gt;

&lt;p&gt;Full structure generated instantly.&lt;/p&gt;

&lt;p&gt;This is what Emmet does. And once you start using it, you can’t go back, seriously.&lt;/p&gt;




&lt;h1&gt;
  
  
  What is Emmet? (In Very Simple Words)
&lt;/h1&gt;

&lt;p&gt;Emmet is like shortcut language for HTML and CSS.&lt;/p&gt;

&lt;p&gt;You know how on your phone:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;“omw” → becomes “On my way!”&lt;/li&gt;
&lt;li&gt;“brb” → becomes “Be right back!”&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Same concept.&lt;/p&gt;

&lt;p&gt;You type short code → it expands into full HTML.&lt;/p&gt;

&lt;p&gt;Examples:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Press Tab →&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&amp;gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;div.container
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Press Tab →&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&lt;/span&gt; &lt;span class="na"&gt;class=&lt;/span&gt;&lt;span class="s"&gt;"container"&lt;/span&gt;&lt;span class="nt"&gt;&amp;gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ul&amp;gt;li*3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Press Tab →&lt;br&gt;
3 &lt;code&gt;&amp;lt;li&amp;gt;&lt;/code&gt; elements inside a &lt;code&gt;&amp;lt;ul&amp;gt;&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;And the crazy part?&lt;br&gt;
It’s already built into editors like VS Code. You probably used it without knowing what it is called.&lt;/p&gt;


&lt;h1&gt;
  
  
  Why Emmet is a Game Changer (Especially for Beginners)
&lt;/h1&gt;
&lt;h3&gt;
  
  
  1. Speed
&lt;/h3&gt;

&lt;p&gt;You write HTML almost 10x faster. Not even exaggerating.&lt;/p&gt;
&lt;h3&gt;
  
  
  2. Fewer Mistakes
&lt;/h3&gt;

&lt;p&gt;No missing closing tags. No broken structure. Emmet generates valid HTML automatically.&lt;/p&gt;
&lt;h3&gt;
  
  
  3. You Understand Structure Better
&lt;/h3&gt;

&lt;p&gt;When you type &lt;code&gt;div&amp;gt;p&lt;/code&gt;, you're literally thinking in parent-child relationships. It trains your brain.&lt;/p&gt;
&lt;h3&gt;
  
  
  4. Focus on Thinking, Not Typing
&lt;/h3&gt;

&lt;p&gt;Instead of wasting energy typing repetitive tags, you think about layout and logic.&lt;/p&gt;
&lt;h3&gt;
  
  
  5. Professional Workflow
&lt;/h3&gt;

&lt;p&gt;Most developers use Emmet daily. Learning this early is honestly a small unfair advantage.&lt;/p&gt;


&lt;h1&gt;
  
  
  How Emmet Actually Works
&lt;/h1&gt;

&lt;p&gt;Let’s see the flow:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;You type: div.container
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;↓&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Editor detects Emmet pattern
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;↓&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;You press Tab
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;↓&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Emmet expands it
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;↓&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div class="container"&amp;gt;&amp;lt;/div&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It feels like magic at first. Then it becomes normal. Then it becomes addiction.&lt;/p&gt;




&lt;h1&gt;
  
  
  Basic Emmet Symbols (This is Where Fun Starts)
&lt;/h1&gt;

&lt;p&gt;Here’s the cheat sheet you’ll use daily:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Symbol&lt;/th&gt;
&lt;th&gt;Meaning&lt;/th&gt;
&lt;th&gt;Example&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;&amp;gt;&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Child (nested inside)&lt;/td&gt;
&lt;td&gt;&lt;code&gt;div&amp;gt;p&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;+&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Sibling&lt;/td&gt;
&lt;td&gt;&lt;code&gt;div+p&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;*&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Repeat&lt;/td&gt;
&lt;td&gt;&lt;code&gt;li*3&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;^&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Go up one level&lt;/td&gt;
&lt;td&gt;&lt;code&gt;div&amp;gt;p^span&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;()&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Grouping&lt;/td&gt;
&lt;td&gt;&lt;code&gt;(div&amp;gt;p)*2&lt;/code&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h1&gt;
  
  
  Understanding with Simple Diagrams
&lt;/h1&gt;

&lt;h3&gt;
  
  
  1. Child (&lt;code&gt;&amp;gt;&lt;/code&gt;)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;div&amp;gt;p
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Structure:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;div
 └── p
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Result:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;p&amp;gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  2. Sibling (&lt;code&gt;+&lt;/code&gt;)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;div+p
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Structure:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Result:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;div&amp;gt;&amp;lt;/div&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;p&amp;gt;&amp;lt;/p&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  3. Repeat (&lt;code&gt;*&lt;/code&gt;)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;li*3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Result:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;li&amp;gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;li&amp;gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;li&amp;gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h1&gt;
  
  
  Adding Classes and IDs
&lt;/h1&gt;

&lt;h3&gt;
  
  
  Classes use &lt;code&gt;.&lt;/code&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;div.container
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;→ &lt;code&gt;&amp;lt;div class="container"&amp;gt;&amp;lt;/div&amp;gt;&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;button.btn.btn-primary
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;→ &lt;code&gt;&amp;lt;button class="btn btn-primary"&amp;gt;&amp;lt;/button&amp;gt;&lt;/code&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  IDs use &lt;code&gt;#&lt;/code&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;div#header
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;→ &lt;code&gt;&amp;lt;div id="header"&amp;gt;&amp;lt;/div&amp;gt;&lt;/code&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  Combine Both
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;div#main.container.wrapper
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;→ &lt;code&gt;&amp;lt;div id="main" class="container wrapper"&amp;gt;&amp;lt;/div&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Small note: ID first, then classes. It just feels cleaner that way.&lt;/p&gt;




&lt;h1&gt;
  
  
  Adding Attributes with &lt;code&gt;[ ]&lt;/code&gt;
&lt;/h1&gt;

&lt;p&gt;Anything inside square brackets becomes an attribute.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;a[href="#"]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;→ &lt;code&gt;&amp;lt;a href="#"&amp;gt;&amp;lt;/a&amp;gt;&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;img[src="photo.jpg"][alt="Photo"]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;→ &lt;code&gt;&amp;lt;img src="photo.jpg" alt="Photo" /&amp;gt;&lt;/code&gt;&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;input[type="text"][placeholder="Enter name"]
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;→ &lt;code&gt;&amp;lt;input type="text" placeholder="Enter name" /&amp;gt;&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Very powerful, very simple.&lt;/p&gt;




&lt;h1&gt;
  
  
  Nesting Elements Like a Pro
&lt;/h1&gt;

&lt;h3&gt;
  
  
  Simple Nesting
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;div&amp;gt;p
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;div
 └── p
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Multiple Levels
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;div&amp;gt;ul&amp;gt;li
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;div
 └── ul
      └── li
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Multiple Children
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;div&amp;gt;p+span+button
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;div
 ├── p
 ├── span
 └── button
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is where your brain start thinking in structure instead of lines.&lt;/p&gt;




&lt;h1&gt;
  
  
  Repeating Structures
&lt;/h1&gt;

&lt;h3&gt;
  
  
  Simple Repeat
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;li*5
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;5 &lt;code&gt;&amp;lt;li&amp;gt;&lt;/code&gt; elements.&lt;/p&gt;




&lt;h3&gt;
  
  
  Nested Repeat
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ul&amp;gt;li*3
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ul
 ├── li
 ├── li
 └── li
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Complex Repeat
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;div.card*4&amp;gt;h2+p+button
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You instantly get 4 card components with content inside.&lt;/p&gt;

&lt;p&gt;This is where Emmet really saves time.&lt;/p&gt;




&lt;h1&gt;
  
  
  Adding Text Content &lt;code&gt;{}&lt;/code&gt;
&lt;/h1&gt;

&lt;p&gt;Use curly braces.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;p{Hello World}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;→ &lt;code&gt;&amp;lt;p&amp;gt;Hello World&amp;lt;/p&amp;gt;&lt;/code&gt;&lt;/p&gt;




&lt;h3&gt;
  
  
  With Nesting
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;div&amp;gt;h1{Welcome}+p{This is a paragraph}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  Numbered Content with &lt;code&gt;$&lt;/code&gt;
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ul&amp;gt;li*3{Item $}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Result:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;ul&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&lt;/span&gt;Item 1&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&lt;/span&gt;Item 2&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
  &lt;span class="nt"&gt;&amp;lt;li&amp;gt;&lt;/span&gt;Item 3&lt;span class="nt"&gt;&amp;lt;/li&amp;gt;&lt;/span&gt;
&lt;span class="nt"&gt;&amp;lt;/ul&amp;gt;&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The &lt;code&gt;$&lt;/code&gt; automatically increments numbers. It feels smart honestly.&lt;/p&gt;




&lt;h1&gt;
  
  
  The Magic Shortcut: Full HTML Boilerplate
&lt;/h1&gt;

&lt;p&gt;Open a blank file.&lt;/p&gt;

&lt;p&gt;Type:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Press Tab.&lt;/p&gt;

&lt;p&gt;You instantly get full HTML5 structure:&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;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;/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;That alone saves so much time.&lt;/p&gt;




&lt;h1&gt;
  
  
  Real World Example: Navigation Bar
&lt;/h1&gt;

&lt;p&gt;Emmet:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;nav.navbar&amp;gt;ul.nav-list&amp;gt;li.nav-item*5&amp;gt;a.nav-link[href="#"]{Link $}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Mental structure:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;nav.navbar
 └── ul.nav-list
      ├── li.nav-item
      │     └── a.nav-link
      ├── li.nav-item
      │     └── a.nav-link
      └── ...
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This is how you think like a developer. Structure first, typing later.&lt;/p&gt;




&lt;h1&gt;
  
  
  Visual Guide: What Happens Internally
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;┌──────────────────────────────┐
│ You Type: div.container&amp;gt;p*3 │
└──────────────────────────────┘
                ↓
┌──────────────────────────────┐
│ Emmet understands structure │
│ - div with class container  │
│ - 3 p elements inside       │
└──────────────────────────────┘
                ↓
┌──────────────────────────────┐
│ You press Tab               │
└──────────────────────────────┘
                ↓
┌──────────────────────────────┐
│ HTML is generated instantly │
└──────────────────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Feels simple. But it's powerful.&lt;/p&gt;




&lt;h1&gt;
  
  
  Patterns You’ll Use Almost Daily
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;div.wrapper&amp;gt;h1+p&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;ul&amp;gt;li*5&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;button.btn.btn-primary{Click Me}&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;a[href="/page"]{Link}&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;section#about&amp;gt;div.container&amp;gt;h2+p&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you master just these, your HTML workflow becomes smooth.&lt;/p&gt;




&lt;h1&gt;
  
  
  Practice (Do This Seriously)
&lt;/h1&gt;

&lt;p&gt;Try building:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Header with logo and nav
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   header&amp;gt;div.logo+nav&amp;gt;ul&amp;gt;li*4&amp;gt;a
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Article layout
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   article&amp;gt;h1+div.meta&amp;gt;span.author+span.date+p
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Footer with 3 columns
&lt;/li&gt;
&lt;/ol&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   footer&amp;gt;div.column*3&amp;gt;h3+p*2
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;   table&amp;gt;tr*3&amp;gt;td*4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;ol&gt;
&lt;li&gt;Full page
Start with &lt;code&gt;!&lt;/code&gt; then add header, main, footer.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Practice this once. You’ll never write plain HTML the same way again.&lt;/p&gt;




&lt;h1&gt;
  
  
  Final Thoughts
&lt;/h1&gt;

&lt;p&gt;You still need to know HTML properly. But Emmet removes the boring part. And honestly, coding becomes more enjoyable when you're not fighting with closing tags all the time.&lt;/p&gt;

&lt;p&gt;If you’re a beginner, start using it today.&lt;/p&gt;

&lt;p&gt;Happy Coding.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>html</category>
      <category>productivity</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Understanding HTML Tags and Elements</title>
      <dc:creator>Rajat Yadav</dc:creator>
      <pubDate>Thu, 12 Feb 2026 06:27:06 +0000</pubDate>
      <link>https://dev.to/rajat_yadav_/understanding-html-tags-and-elements-16e9</link>
      <guid>https://dev.to/rajat_yadav_/understanding-html-tags-and-elements-16e9</guid>
      <description>&lt;p&gt;So we will start with basics what is HTML? &lt;/p&gt;

&lt;p&gt;When you open any website in your browser maybe YouTube, maybe LinkedIn, maybe your own project what you see (text, buttons, images, links) is built on top of &lt;strong&gt;HTML&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Without HTML, a webpage would be just raw text thrown randomly on the screen. No structure. No meaning. Just chaos.&lt;/p&gt;

&lt;p&gt;And if you're learning web development (like seriously learning it, not just watching tutorials), understanding HTML properly is the first real step.&lt;/p&gt;

&lt;p&gt;So let’s break it down in a simple way. No over-complicated words. No confusion.&lt;/p&gt;




&lt;h2&gt;
  
  
  What Is HTML and Why Do We Use It?
&lt;/h2&gt;

&lt;h3&gt;
  
  
  The Basic Idea
&lt;/h3&gt;

&lt;p&gt;HTML stands for &lt;strong&gt;HyperText Markup Language&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Now that sounds fancy. But actually it’s very simple.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Markup&lt;/strong&gt; = you mark parts of your content&lt;br&gt;
(“This is a heading.” “This is a paragraph.” “This is a link.”)&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Language&lt;/strong&gt; = a set of rules the browser understands.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So HTML is just a way of marking up content so the browser knows how to display it.&lt;/p&gt;

&lt;p&gt;You're not just typing text.&lt;/p&gt;

&lt;p&gt;You're describing what that text &lt;em&gt;is&lt;/em&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  HTML Is the Skeleton of a Webpage
&lt;/h2&gt;

&lt;p&gt;Think of a webpage like a human body:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;HTML&lt;/strong&gt; = Skeleton (structure)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;CSS&lt;/strong&gt; = Skin &amp;amp; clothes (design, colors, layout)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;JavaScript&lt;/strong&gt; = Muscles &amp;amp; nerves (movement and behavior)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If there is no skeleton, nothing else can exist properly.&lt;/p&gt;

&lt;p&gt;You can’t style something that doesn’t have structure.&lt;br&gt;
You can’t add behavior to something that doesn’t exist.&lt;/p&gt;

&lt;p&gt;So HTML is the foundation.&lt;/p&gt;

&lt;p&gt;It tells the browser:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;This is a heading.&lt;/li&gt;
&lt;li&gt;This is a paragraph.&lt;/li&gt;
&lt;li&gt;This is a list.&lt;/li&gt;
&lt;li&gt;This is an image.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Everything starts here.&lt;/p&gt;


&lt;h2&gt;
  
  
  Why Do We Use HTML?
&lt;/h2&gt;

&lt;p&gt;We use HTML because:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;
&lt;strong&gt;Browsers understand it.&lt;/strong&gt; Every website is built from HTML (or something that generates HTML).&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;It gives structure.&lt;/strong&gt; It organizes content clearly.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;It improves accessibility.&lt;/strong&gt; Screen readers rely on proper HTML structure.&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;It’s the web standard.&lt;/strong&gt; The internet is built on HTML.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;When you write HTML, you’re not just writing code.&lt;/p&gt;

&lt;p&gt;You’re defining the structure of a document that millions of devices can understand.&lt;/p&gt;


&lt;h1&gt;
  
  
  What Is an HTML Tag?
&lt;/h1&gt;
&lt;h3&gt;
  
  
  Tags Are Like Labels
&lt;/h3&gt;

&lt;p&gt;An HTML tag is a label you put around content.&lt;/p&gt;

&lt;p&gt;It tells the browser what that content is.&lt;/p&gt;

&lt;p&gt;Think of it like this:&lt;/p&gt;

&lt;p&gt;Opening tag → “Start of paragraph.”&lt;br&gt;
Content → The actual text.&lt;br&gt;
Closing tag → “End of paragraph.”&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;p&amp;gt;This is a paragraph.&amp;lt;/p&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Breakdown:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt; = opening tag&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;This is a paragraph.&lt;/code&gt; = content&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;&amp;lt;/p&amp;gt;&lt;/code&gt; = closing tag&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The &lt;code&gt;/&lt;/code&gt; means “closing.”&lt;/p&gt;




&lt;h2&gt;
  
  
  Visual Diagram: Tag Structure
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Opening Tag      Content             Closing Tag

   &amp;lt;p&amp;gt;      This is a paragraph.        &amp;lt;/p&amp;gt;

          └──────── Entire Element ────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The opening tag + content + closing tag together form something called an &lt;strong&gt;element&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;And this is where many beginners get confused.&lt;/p&gt;




&lt;h1&gt;
  
  
  Tag vs Element (Important Difference)
&lt;/h1&gt;

&lt;p&gt;Many beginners think tag and element are same. But they are not exactly same.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Tag&lt;/strong&gt; = the syntax like &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;/p&amp;gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Element&lt;/strong&gt; = the whole thing → &lt;code&gt;&amp;lt;p&amp;gt;Hello&amp;lt;/p&amp;gt;&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Think of it like a box:&lt;/p&gt;

&lt;p&gt;Tags = the box edges&lt;br&gt;
Content = what’s inside&lt;br&gt;
Element = the full box with everything&lt;/p&gt;

&lt;p&gt;Diagram:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;ELEMENT (Whole thing)

┌───────────────────────────────┐
│  &amp;lt;p&amp;gt;  Hello world  &amp;lt;/p&amp;gt;      │
│   ↑         ↑        ↑       │
│ Opening   Content   Closing  │
│  Tag                 Tag     │
└───────────────────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The browser thinks in &lt;strong&gt;elements&lt;/strong&gt;.&lt;br&gt;
We write &lt;strong&gt;tags&lt;/strong&gt; to create them.&lt;/p&gt;


&lt;h1&gt;
  
  
  Self-Closing (Void) Elements
&lt;/h1&gt;

&lt;p&gt;Now here’s something interesting.&lt;/p&gt;

&lt;p&gt;Not all elements have content inside them.&lt;/p&gt;

&lt;p&gt;Some elements don’t wrap text. They just do one thing.&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;Line break&lt;/li&gt;
&lt;li&gt;Image&lt;/li&gt;
&lt;li&gt;Horizontal line&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These are called &lt;strong&gt;void elements&lt;/strong&gt; (sometimes casually called self-closing).&lt;/p&gt;

&lt;p&gt;Examples:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;br&amp;gt;
&amp;lt;img src="photo.jpg" alt="A photo"&amp;gt;
&amp;lt;hr&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Notice something?&lt;/p&gt;

&lt;p&gt;There is &lt;strong&gt;no closing tag&lt;/strong&gt; like &lt;code&gt;&amp;lt;/br&amp;gt;&lt;/code&gt; or &lt;code&gt;&amp;lt;/img&amp;gt;&lt;/code&gt;.&lt;/p&gt;

&lt;p&gt;Because they don’t wrap content.&lt;/p&gt;

&lt;p&gt;They just exist.&lt;/p&gt;

&lt;p&gt;Common void elements:&lt;/p&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Tag&lt;/th&gt;
&lt;th&gt;Purpose&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;&amp;lt;br&amp;gt;&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Line break&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;&amp;lt;hr&amp;gt;&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Horizontal line&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;&amp;lt;img&amp;gt;&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Image&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;&amp;lt;input&amp;gt;&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Form input&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;&lt;code&gt;&amp;lt;meta&amp;gt;&lt;/code&gt;&lt;/td&gt;
&lt;td&gt;Page metadata&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;So remember:&lt;/p&gt;

&lt;p&gt;Void element = one tag, no content, no closing tag.&lt;/p&gt;




&lt;h1&gt;
  
  
  Block-Level vs Inline Elements
&lt;/h1&gt;

&lt;p&gt;This part is very important for layout understanding.&lt;/p&gt;

&lt;p&gt;HTML elements behave in two main ways:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Block level&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Inline&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  Block-Level Elements
&lt;/h2&gt;

&lt;p&gt;Block elements:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Start on a new line&lt;/li&gt;
&lt;li&gt;Take full width available&lt;/li&gt;
&lt;li&gt;Stack vertically&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Examples:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;&amp;lt;h1&amp;gt;&lt;/code&gt; to &lt;code&gt;&amp;lt;h6&amp;gt;&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;section&amp;gt;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;ul&amp;gt;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;li&amp;gt;&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Diagram:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Block 1  ─────────────────────────

Block 2  ─────────────────────────

Block 3  ─────────────────────────
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each block sits below the previous one.&lt;/p&gt;

&lt;p&gt;Like stacking boxes.&lt;/p&gt;




&lt;h2&gt;
  
  
  Inline Elements
&lt;/h2&gt;

&lt;p&gt;Inline elements:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Do NOT start on new line&lt;/li&gt;
&lt;li&gt;Take only as much width as needed&lt;/li&gt;
&lt;li&gt;Sit inside text&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Examples:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;span&amp;gt;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;a&amp;gt;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;strong&amp;gt;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;em&amp;gt;&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example sentence:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;This is a &amp;lt;span&amp;gt;word&amp;lt;/span&amp;gt; and &amp;lt;a href="#"&amp;gt;a link&amp;lt;/a&amp;gt;.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;They stay in the same line.&lt;/p&gt;

&lt;p&gt;Diagram:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Text Text Inline1 Inline2 Inline3 Text
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;They flow like normal words.&lt;/p&gt;




&lt;h2&gt;
  
  
  Common Mistake
&lt;/h2&gt;

&lt;p&gt;You should not put a block element inside an inline element.&lt;/p&gt;

&lt;p&gt;Wrong:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;a href="#"&amp;gt;&amp;lt;p&amp;gt;Don't do this&amp;lt;/p&amp;gt;&amp;lt;/a&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Correct:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;p&amp;gt;Read &amp;lt;a href="#"&amp;gt;this link&amp;lt;/a&amp;gt;.&amp;lt;/p&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Blocks are for structure.&lt;br&gt;
Inlines are for parts inside structure.&lt;/p&gt;


&lt;h1&gt;
  
  
  Commonly Used HTML Tags
&lt;/h1&gt;

&lt;p&gt;Let’s see the most important ones you’ll use daily.&lt;/p&gt;


&lt;h2&gt;
  
  
  Headings &amp;amp; Text
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;h1&amp;gt;Main Title&amp;lt;/h1&amp;gt;
&amp;lt;h2&amp;gt;Sub Title&amp;lt;/h2&amp;gt;
&amp;lt;p&amp;gt;This is a paragraph.&amp;lt;/p&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;code&gt;&amp;lt;h1&amp;gt;&lt;/code&gt; is biggest heading.&lt;br&gt;
&lt;code&gt;&amp;lt;h6&amp;gt;&lt;/code&gt; is smallest.&lt;/p&gt;


&lt;h2&gt;
  
  
  Containers
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;div&amp;gt;This is a block container&amp;lt;/div&amp;gt;
&amp;lt;span&amp;gt;This is inline container&amp;lt;/span&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; → block container&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;&amp;lt;span&amp;gt;&lt;/code&gt; → inline container&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;They don’t add meaning. They just help structure or styling.&lt;/p&gt;


&lt;h2&gt;
  
  
  Links &amp;amp; Images
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;a href="https://example.com"&amp;gt;Visit site&amp;lt;/a&amp;gt;
&amp;lt;img src="photo.jpg" alt="Description"&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;&lt;code&gt;href&lt;/code&gt; and &lt;code&gt;src&lt;/code&gt; are called &lt;strong&gt;attributes&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Attributes give extra information.&lt;/p&gt;


&lt;h2&gt;
  
  
  Lists
&lt;/h2&gt;

&lt;p&gt;Unordered list:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;ul&amp;gt;
  &amp;lt;li&amp;gt;First item&amp;lt;/li&amp;gt;
  &amp;lt;li&amp;gt;Second item&amp;lt;/li&amp;gt;
&amp;lt;/ul&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Ordered list:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;ol&amp;gt;
  &amp;lt;li&amp;gt;Step one&amp;lt;/li&amp;gt;
  &amp;lt;li&amp;gt;Step two&amp;lt;/li&amp;gt;
&amp;lt;/ol&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  Emphasis &amp;amp; Meaning
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;strong&amp;gt;Important&amp;lt;/strong&amp;gt;
&amp;lt;em&amp;gt;Emphasized text&amp;lt;/em&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use &lt;code&gt;&amp;lt;strong&amp;gt;&lt;/code&gt; when something is important.&lt;br&gt;
Use &lt;code&gt;&amp;lt;em&amp;gt;&lt;/code&gt; for emphasis.&lt;/p&gt;

&lt;p&gt;It’s not just styling, it adds meaning.&lt;/p&gt;


&lt;h1&gt;
  
  
  Minimal HTML Page Structure
&lt;/h1&gt;

&lt;p&gt;Every HTML page usually looks like this:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;
&amp;lt;html lang="en"&amp;gt;
&amp;lt;head&amp;gt;
  &amp;lt;meta charset="UTF-8"&amp;gt;
  &amp;lt;title&amp;gt;My Page&amp;lt;/title&amp;gt;
&amp;lt;/head&amp;gt;
&amp;lt;body&amp;gt;
  &amp;lt;h1&amp;gt;Welcome&amp;lt;/h1&amp;gt;
  &amp;lt;p&amp;gt;This is my first page.&amp;lt;/p&amp;gt;
&amp;lt;/body&amp;gt;
&amp;lt;/html&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Breakdown:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;&amp;lt;!DOCTYPE html&amp;gt;&lt;/code&gt; → tells browser this is HTML5&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;&amp;lt;html&amp;gt;&lt;/code&gt; → root element&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt; → metadata (not visible)&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;&amp;lt;body&amp;gt;&lt;/code&gt; → visible content&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You don’t have to memorize everything today.&lt;/p&gt;

&lt;p&gt;Start small.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;h1&amp;gt;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;span&amp;gt;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;a&amp;gt;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;img&amp;gt;&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Then slowly expand.&lt;/p&gt;




&lt;h1&gt;
  
  
  Inspect HTML in the Browser (Very Powerful Trick)
&lt;/h1&gt;

&lt;p&gt;Here’s something I wish I understood earlier.&lt;/p&gt;

&lt;p&gt;Every website is just HTML underneath.&lt;/p&gt;

&lt;p&gt;Right click → &lt;strong&gt;Inspect&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;You will see:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Opening and closing tags&lt;/li&gt;
&lt;li&gt;Nested elements&lt;/li&gt;
&lt;li&gt;Structure&lt;/li&gt;
&lt;li&gt;Parent-child relationships&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Hover over elements in inspector and browser highlights them.&lt;/p&gt;

&lt;p&gt;This is how you really understand how websites are built.&lt;/p&gt;

&lt;p&gt;Just reading theory is not enough. You need to observe real websites.&lt;/p&gt;




&lt;h1&gt;
  
  
  Final Thoughts
&lt;/h1&gt;

&lt;p&gt;Many people rush it.&lt;/p&gt;

&lt;p&gt;They jump to React. Or animations. Or fancy frameworks.&lt;/p&gt;

&lt;p&gt;But if your HTML foundation is weak, everything else feels confusing later.&lt;/p&gt;

&lt;p&gt;HTML is simple. But simple doesn’t mean unimportant.&lt;/p&gt;

&lt;p&gt;It’s the base of everything on the web.&lt;/p&gt;

&lt;p&gt;Take your time.&lt;/p&gt;

&lt;p&gt;Write small pages.&lt;br&gt;
Inspect websites.&lt;br&gt;
Break things.&lt;br&gt;
Fix them.&lt;/p&gt;

&lt;p&gt;And slowly, things start making sense.&lt;/p&gt;

&lt;p&gt;Happy coding guyzzz 🙂&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>html</category>
      <category>tutorial</category>
      <category>webdev</category>
    </item>
    <item>
      <title>How a Browser Works: A Beginner-Friendly Guide to Browser Internals</title>
      <dc:creator>Rajat Yadav</dc:creator>
      <pubDate>Wed, 11 Feb 2026 18:59:33 +0000</pubDate>
      <link>https://dev.to/rajat_yadav_/how-a-browser-works-a-beginner-friendly-guide-to-browser-internals-3knp</link>
      <guid>https://dev.to/rajat_yadav_/how-a-browser-works-a-beginner-friendly-guide-to-browser-internals-3knp</guid>
      <description>&lt;p&gt;You’re sitting at your computer.&lt;br&gt;
You type:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://chaicode.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You press &lt;strong&gt;Enter&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;And boom the website appears.&lt;/p&gt;

&lt;p&gt;But what actually happened in that tiiny moment?&lt;br&gt;
It feels intant, but behind the scenes ur browser just did alot of work. Like seriously a lot.&lt;/p&gt;

&lt;p&gt;It contacted servers, downloaded files, parsed code, built trees, calculated layouts, painted pixels and finally showed it to you.&lt;/p&gt;

&lt;p&gt;Let’s break it down slowly and visually.&lt;/p&gt;


&lt;h1&gt;
  
  
  First, What Even Is a Browser?
&lt;/h1&gt;

&lt;p&gt;Most beginners think:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Browser? It opens websites.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Technically true. But that’s like saying:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Chef? He just makes food.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Not enough.&lt;/p&gt;

&lt;p&gt;A browser is more like a &lt;strong&gt;translator + manager + artist + delivery system&lt;/strong&gt; all combined together.&lt;/p&gt;

&lt;p&gt;When you visit a website, your browser:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Fetches files from a server&lt;/li&gt;
&lt;li&gt;Understands (parses) HTML, CSS, JavaScript&lt;/li&gt;
&lt;li&gt;Builds internal structures&lt;/li&gt;
&lt;li&gt;Calculates layout&lt;/li&gt;
&lt;li&gt;Paints pixels&lt;/li&gt;
&lt;li&gt;Displays everything on your screen&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;It’s doing way more than we realise, honestly.&lt;/p&gt;


&lt;h1&gt;
  
  
  The Main Parts of a Browser (Restaurant Analogy 🍽️)
&lt;/h1&gt;

&lt;p&gt;Think of a browser like a restaurant.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;┌─────────────────────────────────────────┐
│         USER INTERFACE                   │
│  (Dining Area - What You See)            │
│  - Address bar, tabs, buttons            │
└─────────────────────────────────────────┘
                    ↓
┌─────────────────────────────────────────┐
│         BROWSER ENGINE                   │
│  (Manager - Coordinates Everything)      │
└─────────────────────────────────────────┘
                    ↓
┌─────────────────────────────────────────┐
│         RENDERING ENGINE                 │
│  (Chef - Creates the Visual Output)      │
│  - Parses HTML/CSS                       │
│  - Builds DOM &amp;amp; CSSOM                    │
│  - Renders the page                      │
└─────────────────────────────────────────┘
                    ↓
┌─────────────────────────────────────────┐
│         NETWORKING LAYER                 │
│  (Delivery Service - Gets Files)         │
│  - HTTP requests                         │
│  - Downloads resources                   │
└─────────────────────────────────────────┘
                    ↓
┌─────────────────────────────────────────┐
│         JAVASCRIPT ENGINE                │
│  (Waiter - Adds Interaction)             │
│  - Executes JS                           │
│  - Handles interactivity                 │
└─────────────────────────────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Each part has a specific job. Let’s understand them one by one.&lt;/p&gt;




&lt;h1&gt;
  
  
  1. User Interface (UI)
&lt;/h1&gt;

&lt;p&gt;This is the part &lt;strong&gt;you interact with&lt;/strong&gt;:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Address bar&lt;/li&gt;
&lt;li&gt;Tabs&lt;/li&gt;
&lt;li&gt;Back/Forward buttons&lt;/li&gt;
&lt;li&gt;Bookmarks&lt;/li&gt;
&lt;li&gt;Settings&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;This is just the “face” of the browser.&lt;/p&gt;

&lt;p&gt;Like steering wheel of a car.&lt;br&gt;
You control it, but the engine is inside.&lt;/p&gt;


&lt;h1&gt;
  
  
  2. Browser Engine vs Rendering Engine (This Confuses Everyone)
&lt;/h1&gt;
&lt;h3&gt;
  
  
  Browser Engine → The Manager
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Coordinates everything&lt;/li&gt;
&lt;li&gt;Controls communication between parts&lt;/li&gt;
&lt;li&gt;Decides what to do next&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Rendering Engine → The Artist
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Parses HTML &amp;amp; CSS&lt;/li&gt;
&lt;li&gt;Builds structures&lt;/li&gt;
&lt;li&gt;Paints pixels on screen&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Some real rendering engines used today:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Blink&lt;/strong&gt; (Chrome, Edge, Opera)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Gecko&lt;/strong&gt; (Firefox)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;WebKit&lt;/strong&gt; (Safari)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The browser engine manages everything, but rendering engine does the visual heavy work.&lt;/p&gt;


&lt;h1&gt;
  
  
  3. Networking — How Files Are Fetched
&lt;/h1&gt;

&lt;p&gt;Now let’s walk through what happens when you type a URL.&lt;/p&gt;

&lt;p&gt;You type:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;https://chaicode.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Here’s what happens:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Step 1: Break URL
Protocol → https
Domain   → chaicode.com
Path     → /
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Step 2: DNS Lookup
&lt;/h3&gt;

&lt;p&gt;Your browser asks:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“What is the IP address of chaicode.com?”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;DNS replies:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;Now browser knows where to go.&lt;/p&gt;

&lt;h3&gt;
  
  
  Step 3: HTTP Request
&lt;/h3&gt;

&lt;p&gt;Browser sends request to that IP:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Please send me the HTML file.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Server responds with HTML.&lt;/p&gt;

&lt;p&gt;But HTML isn’t the only thing needed.&lt;/p&gt;

&lt;p&gt;Inside HTML, browser finds:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;CSS files&lt;/li&gt;
&lt;li&gt;JavaScript files&lt;/li&gt;
&lt;li&gt;Images&lt;/li&gt;
&lt;li&gt;Fonts&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Then it downloads all of them &lt;strong&gt;in parallel&lt;/strong&gt; (simultaneously).&lt;/p&gt;

&lt;p&gt;That’s why modern websites load fast.&lt;/p&gt;




&lt;h1&gt;
  
  
  4. HTML Parsing &amp;amp; DOM Creation
&lt;/h1&gt;

&lt;p&gt;Now browser has HTML.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight html"&gt;&lt;code&gt;&lt;span class="nt"&gt;&amp;lt;html&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;title&amp;gt;&lt;/span&gt;My Page&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;h1&amp;gt;&lt;/span&gt;Welcome&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;Hello world!&lt;span class="nt"&gt;&amp;lt;/p&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;Browser does something called &lt;strong&gt;parsing&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is Parsing?
&lt;/h3&gt;

&lt;p&gt;Parsing means breaking text into meaningful structure.&lt;/p&gt;

&lt;p&gt;Like reading a math expression:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;2 + 3 * 4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It builds a tree:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;        +
       / \
      2   *
         / \
        3   4
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;HTML works same way.&lt;/p&gt;

&lt;p&gt;Browser builds a tree:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;        html
       /    \
    head    body
     |      /  \
   title   h1   p
     |      |    |
  "My Page" "Welcome" "Hello world!"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This tree is called:&lt;/p&gt;

&lt;h1&gt;
  
  
  🌳 DOM (Document Object Model)
&lt;/h1&gt;

&lt;p&gt;Every HTML element becomes a node.&lt;/p&gt;

&lt;p&gt;Why DOM matters?&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;JavaScript uses it&lt;/li&gt;
&lt;li&gt;Browser uses it&lt;/li&gt;
&lt;li&gt;Changes in DOM update the screen&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Without DOM, nothing works.&lt;/p&gt;




&lt;h1&gt;
  
  
  5. CSS Parsing &amp;amp; CSSOM Creation
&lt;/h1&gt;

&lt;p&gt;At the same time, browser parses CSS.&lt;/p&gt;

&lt;p&gt;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-size&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="m"&gt;16px&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;
  &lt;span class="nl"&gt;color&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="no"&gt;black&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="no"&gt;blue&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;Browser builds another tree called:&lt;/p&gt;

&lt;h1&gt;
  
  
  CSSOM (CSS Object Model)
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;        StyleSheet
             │
      ┌──────┴──────┐
      │             │
    body{}         h1{}
      │             │
  font-size       color
  color
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Important thing:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Browser cannot render until CSSOM is ready&lt;br&gt;
Because styles affect layout.&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h1&gt;
  
  
  6. DOM + CSSOM = Render Tree
&lt;/h1&gt;

&lt;p&gt;Now browser combines both trees.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;DOM Tree        CSSOM Tree
    │                │
    └──── Combine ───┘
             ↓
         Render Tree
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Render Tree contains:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Only visible elements&lt;/li&gt;
&lt;li&gt;With computed styles attached&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Not included:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;head&amp;gt;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;script&amp;gt;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;Hidden elements&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Render Tree is basically blueprint of what will be shown.&lt;/p&gt;




&lt;h1&gt;
  
  
  7. Layout (Reflow)
&lt;/h1&gt;

&lt;p&gt;Now browser calculates positions.&lt;/p&gt;

&lt;p&gt;Questions browser asks:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;How wide is this element?&lt;/li&gt;
&lt;li&gt;Where should it go?&lt;/li&gt;
&lt;li&gt;How much space does it need?&lt;/li&gt;
&lt;li&gt;Does it wrap to next line?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;p&gt;Before Layout:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Header
Nav   Main
Footer
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;After Layout:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;┌─────────────────┐
│ Header (100%)   │
├─────────────────┤
│ Nav │ Main      │
├─────────────────┤
│ Footer (100%)   │
└─────────────────┘
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now browser knows exact pixel positions.&lt;/p&gt;




&lt;h1&gt;
  
  
  8. Painting
&lt;/h1&gt;

&lt;p&gt;Layout tells &lt;strong&gt;where&lt;/strong&gt; to draw.&lt;/p&gt;

&lt;p&gt;CSS tells &lt;strong&gt;what&lt;/strong&gt; to draw.&lt;/p&gt;

&lt;p&gt;Painting fills in pixels:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Background colors&lt;/li&gt;
&lt;li&gt;Borders&lt;/li&gt;
&lt;li&gt;Text&lt;/li&gt;
&lt;li&gt;Images&lt;/li&gt;
&lt;li&gt;Shadows&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Think like paint-by-numbers.&lt;/p&gt;

&lt;p&gt;Layers:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Background&lt;/li&gt;
&lt;li&gt;Borders&lt;/li&gt;
&lt;li&gt;Text&lt;/li&gt;
&lt;li&gt;Images&lt;/li&gt;
&lt;li&gt;Overlays&lt;/li&gt;
&lt;/ol&gt;




&lt;h1&gt;
  
  
  9. Display
&lt;/h1&gt;

&lt;p&gt;Finally:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Render Tree
   ↓
Layout
   ↓
Paint
   ↓
Graphics Card
   ↓
Monitor
   ↓
Your Eyes 👀
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And you see the webpage.&lt;/p&gt;

&lt;p&gt;All of this usually happens in less than a second.&lt;/p&gt;

&lt;p&gt;Crazy right?&lt;/p&gt;




&lt;h1&gt;
  
  
  Complete Flow (From URL to Pixels)
&lt;/h1&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;1. You type URL
        ↓
2. DNS lookup
        ↓
3. HTTP request
        ↓
4. Receive HTML
        ↓
5. Download CSS/JS/Images
        ↓
6. Build DOM
        ↓
7. Build CSSOM
        ↓
8. Create Render Tree
        ↓
9. Layout (Reflow)
        ↓
10. Paint
        ↓
11. Display on screen
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h1&gt;
  
  
  Final Thoughts
&lt;/h1&gt;

&lt;p&gt;Next time you open a website, just remember:&lt;/p&gt;

&lt;p&gt;Your browser didn’t “just open it”.&lt;/p&gt;

&lt;p&gt;It:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Talked to servers&lt;/li&gt;
&lt;li&gt;Downloaded multiple files&lt;/li&gt;
&lt;li&gt;Built tree structures&lt;/li&gt;
&lt;li&gt;Calculated layouts&lt;/li&gt;
&lt;li&gt;Painted millions of pixels&lt;/li&gt;
&lt;li&gt;Coordinated multiple engines&lt;/li&gt;
&lt;li&gt;And then showed you result&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;All in milliseconds.&lt;/p&gt;

&lt;p&gt;Sometimes we think frontend is just HTML &amp;amp; CSS.&lt;/p&gt;

&lt;p&gt;But honestly, the browser is doing so much heavy lifting behind the scenes and we dont even realise it properly.&lt;/p&gt;

&lt;p&gt;once you understand this flow deeply, performance optimization and debugging becomes way more logical.&lt;/p&gt;

&lt;p&gt;Happy Learning..&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>computerscience</category>
      <category>tutorial</category>
      <category>webdev</category>
    </item>
    <item>
      <title>Understanding Network Devices</title>
      <dc:creator>Rajat Yadav</dc:creator>
      <pubDate>Wed, 11 Feb 2026 18:25:05 +0000</pubDate>
      <link>https://dev.to/rajat_yadav_/understanding-network-devices-3f1e</link>
      <guid>https://dev.to/rajat_yadav_/understanding-network-devices-3f1e</guid>
      <description>&lt;p&gt;When we open our browser and type &lt;strong&gt;google.com&lt;/strong&gt;, it feels instant. You press Enter… and boom, the page loads.&lt;/p&gt;

&lt;p&gt;But behind that one click, a lot of hardware devices are silently working together. You’ve probably heard words like &lt;em&gt;router&lt;/em&gt;, &lt;em&gt;modem&lt;/em&gt;, &lt;em&gt;firewall&lt;/em&gt;, or even &lt;em&gt;load balancer&lt;/em&gt; — but honestly, most people don’t clearly know what each one actually does. And sometimes we just say “modem” for everything..&lt;/p&gt;

&lt;p&gt;In this article, we’ll break down the essential networking hardware that makes the internet work in simple language, with real examples, and diagrams.&lt;/p&gt;

&lt;p&gt;We’ll cover:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Modem – How your network connects to the internet&lt;/li&gt;
&lt;li&gt;Router – How traffic gets directed&lt;/li&gt;
&lt;li&gt;Switch vs Hub – How local networks actually work&lt;/li&gt;
&lt;li&gt;Firewall – Where security lives&lt;/li&gt;
&lt;li&gt;Load Balancer – Why scalable systems need it&lt;/li&gt;
&lt;li&gt;How all of these work together in real-world setups&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let’s start with the big picture.&lt;/p&gt;




&lt;h1&gt;
  
  
  How the Internet Reaches You
&lt;/h1&gt;

&lt;p&gt;Before going deep into each device, let’s understand the journey of a single packet.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Internet 
   ↓
Modem 
   ↓
Router 
   ↓
Switch 
   ↓
Your Device
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Think of it like mail delivery:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Internet = The global postal system&lt;/li&gt;
&lt;li&gt;Modem = Your mailbox&lt;/li&gt;
&lt;li&gt;Router = The mail sorter&lt;/li&gt;
&lt;li&gt;Switch = The delivery person inside the building&lt;/li&gt;
&lt;li&gt;Your Device = The person receiving the mail&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each one has a specific job. If even one fails, things stop working. And then we start restarting router again and again&lt;/p&gt;




&lt;h1&gt;
  
  
  1. What is a Modem?
&lt;/h1&gt;

&lt;h2&gt;
  
  
  The Problem: Different “Languages”
&lt;/h2&gt;

&lt;p&gt;Your home network speaks one language (Ethernet/Wi-Fi signals).&lt;/p&gt;

&lt;p&gt;Your ISP (Internet Service Provider) speaks another language (cable, DSL, fiber signals).&lt;/p&gt;

&lt;p&gt;They don’t understand each other directly.&lt;/p&gt;

&lt;p&gt;A &lt;strong&gt;modem&lt;/strong&gt; (Modulator-Demodulator) is basically a translator.&lt;/p&gt;

&lt;h3&gt;
  
  
  What it does:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Modulation → Converts digital data into signals that can travel over cable/fiber&lt;/li&gt;
&lt;li&gt;Demodulation → Converts incoming signals back into digital data&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Diagram:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Your Computer (Digital Data)
        ↓
      Modem
        ↓
Cable/Fiber Signal
        ↓
        ISP
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  Important Things About Modem
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Connects to ISP&lt;/li&gt;
&lt;li&gt;Provides usually one public IP&lt;/li&gt;
&lt;li&gt;Does NOT route traffic&lt;/li&gt;
&lt;li&gt;It’s the boundary between your network and the internet&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Many people call their router a modem. But they are not same. A modem connects you to the internet. A router manages traffic inside your network.&lt;/p&gt;

&lt;p&gt;That difference is small but very important.&lt;/p&gt;




&lt;h1&gt;
  
  
  2. What is a Router?
&lt;/h1&gt;

&lt;h2&gt;
  
  
  The Problem: Where Should Data Go?
&lt;/h2&gt;

&lt;p&gt;Once data enters your network, how does it know where to go?&lt;/p&gt;

&lt;p&gt;You might have:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Laptop&lt;/li&gt;
&lt;li&gt;Phone&lt;/li&gt;
&lt;li&gt;Smart TV&lt;/li&gt;
&lt;li&gt;IoT devices&lt;/li&gt;
&lt;li&gt;Gaming console&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A &lt;strong&gt;router&lt;/strong&gt; decides:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;This packet is for Laptop → Send there&lt;/li&gt;
&lt;li&gt;This one goes to Internet → Send to modem&lt;/li&gt;
&lt;li&gt;This one is internal → Keep inside&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Diagram:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;               Router
            /    |     \
         PC    Phone    TV
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The router maintains something called a &lt;strong&gt;routing table&lt;/strong&gt; — basically a map of where things are.&lt;/p&gt;

&lt;h3&gt;
  
  
  What Router Actually Does
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Maintains routing table&lt;/li&gt;
&lt;li&gt;Assigns local IPs (via DHCP)&lt;/li&gt;
&lt;li&gt;Separates local network from internet&lt;/li&gt;
&lt;li&gt;Often provides Wi-Fi&lt;/li&gt;
&lt;li&gt;Routes packets between networks&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Router vs Modem (Simple Table)
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Modem&lt;/th&gt;
&lt;th&gt;Router&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Connects to ISP&lt;/td&gt;
&lt;td&gt;Connects devices&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Translates signals&lt;/td&gt;
&lt;td&gt;Routes traffic&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;One public IP&lt;/td&gt;
&lt;td&gt;Many local IPs&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Physical/Data layer&lt;/td&gt;
&lt;td&gt;Network layer&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;In most homes today, you actually use a combo device. One box that does modem + router + switch + Wi-Fi.&lt;/p&gt;

&lt;p&gt;But logically, they are separate components.&lt;/p&gt;




&lt;h1&gt;
  
  
  3. Switch vs Hub – How Local Networks Work
&lt;/h1&gt;

&lt;p&gt;Let’s say you want to connect 20 devices.&lt;/p&gt;

&lt;p&gt;Your router has only 4 ports.&lt;/p&gt;

&lt;p&gt;What now?&lt;/p&gt;

&lt;p&gt;You add a &lt;strong&gt;switch&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;But before switch, there was something called a &lt;strong&gt;hub&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  What is a Hub? (Old Technology)
&lt;/h2&gt;

&lt;p&gt;A hub is very simple and kind of dumb.&lt;/p&gt;

&lt;p&gt;It receives a packet → sends it to ALL ports.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Computer A → Hub → Sends to B, C, D, E (everyone)
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Everyone sees the packet, even if not meant for them.&lt;/p&gt;

&lt;p&gt;This creates unnecessary traffic and collisions.&lt;/p&gt;

&lt;p&gt;Think of hub like shouting in a classroom. Everyone hears you even if you’re talking to one person.&lt;/p&gt;

&lt;p&gt;That’s inefficient.&lt;/p&gt;




&lt;h2&gt;
  
  
  What is a Switch? (Modern Way)
&lt;/h2&gt;

&lt;p&gt;A switch is smarter.&lt;/p&gt;

&lt;p&gt;It learns which device is connected to which port.&lt;/p&gt;

&lt;p&gt;When Computer A sends to Computer B:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Computer A → Switch → Only Computer B
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Other devices don’t even know it happened.&lt;/p&gt;

&lt;p&gt;Much cleaner. Much faster.&lt;/p&gt;

&lt;h3&gt;
  
  
  Hub vs Switch
&lt;/h3&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Hub&lt;/th&gt;
&lt;th&gt;Switch&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Broadcasts to all&lt;/td&gt;
&lt;td&gt;Sends to specific port&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Causes collisions&lt;/td&gt;
&lt;td&gt;Avoids collisions&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Layer 1&lt;/td&gt;
&lt;td&gt;Layer 2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Obsolete&lt;/td&gt;
&lt;td&gt;Standard today&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;

&lt;p&gt;Today, hubs are almost dead. Switches are everywhere.&lt;/p&gt;




&lt;h1&gt;
  
  
  4. What is a Firewall?
&lt;/h1&gt;

&lt;p&gt;Now comes security.&lt;/p&gt;

&lt;p&gt;Your network is connected to the internet. That means:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Good traffic can come&lt;/li&gt;
&lt;li&gt;Bad traffic can also come&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A &lt;strong&gt;firewall&lt;/strong&gt; acts like a security guard.&lt;/p&gt;

&lt;p&gt;It inspects every packet and decides:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Allow&lt;/li&gt;
&lt;li&gt;Block&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Diagram:
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Internet
   ↓
Firewall
   ↓
Your Network
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  What Firewall Checks
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Source IP&lt;/li&gt;
&lt;li&gt;Destination IP&lt;/li&gt;
&lt;li&gt;Port number&lt;/li&gt;
&lt;li&gt;Protocol&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Common Rules
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Allow HTTP (80), HTTPS (443)&lt;/li&gt;
&lt;li&gt;Block unknown incoming traffic&lt;/li&gt;
&lt;li&gt;Allow outgoing DNS (53)&lt;/li&gt;
&lt;li&gt;Deny by default&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Firewall can be:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Hardware device&lt;/li&gt;
&lt;li&gt;Software (like iptables, Windows Firewall)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Without firewall, your network would be exposed. And that is not good at all.&lt;/p&gt;




&lt;h1&gt;
  
  
  5. What is a Load Balancer?
&lt;/h1&gt;

&lt;p&gt;Now imagine your website becomes popular.&lt;/p&gt;

&lt;p&gt;Day 1 → 100 users&lt;br&gt;
Day 100 → 10,000 users&lt;br&gt;
Day 1000 → 1 million users&lt;/p&gt;

&lt;p&gt;One server can’t handle everything.&lt;/p&gt;

&lt;p&gt;So you add more servers.&lt;/p&gt;

&lt;p&gt;But how do users get distributed across them?&lt;/p&gt;

&lt;p&gt;You use a &lt;strong&gt;load balancer&lt;/strong&gt;.&lt;/p&gt;
&lt;h3&gt;
  
  
  Diagram:
&lt;/h3&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;            Load Balancer
           /      |       \
       Server A  Server B  Server C
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Load balancer:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Receives request&lt;/li&gt;
&lt;li&gt;Decides best server&lt;/li&gt;
&lt;li&gt;Forwards request&lt;/li&gt;
&lt;li&gt;Removes unhealthy servers&lt;/li&gt;
&lt;li&gt;Can terminate SSL&lt;/li&gt;
&lt;/ul&gt;
&lt;h3&gt;
  
  
  Algorithms
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Round Robin&lt;/li&gt;
&lt;li&gt;Least Connections&lt;/li&gt;
&lt;li&gt;IP Hash&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It ensures:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;No single server gets overloaded&lt;/li&gt;
&lt;li&gt;High availability&lt;/li&gt;
&lt;li&gt;Scalability&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Load balancer is one of first components added in production systems.&lt;/p&gt;


&lt;h1&gt;
  
  
  6. How Everything Works Together (Real Setup)
&lt;/h1&gt;
&lt;h2&gt;
  
  
  Home Setup
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Internet
   ↓
Modem
   ↓
Router (with Firewall)
   ↓
Switch (optional)
   ↓
Devices
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Flow when you open google.com:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Device sends request&lt;/li&gt;
&lt;li&gt;Router checks firewall rules&lt;/li&gt;
&lt;li&gt;Router sends to modem&lt;/li&gt;
&lt;li&gt;Modem sends to ISP&lt;/li&gt;
&lt;li&gt;Response comes back same path&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Simple but powerful.&lt;/p&gt;


&lt;h2&gt;
  
  
  Office/Data Center Setup
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Internet
   ↓
Firewall
   ↓
Load Balancer
   ↓
Router
   ↓
Switch
   ↓
Servers
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;Flow:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;User types domain&lt;/li&gt;
&lt;li&gt;DNS resolves to load balancer IP&lt;/li&gt;
&lt;li&gt;Firewall checks request&lt;/li&gt;
&lt;li&gt;Load balancer selects server&lt;/li&gt;
&lt;li&gt;Router forwards&lt;/li&gt;
&lt;li&gt;Switch delivers&lt;/li&gt;
&lt;li&gt;Server responds&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Everything follows reverse path back.&lt;/p&gt;


&lt;h1&gt;
  
  
  7. Cloud Version (Modern Infrastructure)
&lt;/h1&gt;

&lt;p&gt;In cloud (AWS, GCP, Azure), hardware becomes virtual.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Internet
   ↓
WAF
   ↓
Load Balancer
   ↓
Security Groups
   ↓
Route Tables
   ↓
Virtual Instances
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Concepts are same. Only implementation is software-defined.&lt;/p&gt;

&lt;p&gt;And honestly, if you understand the physical version first, cloud becomes very easy to understand.&lt;/p&gt;




&lt;h1&gt;
  
  
  Final Thoughts
&lt;/h1&gt;

&lt;p&gt;As a software engineer, especially if we are into backend or system design, we should know:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Where firewall sits&lt;/li&gt;
&lt;li&gt;Where load balancer fits&lt;/li&gt;
&lt;li&gt;How routing works&lt;/li&gt;
&lt;li&gt;Why switches matter&lt;/li&gt;
&lt;li&gt;Why modem and router are not same&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When production breaks, these concepts help us debug faster. Otherwise we just say “server down maybe” without knowing real cause&lt;/p&gt;

&lt;p&gt;The internet looks like magic. But it’s not magic.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Good systems are built from small, clear responsibilities.&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;Happy Learning guys...&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>computerscience</category>
      <category>networking</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>TCP Working: 3-Way Handshake &amp; Reliable Communication</title>
      <dc:creator>Rajat Yadav</dc:creator>
      <pubDate>Wed, 11 Feb 2026 18:14:23 +0000</pubDate>
      <link>https://dev.to/rajat_yadav_/tcp-working-3-way-handshake-reliable-communication-44e6</link>
      <guid>https://dev.to/rajat_yadav_/tcp-working-3-way-handshake-reliable-communication-44e6</guid>
      <description>&lt;p&gt;When two computers talk over the internet, they don’t send data in one big file.&lt;br&gt;
They break it into small pieces called &lt;strong&gt;packets&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Now here’s the problem.&lt;/p&gt;

&lt;p&gt;Those packets don’t always behave nicely. They can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Arrive late&lt;/li&gt;
&lt;li&gt;Arrive out of order&lt;/li&gt;
&lt;li&gt;Arrive twice&lt;/li&gt;
&lt;li&gt;Or never arrive at all&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If we just throw packets into the internet without rules, things would be chaos.&lt;/p&gt;

&lt;p&gt;You would see:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Half loaded websites&lt;/li&gt;
&lt;li&gt;Broken downloads&lt;/li&gt;
&lt;li&gt;Messages missing some words in the middle&lt;/li&gt;
&lt;li&gt;Random glitches everywhere&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So obviously… we need some system.&lt;/p&gt;

&lt;p&gt;That system is called &lt;strong&gt;TCP&lt;/strong&gt;.&lt;/p&gt;




&lt;h1&gt;
  
  
  What is TCP and Why Do We Need It?
&lt;/h1&gt;

&lt;p&gt;&lt;strong&gt;TCP (Transmission Control Protocol)&lt;/strong&gt; is a set of rules that makes communication reliable.&lt;/p&gt;

&lt;p&gt;Its job is simple (but very powerful):&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Make sure data reaches&lt;/li&gt;
&lt;li&gt;Make sure it reaches in correct order&lt;/li&gt;
&lt;li&gt;Make sure it is not corrupted&lt;/li&gt;
&lt;li&gt;And make sure both sides agree when starting and ending&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Think of TCP like a very disciplined courier service.&lt;br&gt;
Not fast-fast, but very safe.&lt;/p&gt;

&lt;p&gt;Without TCP, the internet would technically work… but very badly.&lt;/p&gt;




&lt;h1&gt;
  
  
  What Problems TCP Solves
&lt;/h1&gt;

&lt;p&gt;TCP mainly handles three big problems:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Packet Loss
&lt;/h3&gt;

&lt;p&gt;Sometimes packets just disappear in the network.&lt;/p&gt;

&lt;p&gt;TCP fixes this by:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Numbering packets&lt;/li&gt;
&lt;li&gt;Waiting for confirmation (ACK)&lt;/li&gt;
&lt;li&gt;Resending if confirmation doesn’t come&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  2. Out-of-Order Delivery
&lt;/h3&gt;

&lt;p&gt;Internet doesn’t guarantee packets take same route.&lt;/p&gt;

&lt;p&gt;So packet #3 can arrive before packet #1.&lt;/p&gt;

&lt;p&gt;TCP solves this using sequence numbers.&lt;br&gt;
Receiver rearranges them before giving data to application.&lt;/p&gt;

&lt;p&gt;So your browser only sees clean, ordered data.&lt;/p&gt;




&lt;h3&gt;
  
  
  3. Data Corruption
&lt;/h3&gt;

&lt;p&gt;Sometimes packets get damaged during transmission.&lt;/p&gt;

&lt;p&gt;TCP uses something called a &lt;strong&gt;checksum&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;If checksum fails:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Packet is rejected&lt;/li&gt;
&lt;li&gt;Sender resends it&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So data integrity is maintained.&lt;/p&gt;




&lt;h1&gt;
  
  
  The TCP 3-Way Handshake (Before Data Starts)
&lt;/h1&gt;

&lt;p&gt;TCP does not just start sending data randomly.&lt;/p&gt;

&lt;p&gt;First, both sides confirm they are ready.&lt;/p&gt;

&lt;p&gt;This process is called the &lt;strong&gt;3-Way Handshake&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;It uses three steps:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;SYN&lt;/li&gt;
&lt;li&gt;SYN-ACK&lt;/li&gt;
&lt;li&gt;ACK&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let’s understand this slowly.&lt;/p&gt;




&lt;h2&gt;
  
  
  Conversation Analogy
&lt;/h2&gt;

&lt;p&gt;Imagine calling someone.&lt;/p&gt;

&lt;p&gt;You: “Hey, can we talk?”&lt;br&gt;
Friend: “Yes, I can hear you. Can you hear me?”&lt;br&gt;
You: “Yes, I can hear you. Let’s talk.”&lt;/p&gt;

&lt;p&gt;Now both sides know connection is good.&lt;/p&gt;

&lt;p&gt;Same happens in TCP.&lt;/p&gt;




&lt;h1&gt;
  
  
  Step-by-Step: SYN → SYN-ACK → ACK
&lt;/h1&gt;

&lt;p&gt;Let’s assume:&lt;/p&gt;

&lt;p&gt;Client = Your browser&lt;br&gt;
Server = Web server&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 1: SYN
&lt;/h2&gt;

&lt;p&gt;Client sends a packet with SYN flag.&lt;/p&gt;

&lt;p&gt;Meaning:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“I want to start a connection.”&lt;br&gt;
“Here is my starting sequence number.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Diagram:&lt;/p&gt;

&lt;p&gt;Client                Server&lt;br&gt;
| ---- SYN ----&amp;gt;      |&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 2: SYN-ACK
&lt;/h2&gt;

&lt;p&gt;Server replies with SYN-ACK.&lt;/p&gt;

&lt;p&gt;This means two things:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;SYN → “Yes, I also want to connect.”&lt;/li&gt;
&lt;li&gt;ACK → “I received your SYN.”&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Diagram:&lt;/p&gt;

&lt;p&gt;Client                Server&lt;br&gt;
| ---- SYN ----&amp;gt;      |&lt;br&gt;
| &amp;lt;--- SYN-ACK ---    |&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 3: ACK
&lt;/h2&gt;

&lt;p&gt;Client sends final ACK.&lt;/p&gt;

&lt;p&gt;Meaning:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“I received your response. Now we’re ready.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Diagram:&lt;/p&gt;

&lt;p&gt;Client                Server&lt;br&gt;
| ---- SYN ----&amp;gt;      |&lt;br&gt;
| &amp;lt;--- SYN-ACK ---    |&lt;br&gt;
| ---- ACK ----&amp;gt;      |&lt;/p&gt;

&lt;p&gt;Connection established ✅&lt;/p&gt;

&lt;p&gt;Now actual data can start.&lt;/p&gt;




&lt;h1&gt;
  
  
  How Data Transfer Works in TCP
&lt;/h1&gt;

&lt;p&gt;After handshake, data flows.&lt;/p&gt;

&lt;p&gt;TCP treats data as a &lt;strong&gt;stream of bytes&lt;/strong&gt;, not messages.&lt;/p&gt;

&lt;p&gt;Example:&lt;/p&gt;

&lt;p&gt;Suppose client sends:&lt;/p&gt;

&lt;p&gt;HELLO WORLD&lt;/p&gt;

&lt;p&gt;TCP might split it like:&lt;/p&gt;

&lt;p&gt;Packet 1 → Bytes 1000–1005&lt;br&gt;
Packet 2 → Bytes 1006–1010&lt;/p&gt;

&lt;p&gt;Each byte has a sequence number.&lt;/p&gt;

&lt;p&gt;Receiver uses those numbers to reassemble everything properly.&lt;/p&gt;

&lt;p&gt;Application just sees:&lt;/p&gt;

&lt;p&gt;HELLO WORLD&lt;/p&gt;

&lt;p&gt;It never sees the splitting.&lt;/p&gt;




&lt;h1&gt;
  
  
  Sequence Numbers and ACKs (Simple Idea)
&lt;/h1&gt;

&lt;p&gt;Sender sends:&lt;/p&gt;

&lt;p&gt;Bytes 1000–1499&lt;/p&gt;

&lt;p&gt;Receiver replies:&lt;/p&gt;

&lt;p&gt;ACK 1500&lt;/p&gt;

&lt;p&gt;Which means:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“I got everything till 1499. Send next from 1500.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This is called cumulative acknowledgement.&lt;/p&gt;

&lt;p&gt;It keeps things simple and efficient.&lt;/p&gt;




&lt;h1&gt;
  
  
  What Happens If Packet Is Lost?
&lt;/h1&gt;

&lt;p&gt;Suppose sender sends:&lt;/p&gt;

&lt;p&gt;Bytes 1000–1499&lt;/p&gt;

&lt;p&gt;But packet gets lost.&lt;/p&gt;

&lt;p&gt;Receiver never sends ACK.&lt;/p&gt;

&lt;p&gt;Sender waits for some time…&lt;/p&gt;

&lt;p&gt;No ACK?&lt;/p&gt;

&lt;p&gt;Sender assumes packet lost.&lt;/p&gt;

&lt;p&gt;Resends:&lt;/p&gt;

&lt;p&gt;Bytes 1000–1499&lt;/p&gt;

&lt;p&gt;This is called &lt;strong&gt;retransmission&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Application doesn’t even know this happened.&lt;/p&gt;

&lt;p&gt;TCP hides all this complexity.&lt;/p&gt;




&lt;h1&gt;
  
  
  What About Out-of-Order Packets?
&lt;/h1&gt;

&lt;p&gt;Suppose:&lt;/p&gt;

&lt;p&gt;Packet 1500–1999 arrives&lt;br&gt;
But 1000–1499 hasn’t arrived yet&lt;/p&gt;

&lt;p&gt;Receiver will:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Store 1500–1999 temporarily&lt;/li&gt;
&lt;li&gt;Still send ACK 1000
(Meaning: I’m still waiting for 1000 onwards)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Sender understands missing part and resends it.&lt;/p&gt;

&lt;p&gt;Everything gets fixed silently.&lt;/p&gt;




&lt;h1&gt;
  
  
  How TCP Ensures Correctness
&lt;/h1&gt;

&lt;p&gt;TCP ensures correctness using:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Sequence numbers → ordering&lt;/li&gt;
&lt;li&gt;ACKs → confirmation&lt;/li&gt;
&lt;li&gt;Retransmissions → reliability&lt;/li&gt;
&lt;li&gt;Checksums → corruption detection&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It’s like a very strict teacher checking every homework twice 😅&lt;/p&gt;




&lt;h1&gt;
  
  
  How TCP Connection Is Closed
&lt;/h1&gt;

&lt;p&gt;Starting needs handshake.&lt;br&gt;
Ending also needs proper closing.&lt;/p&gt;

&lt;p&gt;TCP uses:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;FIN (Finish)&lt;/li&gt;
&lt;li&gt;ACK&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let’s say client wants to close.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 1: Client sends FIN
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;“I’m done sending data.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Client                Server&lt;br&gt;
| ---- FIN ----&amp;gt;      |&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 2: Server sends ACK
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;“Okay, I know you’re done.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Client                Server&lt;br&gt;
| ---- FIN ----&amp;gt;      |&lt;br&gt;
| &amp;lt;--- ACK ----       |&lt;/p&gt;

&lt;p&gt;Server might still send remaining data.&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 3: Server sends FIN
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;“I’m also done sending.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Client                Server&lt;br&gt;
| ---- FIN ----&amp;gt;      |&lt;br&gt;
| &amp;lt;--- ACK ----       |&lt;br&gt;
| &amp;lt;--- FIN ----       |&lt;/p&gt;




&lt;h2&gt;
  
  
  Step 4: Client sends ACK
&lt;/h2&gt;

&lt;blockquote&gt;
&lt;p&gt;“Got it. Now we’re fully done.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Client                Server&lt;br&gt;
| ---- FIN ----&amp;gt;      |&lt;br&gt;
| &amp;lt;--- ACK ----       |&lt;br&gt;
| &amp;lt;--- FIN ----       |&lt;br&gt;
| ---- ACK ----&amp;gt;      |&lt;/p&gt;

&lt;p&gt;Connection closed ✅&lt;/p&gt;




&lt;h1&gt;
  
  
  TCP Lifecycle Summary
&lt;/h1&gt;

&lt;p&gt;You can think TCP in three phases:&lt;/p&gt;

&lt;h2&gt;
  
  
  1. Establish
&lt;/h2&gt;

&lt;p&gt;SYN → SYN-ACK → ACK&lt;/p&gt;

&lt;h2&gt;
  
  
  2. Transfer
&lt;/h2&gt;

&lt;p&gt;Data + Sequence numbers + ACKs + Retransmissions&lt;/p&gt;

&lt;h2&gt;
  
  
  3. Close
&lt;/h2&gt;

&lt;p&gt;FIN → ACK → FIN → ACK&lt;/p&gt;

&lt;p&gt;Simple structure. Very powerful system.&lt;/p&gt;




&lt;h1&gt;
  
  
  Why TCP Matters for You (As a Developer)
&lt;/h1&gt;

&lt;p&gt;Even if you don’t write TCP manually:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;HTTP runs on TCP&lt;/li&gt;
&lt;li&gt;APIs use TCP&lt;/li&gt;
&lt;li&gt;Database connections use TCP&lt;/li&gt;
&lt;li&gt;Backend services depend on TCP&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When you debug:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Slow APIs&lt;/li&gt;
&lt;li&gt;Timeout errors&lt;/li&gt;
&lt;li&gt;Connection reset issues&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;TCP is involved somewhere.&lt;/p&gt;

&lt;p&gt;Understanding TCP makes you stronger backend engineer.&lt;/p&gt;




&lt;h1&gt;
  
  
  Final Thoughts
&lt;/h1&gt;

&lt;p&gt;Without TCP, internet would feel broken and unstable.&lt;/p&gt;

&lt;p&gt;It is slow sometimes, yes.&lt;br&gt;
But it is reliable.&lt;/p&gt;

&lt;p&gt;And in networking, reliability matters more than speed in many cases.&lt;/p&gt;

&lt;p&gt;Happy learning..........&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>computerscience</category>
      <category>networking</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Getting Started with cURL</title>
      <dc:creator>Rajat Yadav</dc:creator>
      <pubDate>Wed, 11 Feb 2026 17:40:26 +0000</pubDate>
      <link>https://dev.to/rajat_yadav_/getting-started-with-curl-c4d</link>
      <guid>https://dev.to/rajat_yadav_/getting-started-with-curl-c4d</guid>
      <description>&lt;p&gt;Before jumping into tools like cURL, we need to understand something more important:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;Who are we even talking to?&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;That “someone” is called a &lt;strong&gt;server&lt;/strong&gt;.&lt;/p&gt;




&lt;h2&gt;
  
  
  What Is a Server? (In Very Simple Words)
&lt;/h2&gt;

&lt;p&gt;A &lt;strong&gt;server&lt;/strong&gt; is just a computer that gives something when you ask for it.&lt;/p&gt;

&lt;p&gt;It can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;send you a website&lt;/li&gt;
&lt;li&gt;give you data&lt;/li&gt;
&lt;li&gt;store your files&lt;/li&gt;
&lt;li&gt;save your login info&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When you open Instagram, submit a form, or fetch API data you are talking to a server.&lt;/p&gt;

&lt;p&gt;You (your browser, your app, your terminal) are called the &lt;strong&gt;client&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;So the basic idea is:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Client  →  Server  →  Response
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You ask.&lt;br&gt;
Server processes.&lt;br&gt;
Server replies.&lt;/p&gt;

&lt;p&gt;That’s it.&lt;/p&gt;


&lt;h2&gt;
  
  
  Does a Server Look Special?
&lt;/h2&gt;

&lt;p&gt;Not really.&lt;/p&gt;

&lt;p&gt;A server is also a computer, just like yours.&lt;br&gt;
It has:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;CPU&lt;/li&gt;
&lt;li&gt;Memory&lt;/li&gt;
&lt;li&gt;Storage&lt;/li&gt;
&lt;li&gt;Operating System (Ubuntu, Windows Server, etc.)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;The only difference?&lt;/p&gt;

&lt;p&gt;It is always running and always ready to respond to requests.&lt;/p&gt;


&lt;h2&gt;
  
  
  Types of Servers
&lt;/h2&gt;

&lt;p&gt;There are different kinds of servers depending on what they provide.&lt;/p&gt;
&lt;h3&gt;
  
  
  1. Web Server
&lt;/h3&gt;

&lt;p&gt;Delivers websites (HTML, CSS, JavaScript, images).&lt;/p&gt;

&lt;p&gt;Example flow:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Browser → Web Server → HTML page
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  2. File Server
&lt;/h3&gt;

&lt;p&gt;Stores and manages files.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Client → File Server → File Download
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  3. Mail Server
&lt;/h3&gt;

&lt;p&gt;Handles sending and receiving emails.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Email App → Mail Server → Inbox
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  4. Database Server
&lt;/h3&gt;

&lt;p&gt;Stores structured data (like users, products, orders).&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Backend App → Database Server → Data
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;Now that we understand servers…&lt;/p&gt;

&lt;p&gt;Let’s talk about how we can speak to them without a browser.&lt;/p&gt;




&lt;h1&gt;
  
  
  What is cURL? (Very Simple Explanation)
&lt;/h1&gt;

&lt;p&gt;cURL is a &lt;strong&gt;command-line tool&lt;/strong&gt; that lets you send requests to a server directly from your terminal.&lt;/p&gt;

&lt;p&gt;Instead of clicking buttons in a browser,&lt;br&gt;
you type a command.&lt;/p&gt;

&lt;p&gt;That’s it.&lt;/p&gt;

&lt;p&gt;cURL stands for &lt;strong&gt;Client URL&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Meaning:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;You are the client&lt;/li&gt;
&lt;li&gt;You send something to a URL&lt;/li&gt;
&lt;li&gt;You get a response back&lt;/li&gt;
&lt;/ul&gt;


&lt;h2&gt;
  
  
  How cURL Communicates
&lt;/h2&gt;

&lt;p&gt;Here’s what happens when you use cURL:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Terminal (You)
      ↓
cURL builds HTTP request
      ↓
Server receives request
      ↓
Server sends response
      ↓
cURL prints response in terminal
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;No UI.&lt;br&gt;
No fancy design.&lt;br&gt;
Just raw communication.&lt;/p&gt;


&lt;h1&gt;
  
  
  Your First cURL Command
&lt;/h1&gt;

&lt;p&gt;The simplest possible example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl https://example.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What just happened?&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;cURL sent a &lt;strong&gt;GET request&lt;/strong&gt; to the server.&lt;/li&gt;
&lt;li&gt;The server processed it.&lt;/li&gt;
&lt;li&gt;The server sent back a response.&lt;/li&gt;
&lt;li&gt;cURL printed the response (HTML) in your terminal.&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;You just fetched a webpage without opening a browser.&lt;/p&gt;

&lt;p&gt;Feels small… but it’s powerful.&lt;/p&gt;




&lt;h1&gt;
  
  
  What Exactly Is a Request and Response?
&lt;/h1&gt;

&lt;p&gt;Every HTTP communication has two parts:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Request  →  Response
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  The Request (What You Send)
&lt;/h2&gt;

&lt;p&gt;A request usually contains:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;URL (where you’re sending it)&lt;/li&gt;
&lt;li&gt;Method (GET or POST)&lt;/li&gt;
&lt;li&gt;Headers (extra info)&lt;/li&gt;
&lt;li&gt;Body (data, sometimes)&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  The Response (What Server Sends Back)
&lt;/h2&gt;

&lt;p&gt;A response has three main parts:&lt;/p&gt;

&lt;h3&gt;
  
  
  1. Status Code
&lt;/h3&gt;

&lt;p&gt;Tells you what happened.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;200 → Success&lt;/li&gt;
&lt;li&gt;404 → Not Found&lt;/li&gt;
&lt;li&gt;500 → Server Error&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  2. Headers
&lt;/h3&gt;

&lt;p&gt;Extra information like content type, date, etc.&lt;/p&gt;




&lt;h3&gt;
  
  
  3. Body
&lt;/h3&gt;

&lt;p&gt;The actual data (HTML, JSON, text, etc.)&lt;/p&gt;




&lt;p&gt;If you want to see everything (status + headers + body), use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;-i&lt;/span&gt; https://example.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You’ll see something like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;HTTP/2 200
content-type: text/html
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then the HTML.&lt;/p&gt;

&lt;p&gt;200 means it worked.&lt;/p&gt;




&lt;h1&gt;
  
  
  GET vs POST (Only These Two for Now)
&lt;/h1&gt;

&lt;p&gt;Don’t overload yourself with too many methods.&lt;/p&gt;

&lt;p&gt;Just understand these two.&lt;/p&gt;




&lt;h2&gt;
  
  
  GET → “Give me data.”
&lt;/h2&gt;

&lt;p&gt;Used to fetch or read something.&lt;/p&gt;

&lt;p&gt;Default in cURL.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl https://api.example.com/users
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This means:&lt;/p&gt;

&lt;p&gt;“Hey server, send me users.”&lt;/p&gt;




&lt;h2&gt;
  
  
  POST → “Here is data. Do something with it.”
&lt;/h2&gt;

&lt;p&gt;Used when sending data to the server.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl &lt;span class="nt"&gt;-X&lt;/span&gt; POST https://api.example.com/users &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-H&lt;/span&gt; &lt;span class="s2"&gt;"Content-Type: application/json"&lt;/span&gt; &lt;span class="se"&gt;\&lt;/span&gt;
  &lt;span class="nt"&gt;-d&lt;/span&gt; &lt;span class="s1"&gt;'{"name":"Alice"}'&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What this does:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;-X POST&lt;/code&gt; → use POST method&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;-H&lt;/code&gt; → sending extra information&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;-d&lt;/code&gt; → sending actual data&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Don’t worry about remembering everything now. Just understand the idea.&lt;/p&gt;




&lt;h1&gt;
  
  
  Using cURL to Talk to APIs
&lt;/h1&gt;

&lt;p&gt;APIs are just URLs that send back data (usually JSON).&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;curl https://jsonplaceholder.typicode.com/posts/1
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You’ll get something like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight json"&gt;&lt;code&gt;&lt;span class="p"&gt;{&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"userId"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"id"&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt;&lt;span class="w"&gt; &lt;/span&gt;&lt;span class="mi"&gt;1&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt;&lt;span class="w"&gt;
  &lt;/span&gt;&lt;span class="nl"&gt;"title"&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;"body"&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="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;That’s an API response.&lt;/p&gt;

&lt;p&gt;You just interacted with a backend system directly.&lt;/p&gt;




&lt;h1&gt;
  
  
  Browser vs cURL (Conceptual Difference)
&lt;/h1&gt;

&lt;p&gt;Both send HTTP requests.&lt;/p&gt;

&lt;p&gt;But:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Browser:
Request → Server → Response → Render UI
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;





&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;cURL:
Request → Server → Raw Response in Terminal
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Browser shows design.&lt;br&gt;
cURL shows truth.&lt;/p&gt;

&lt;p&gt;That’s why backend developers love it.&lt;/p&gt;


&lt;h1&gt;
  
  
  Common Mistakes Beginners Make
&lt;/h1&gt;

&lt;p&gt;Let me save you some frustration 😅&lt;/p&gt;
&lt;h3&gt;
  
  
  1. Forgetting quotes
&lt;/h3&gt;

&lt;p&gt;If URL has spaces or special characters:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;curl "https://example.com?name=John Doe"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  2. Wrong Content-Type
&lt;/h3&gt;

&lt;p&gt;If sending JSON, always add:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;-H "Content-Type: application/json"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h3&gt;
  
  
  3. Typos in URL
&lt;/h3&gt;

&lt;p&gt;http vs https&lt;br&gt;
Missing slash&lt;br&gt;
Wrong domain&lt;/p&gt;

&lt;p&gt;Happens more than you think.&lt;/p&gt;


&lt;h3&gt;
  
  
  4. Ignoring Status Code
&lt;/h3&gt;

&lt;p&gt;Always check:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;HTTP/2 200
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Use &lt;code&gt;-i&lt;/code&gt; if needed.&lt;/p&gt;




&lt;h1&gt;
  
  
  Where cURL Fits in Backend Development
&lt;/h1&gt;

&lt;p&gt;If you’re building backend APIs:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;You build endpoint
      ↓
You test with cURL
      ↓
You verify response
      ↓
Frontend connects later
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;It’s fast.&lt;br&gt;
No need for frontend.&lt;br&gt;
No need for Postman (at least initially).&lt;/p&gt;

&lt;p&gt;Also used in:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Automation scripts&lt;/li&gt;
&lt;li&gt;Cron jobs&lt;/li&gt;
&lt;li&gt;Health checks&lt;/li&gt;
&lt;li&gt;Debugging production issues&lt;/li&gt;
&lt;/ul&gt;


&lt;h1&gt;
  
  
  Final Thought
&lt;/h1&gt;

&lt;p&gt;cURL is not complicated.&lt;/p&gt;

&lt;p&gt;It just looks scary because it’s raw.&lt;/p&gt;

&lt;p&gt;But once you understand this flow:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Client → Request → Server → Response
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Everything becomes logical.&lt;/p&gt;

&lt;p&gt;Start small.&lt;br&gt;
Use simple GET requests.&lt;br&gt;
Slowly add headers and POST.&lt;/p&gt;

&lt;p&gt;Confidence first. Depth later.&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>cli</category>
      <category>tutorial</category>
      <category>webdev</category>
    </item>
    <item>
      <title>DNS &amp; DNS Record Types Explained</title>
      <dc:creator>Rajat Yadav</dc:creator>
      <pubDate>Wed, 11 Feb 2026 17:12:56 +0000</pubDate>
      <link>https://dev.to/rajat_yadav_/dns-dns-record-types-explained-5gjb</link>
      <guid>https://dev.to/rajat_yadav_/dns-dns-record-types-explained-5gjb</guid>
      <description>&lt;h1&gt;
  
  
  When You Type &lt;code&gt;autmnit.github.io&lt;/code&gt;, How Does Your Browser Know Where It Lives?
&lt;/h1&gt;

&lt;p&gt;When you enter:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;autmnit.github.io
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;into your browser, something interesting happens behind the scenes.&lt;/p&gt;

&lt;p&gt;Your browser doesn’t understand names like humans do.&lt;br&gt;
It only understands &lt;strong&gt;IP addresses&lt;/strong&gt; numbers like:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;So the real question is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;How does the browser convert a name into a number?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;That translation is handled by something called &lt;strong&gt;DNS&lt;/strong&gt;.&lt;/p&gt;




&lt;h1&gt;
  
  
  What Is DNS? (The Internet’s Phonebook)
&lt;/h1&gt;

&lt;p&gt;Let’s keep it very simple.&lt;/p&gt;

&lt;p&gt;The internet runs on &lt;strong&gt;IP addresses&lt;/strong&gt;, but humans prefer &lt;strong&gt;names&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Instead of remembering:&lt;br&gt;
&lt;/p&gt;

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

&lt;/div&gt;



&lt;p&gt;we type:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;autmnit.github.io
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;DNS (Domain Name System) is the system that converts:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Name → IP address
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You can think of DNS like your phone contacts.&lt;/p&gt;

&lt;p&gt;You tap on “Mom”, but your phone actually dials a number.&lt;br&gt;
You don’t see the number — but it’s there.&lt;/p&gt;

&lt;p&gt;Same thing here.&lt;/p&gt;


&lt;h2&gt;
  
  
  Simple Flow Diagram
&lt;/h2&gt;


&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;You type: autmnit.github.io

Browser → DNS: "What is the IP of autmnit.github.io?"

DNS → "It is 203.0.113.10"

Browser → Connects to 203.0.113.10
Website loads.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;


&lt;p&gt;That’s DNS in action.&lt;/p&gt;


&lt;h1&gt;
  
  
  Why DNS Records Are Needed
&lt;/h1&gt;

&lt;p&gt;DNS is not just one big list.&lt;/p&gt;

&lt;p&gt;It’s more like a structured database with different &lt;strong&gt;types of records&lt;/strong&gt;, and each type answers a different question.&lt;/p&gt;

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

&lt;ul&gt;
&lt;li&gt;Where is the website hosted?&lt;/li&gt;
&lt;li&gt;Where should emails be delivered?&lt;/li&gt;
&lt;li&gt;Who is responsible for managing this domain?&lt;/li&gt;
&lt;li&gt;Is this domain verified with Google or some service?&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each of these has a specific &lt;strong&gt;DNS record type&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;One domain → Many records.&lt;/p&gt;

&lt;p&gt;Just like one contact in your phone can have:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Mobile number&lt;/li&gt;
&lt;li&gt;Office number&lt;/li&gt;
&lt;li&gt;Email&lt;/li&gt;
&lt;li&gt;Notes&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A domain can have:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A record&lt;/li&gt;
&lt;li&gt;AAAA record&lt;/li&gt;
&lt;li&gt;CNAME&lt;/li&gt;
&lt;li&gt;MX&lt;/li&gt;
&lt;li&gt;NS&lt;/li&gt;
&lt;li&gt;TXT&lt;/li&gt;
&lt;li&gt;And more&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Let’s understand them slowly, one by one.&lt;/p&gt;


&lt;h1&gt;
  
  
  NS Record – Who Is Responsible for This Domain?
&lt;/h1&gt;

&lt;p&gt;NS stands for &lt;strong&gt;Name Server&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;An NS record answers this question:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Who is managing the DNS for this domain?”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;It does not tell the IP address of the website.&lt;/p&gt;

&lt;p&gt;Instead, it tells the world:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“If you want DNS information about autmnit.github.io, ask these servers.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Example (conceptually):&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;autmnit.github.io
NS → ns1.dns-provider.com
NS → ns2.dns-provider.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That means:&lt;/p&gt;

&lt;p&gt;All DNS questions should go to those name servers.&lt;/p&gt;




&lt;h2&gt;
  
  
  Simple NS Diagram
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Internet: "Where do I ask about autmnit.github.io?"

Answer: "Ask ns1.dns-provider.com"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Think of it like paperwork.&lt;/p&gt;

&lt;p&gt;NS = the office that manages all the records.&lt;/p&gt;




&lt;h1&gt;
  
  
  A Record – Name → IPv4 Address
&lt;/h1&gt;

&lt;p&gt;This is one of the most important records.&lt;/p&gt;

&lt;p&gt;An &lt;strong&gt;A record&lt;/strong&gt; maps a domain name to an IPv4 address.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;autmnit.github.io → 203.0.113.10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;When your browser asks:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Where is autmnit.github.io?”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The A record answers:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“It’s at 203.0.113.10.”&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  Diagram for A Record
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;autmnit.github.io
        ↓
   203.0.113.10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;That’s it. Direct mapping.&lt;/p&gt;

&lt;p&gt;If you remember just one DNS record, this is usually the one beginners think about.&lt;/p&gt;




&lt;h1&gt;
  
  
  AAAA Record – Name → IPv6 Address
&lt;/h1&gt;

&lt;p&gt;An AAAA record works just like an A record.&lt;/p&gt;

&lt;p&gt;But instead of IPv4, it maps to &lt;strong&gt;IPv6&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;IPv6 addresses look like:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;2001:db8:85a3::8a2e:370:7334
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;autmnit.github.io → 2001:db8:85a3::8a2e:370:7334
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;You don’t need to go deep into IPv6 right now.&lt;/p&gt;

&lt;p&gt;Just remember:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;A     = IPv4
AAAA  = IPv6
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Same purpose, different address type.&lt;/p&gt;




&lt;h1&gt;
  
  
  CNAME Record – One Name Points to Another Name
&lt;/h1&gt;

&lt;p&gt;CNAME stands for &lt;strong&gt;Canonical Name&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;It does NOT point to an IP.&lt;/p&gt;

&lt;p&gt;It points to another domain name.&lt;/p&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;www.autmnit.github.io → autmnit.github.io
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This means:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“To find &lt;a href="http://www.autmnit.github.io" rel="noopener noreferrer"&gt;www.autmnit.github.io&lt;/a&gt;, just look up autmnit.github.io.”&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  CNAME Diagram
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;www.autmnit.github.io
        ↓
autmnit.github.io
        ↓
203.0.113.10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;So CNAME is like a nickname.&lt;/p&gt;

&lt;p&gt;Important beginner confusion:&lt;/p&gt;

&lt;h3&gt;
  
  
  A vs CNAME
&lt;/h3&gt;

&lt;p&gt;A record:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Name → IP directly
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;CNAME:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Name → Another name
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Also:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A CNAME cannot point to an IP.&lt;/li&gt;
&lt;li&gt;Usually a domain has either A or CNAME for the same name, not both.&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  MX Record – How Emails Find the Mail Server
&lt;/h1&gt;

&lt;p&gt;MX stands for &lt;strong&gt;Mail Exchange&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;It answers this question:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Where should emails for this domain be delivered?”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;autmnit.github.io → MX → mail.autmnit.github.io
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Now imagine someone sends:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;hello@autmnit.github.io
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;The sending mail server asks DNS:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Where do I send mail for autmnit.github.io?”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;DNS replies:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Send it to mail.autmnit.github.io.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Then DNS looks up:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mail.autmnit.github.io → 203.0.113.20
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;And the email gets delivered.&lt;/p&gt;




&lt;h2&gt;
  
  
  Email Flow Diagram
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Email sent to: hello@autmnit.github.io

Mail server → DNS: "Where to deliver?"

DNS → MX: mail.autmnit.github.io
DNS → A: 203.0.113.20

Mail server → connects to 203.0.113.20
Email delivered.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  NS vs MX (Common Confusion)
&lt;/h2&gt;

&lt;p&gt;NS:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Who manages DNS for this domain?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;MX:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;Where should emails go?&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;They solve completely different problems.&lt;/p&gt;




&lt;h1&gt;
  
  
  TXT Record – Extra Info and Verification
&lt;/h1&gt;

&lt;p&gt;TXT records store text information.&lt;/p&gt;

&lt;p&gt;They are widely used for:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;SPF (which servers can send email)&lt;/li&gt;
&lt;li&gt;DKIM / DMARC (email authentication)&lt;/li&gt;
&lt;li&gt;Domain verification (Google, AWS, etc.)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Example:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;autmnit.github.io → TXT → "v=spf1 include:_spf.google.com ~all"
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;TXT records don’t route traffic.&lt;/p&gt;

&lt;p&gt;They add rules, proof, or verification.&lt;/p&gt;

&lt;p&gt;Think of them like sticky notes attached to your domain.&lt;/p&gt;




&lt;h1&gt;
  
  
  How All Records Work Together (Complete Setup Example)
&lt;/h1&gt;

&lt;p&gt;Let’s imagine a full setup for:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;autmnit.github.io
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h2&gt;
  
  
  Example DNS Structure
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1. NS Records
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;NS → ns1.dns-provider.com
NS → ns2.dns-provider.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;These manage everything.&lt;/p&gt;




&lt;h3&gt;
  
  
  2. A Record (Website)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;autmnit.github.io → 203.0.113.10
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Website lives here.&lt;/p&gt;




&lt;h3&gt;
  
  
  3. AAAA Record (Optional)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;autmnit.github.io → 2001:db8:85a3::8a2e:370:7334
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;IPv6 version.&lt;/p&gt;




&lt;h3&gt;
  
  
  4. CNAME (www version)
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;www.autmnit.github.io → autmnit.github.io
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Alias for main domain.&lt;/p&gt;




&lt;h3&gt;
  
  
  5. Mail Server Setup
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mail.autmnit.github.io → 203.0.113.20
autmnit.github.io → MX → mail.autmnit.github.io
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Emails delivered correctly.&lt;/p&gt;




&lt;h3&gt;
  
  
  6. TXT Records
&lt;/h3&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;TXT → SPF rule
TXT → Domain verification code
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Security and verification handled.&lt;/p&gt;




&lt;h1&gt;
  
  
  Complete Website Loading Flow
&lt;/h1&gt;

&lt;h2&gt;
  
  
  When you open autmnit.github.io
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Browser → DNS: "IP of autmnit.github.io?"

DNS:
   NS → Responsible name server
   A  → 203.0.113.10

Browser → Connects to 203.0.113.10
Website loads.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h2&gt;
  
  
  When someone sends email
&lt;/h2&gt;



&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Mail server → DNS: "MX for autmnit.github.io?"

DNS:
   MX → mail.autmnit.github.io
   A  → 203.0.113.20

Mail server → Connects to 203.0.113.20
Email delivered.
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;h1&gt;
  
  
  Quick Recap of All Records
&lt;/h1&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Record&lt;/th&gt;
&lt;th&gt;What It Solves&lt;/th&gt;
&lt;th&gt;Simple Meaning&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;NS&lt;/td&gt;
&lt;td&gt;Who manages DNS?&lt;/td&gt;
&lt;td&gt;Official DNS authority&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;A&lt;/td&gt;
&lt;td&gt;Where is website (IPv4)?&lt;/td&gt;
&lt;td&gt;Name → IPv4&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;AAAA&lt;/td&gt;
&lt;td&gt;Where is website (IPv6)?&lt;/td&gt;
&lt;td&gt;Name → IPv6&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;CNAME&lt;/td&gt;
&lt;td&gt;Alias for another name&lt;/td&gt;
&lt;td&gt;Nickname&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;MX&lt;/td&gt;
&lt;td&gt;Where do emails go?&lt;/td&gt;
&lt;td&gt;Mail server&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;TXT&lt;/td&gt;
&lt;td&gt;Extra info &amp;amp; verification&lt;/td&gt;
&lt;td&gt;Notes &amp;amp; rules&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h1&gt;
  
  
  Final Thoughts
&lt;/h1&gt;

&lt;p&gt;DNS sounds complex at first, but honestly it’s just:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A system that converts names into IP addresses&lt;/li&gt;
&lt;li&gt;A set of small records, each solving one specific problem&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If you remember:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;A / AAAA → website location
CNAME → alias
MX → email routing
NS → who manages DNS
TXT → extra rules and verification
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then you already understand DNS better than many beginners.&lt;/p&gt;

&lt;p&gt;From here, the best thing you can do is:&lt;/p&gt;

&lt;p&gt;Open your domain DNS settings and just observe each record type.&lt;br&gt;
Slowly it stops feeling like magic and starts feeling like logic.&lt;/p&gt;

&lt;p&gt;And once that happens, you’re in control.&lt;/p&gt;

&lt;p&gt;Happy learning guys..&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>networking</category>
      <category>tutorial</category>
      <category>webdev</category>
    </item>
    <item>
      <title>TCP vs UDP: When to Use What, and How TCP Relates to HTTP</title>
      <dc:creator>Rajat Yadav</dc:creator>
      <pubDate>Wed, 11 Feb 2026 13:48:07 +0000</pubDate>
      <link>https://dev.to/rajat_yadav_/tcp-vs-udp-when-to-use-what-and-how-tcp-relates-to-http-374b</link>
      <guid>https://dev.to/rajat_yadav_/tcp-vs-udp-when-to-use-what-and-how-tcp-relates-to-http-374b</guid>
      <description>&lt;p&gt;When we make two computers communicate over the internet, they don't just throwing data at each other at random. They must follow some rules. Otherwise packets might get lost, arrive out of order, get duplicated, or completely overload the other machine.&lt;/p&gt;

&lt;p&gt;That’s why the internet uses &lt;strong&gt;protocols&lt;/strong&gt; agreed-upon rules for communication.&lt;/p&gt;

&lt;p&gt;At the transport layer, two of the most important protocols are:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;TCP (Transmission Control Protocol)&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;UDP (User Datagram Protocol)&lt;/strong&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;On top of these, we have &lt;strong&gt;HTTP&lt;/strong&gt;, which your browser and web servers use to exchange web data. But here’s something many beginners misunderstand:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;HTTP does not replace TCP.&lt;br&gt;
It runs on top of it.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Let’s break this down slowly and clearly.&lt;/p&gt;




&lt;h1&gt;
  
  
  The Internet Needs Rules to Send Data
&lt;/h1&gt;

&lt;h2&gt;
  
  
  The basic problem
&lt;/h2&gt;

&lt;p&gt;Imagine your computer wants to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Load a webpage&lt;/li&gt;
&lt;li&gt;Send a message&lt;/li&gt;
&lt;li&gt;Stream a video&lt;/li&gt;
&lt;li&gt;Call someone on a video app&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Between you and the other computer, the network can:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Drop packets&lt;/li&gt;
&lt;li&gt;Deliver them in the wrong order&lt;/li&gt;
&lt;li&gt;Duplicate them&lt;/li&gt;
&lt;li&gt;Get congested&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If there were no rules to handle this chaos, communication would be unreliable and messy.&lt;/p&gt;

&lt;p&gt;So the internet uses different layers of protocols. At the transport layer, the main rules for sending data from point A to point B are &lt;strong&gt;TCP and UDP&lt;/strong&gt;.&lt;/p&gt;




&lt;h1&gt;
  
  
  Two Different Philosophies
&lt;/h1&gt;

&lt;p&gt;You can think of TCP and UDP as two different mindsets.&lt;/p&gt;

&lt;h3&gt;
  
  
  TCP mindset:
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;“I want everything delivered correctly, in order, and nothing should be lost.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Like a registered courier or a phone call where you confirm every message.&lt;/p&gt;

&lt;h3&gt;
  
  
  UDP mindset:
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;“I want speed. If something gets lost, that’s okay.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Like a live announcement where you don’t pause to confirm every word.&lt;/p&gt;

&lt;p&gt;Neither one is “better.” They just solve different problems.&lt;/p&gt;




&lt;h1&gt;
  
  
  What Are TCP and UDP? (High-Level View)
&lt;/h1&gt;

&lt;h2&gt;
  
  
  TCP : Safe and Reliable
&lt;/h2&gt;

&lt;p&gt;TCP stands for &lt;strong&gt;Transmission Control Protocol&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;It is:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Connection-oriented&lt;/li&gt;
&lt;li&gt;Reliable&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Connection oriented means:
&lt;/h3&gt;

&lt;p&gt;Before sending actual data, both sides establish a connection. This is done using the famous &lt;strong&gt;3-way handshake&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;Basically:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;“Hey, can we talk?”&lt;/li&gt;
&lt;li&gt;“Yes, we can.”&lt;/li&gt;
&lt;li&gt;“Okay, let’s start.”&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Reliable means:
&lt;/h3&gt;

&lt;p&gt;TCP guarantees:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Data arrives&lt;/li&gt;
&lt;li&gt;Data arrives in order&lt;/li&gt;
&lt;li&gt;Data is not corrupted&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It uses:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Acknowledgements (ACKs)&lt;/li&gt;
&lt;li&gt;Retransmissions&lt;/li&gt;
&lt;li&gt;Flow control&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;You can think of TCP like a phone call:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;You establish the call.&lt;/li&gt;
&lt;li&gt;You confirm the other person heard you.&lt;/li&gt;
&lt;li&gt;If something is unclear, you repeat it.&lt;/li&gt;
&lt;li&gt;You speak at a pace the other person can handle.&lt;/li&gt;
&lt;/ol&gt;

&lt;h3&gt;
  
  
  Trade-off
&lt;/h3&gt;

&lt;p&gt;All this safety adds overhead:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Extra headers&lt;/li&gt;
&lt;li&gt;Handshakes&lt;/li&gt;
&lt;li&gt;Retransmissions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So TCP can be slower and heavier compared to UDP.&lt;/p&gt;




&lt;h2&gt;
  
  
  UDP – Fast but Risky
&lt;/h2&gt;

&lt;p&gt;UDP stands for &lt;strong&gt;User Datagram Protocol&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;It is:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Connectionless&lt;/li&gt;
&lt;li&gt;Best-effort&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Connectionless means:
&lt;/h3&gt;

&lt;p&gt;No handshake. No setup. You just send packets.&lt;/p&gt;

&lt;h3&gt;
  
  
  Best-effort means:
&lt;/h3&gt;

&lt;p&gt;There are no guarantees.&lt;/p&gt;

&lt;p&gt;Packets may:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Get lost&lt;/li&gt;
&lt;li&gt;Arrive out of order&lt;/li&gt;
&lt;li&gt;Be duplicated&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;UDP does not fix this for you.&lt;/p&gt;

&lt;p&gt;Think of UDP like a live broadcast:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;No handshake with each listener&lt;/li&gt;
&lt;li&gt;No confirmation messages&lt;/li&gt;
&lt;li&gt;No waiting for slow receivers&lt;/li&gt;
&lt;li&gt;Just send and move on&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Trade-off
&lt;/h3&gt;

&lt;p&gt;Less overhead = lower latency.&lt;/p&gt;

&lt;p&gt;UDP is faster and lighter, but less reliable.&lt;/p&gt;




&lt;h1&gt;
  
  
  Key Differences Between TCP and UDP
&lt;/h1&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Aspect&lt;/th&gt;
&lt;th&gt;TCP&lt;/th&gt;
&lt;th&gt;UDP&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;Connection&lt;/td&gt;
&lt;td&gt;Connection-oriented (handshake)&lt;/td&gt;
&lt;td&gt;Connectionless&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Reliability&lt;/td&gt;
&lt;td&gt;Reliable (ACK + retransmit)&lt;/td&gt;
&lt;td&gt;No guarantee&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Order&lt;/td&gt;
&lt;td&gt;Guaranteed&lt;/td&gt;
&lt;td&gt;Not guaranteed&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Speed&lt;/td&gt;
&lt;td&gt;Slower&lt;/td&gt;
&lt;td&gt;Faster&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Overhead&lt;/td&gt;
&lt;td&gt;Higher&lt;/td&gt;
&lt;td&gt;Lower&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Analogy&lt;/td&gt;
&lt;td&gt;Phone call&lt;/td&gt;
&lt;td&gt;Broadcast announcement&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h1&gt;
  
  
  Simplified Flow Comparison
&lt;/h1&gt;

&lt;h3&gt;
  
  
  TCP
&lt;/h3&gt;

&lt;p&gt;Client → Server&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;SYN →&lt;/li&gt;
&lt;li&gt;SYN-ACK ←&lt;/li&gt;
&lt;li&gt;ACK →&lt;/li&gt;
&lt;li&gt;Data →&lt;/li&gt;
&lt;li&gt;ACK ←&lt;/li&gt;
&lt;li&gt;FIN →&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There is setup, confirmation, and proper closing.&lt;/p&gt;

&lt;h3&gt;
  
  
  UDP
&lt;/h3&gt;

&lt;p&gt;Client → Server&lt;/p&gt;

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

&lt;p&gt;No handshake. No acknowledgements.&lt;/p&gt;

&lt;p&gt;Just send.&lt;/p&gt;




&lt;h1&gt;
  
  
  When Should You Use TCP?
&lt;/h1&gt;

&lt;p&gt;Use TCP when correctness matters more than speed.&lt;/p&gt;

&lt;p&gt;Examples:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Loading a webpage&lt;/li&gt;
&lt;li&gt;Downloading a file&lt;/li&gt;
&lt;li&gt;Sending an email&lt;/li&gt;
&lt;li&gt;API calls&lt;/li&gt;
&lt;li&gt;Database connections&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If even one byte is missing, the result becomes wrong or broken.&lt;/p&gt;

&lt;p&gt;Mental model:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Better to wait slightly longer and get the correct data.”&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h1&gt;
  
  
  When Should You Use UDP?
&lt;/h1&gt;

&lt;p&gt;Use UDP when low latency matters more than perfect delivery.&lt;/p&gt;

&lt;p&gt;Examples:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Video calls&lt;/li&gt;
&lt;li&gt;Online games&lt;/li&gt;
&lt;li&gt;Live streaming&lt;/li&gt;
&lt;li&gt;VoIP&lt;/li&gt;
&lt;li&gt;DNS queries (usually first attempt)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;In real-time systems, late data is useless.&lt;/p&gt;

&lt;p&gt;If a video frame arrives too late, there is no point replaying it.&lt;/p&gt;

&lt;p&gt;Mental model:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Better to get most of the data quickly than all of it too late.”&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h1&gt;
  
  
  Real-World Examples
&lt;/h1&gt;

&lt;h3&gt;
  
  
  TCP Examples
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Web browsing (HTTP/HTTPS)&lt;/li&gt;
&lt;li&gt;Email (SMTP, IMAP)&lt;/li&gt;
&lt;li&gt;File transfer (FTP, SFTP)&lt;/li&gt;
&lt;li&gt;REST APIs&lt;/li&gt;
&lt;li&gt;gRPC over HTTP&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  UDP Examples
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Video conferencing&lt;/li&gt;
&lt;li&gt;Online gaming&lt;/li&gt;
&lt;li&gt;Live sports streaming&lt;/li&gt;
&lt;li&gt;Voice calls&lt;/li&gt;
&lt;li&gt;DNS lookups&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  Where Does HTTP Fit In?
&lt;/h1&gt;

&lt;p&gt;Now comes the part where many people get confused.&lt;/p&gt;

&lt;h2&gt;
  
  
  HTTP Is NOT a Transport Protocol
&lt;/h2&gt;

&lt;p&gt;HTTP stands for &lt;strong&gt;HyperText Transfer Protocol&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;It is an &lt;strong&gt;application-layer protocol&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;It defines:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What a request looks like&lt;/li&gt;
&lt;li&gt;What a response looks like&lt;/li&gt;
&lt;li&gt;Methods like GET and POST&lt;/li&gt;
&lt;li&gt;Status codes like 200 OK&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;But it does NOT define how bytes move across the network.&lt;/p&gt;

&lt;p&gt;That’s TCP’s job.&lt;/p&gt;




&lt;h1&gt;
  
  
  How the Layers Stack
&lt;/h1&gt;

&lt;p&gt;Very simplified model:&lt;/p&gt;

&lt;p&gt;Application layer → HTTP, HTTPS, SMTP, DNS&lt;br&gt;
Transport layer → TCP, UDP&lt;br&gt;
Network layer → IP&lt;br&gt;
Link layer → Ethernet, Wi-Fi&lt;/p&gt;

&lt;p&gt;So when you load a webpage:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;TCP establishes a connection.&lt;/li&gt;
&lt;li&gt;TCP guarantees reliable delivery.&lt;/li&gt;
&lt;li&gt;HTTP sends:
&lt;code&gt;GET /page&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Server responds:
&lt;code&gt;200 OK + HTML&lt;/code&gt;
&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;HTTP speaks over a reliable TCP connection.&lt;/p&gt;




&lt;h1&gt;
  
  
  Simple Analogy
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;TCP = The phone line&lt;/li&gt;
&lt;li&gt;HTTP = The language you speak over that phone line&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;TCP ensures:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;No missing words&lt;/li&gt;
&lt;li&gt;Correct order&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;HTTP defines:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What you are saying&lt;/li&gt;
&lt;li&gt;What it means&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  Why HTTP Does Not Replace TCP
&lt;/h1&gt;

&lt;p&gt;HTTP depends on TCP.&lt;/p&gt;

&lt;p&gt;HTTP does not:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Retransmit lost packets&lt;/li&gt;
&lt;li&gt;Reorder packets&lt;/li&gt;
&lt;li&gt;Handle flow control&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;TCP already does that.&lt;/p&gt;

&lt;p&gt;If HTTP tried to replace TCP, it would need to reimplement reliability from scratch which makes no sense.&lt;/p&gt;

&lt;p&gt;So instead:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;TCP handles delivery&lt;/li&gt;
&lt;li&gt;HTTP handles meaning&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  Common Beginner Confusion
&lt;/h1&gt;

&lt;p&gt;“Is HTTP the same as TCP?”&lt;/p&gt;

&lt;p&gt;No.&lt;/p&gt;

&lt;p&gt;TCP:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Deals with connections and reliable transport&lt;/li&gt;
&lt;li&gt;Knows nothing about URLs or HTML&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;HTTP:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Deals with requests and responses&lt;/li&gt;
&lt;li&gt;Assumes a reliable stream is already provided&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Different layers. Different responsibilities.&lt;/p&gt;




&lt;h1&gt;
  
  
  One Important Note (Modern Twist)
&lt;/h1&gt;

&lt;p&gt;Traditional HTTP (HTTP/1.1 and HTTP/2) runs over TCP.&lt;/p&gt;

&lt;p&gt;But &lt;strong&gt;HTTP/3&lt;/strong&gt; runs over &lt;strong&gt;QUIC&lt;/strong&gt;, which itself runs over UDP.&lt;/p&gt;

&lt;p&gt;That’s a more advanced topic, but it shows how layers can evolve while keeping the same logical separation.&lt;/p&gt;




&lt;h1&gt;
  
  
  Final Summary
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;The internet needs rules to handle unreliable networks.&lt;/li&gt;
&lt;li&gt;TCP provides reliable, ordered communication.&lt;/li&gt;
&lt;li&gt;UDP provides fast, low-latency communication without guarantees.&lt;/li&gt;
&lt;li&gt;HTTP is an application protocol that runs on top of TCP (usually).&lt;/li&gt;
&lt;li&gt;TCP is the delivery system; HTTP is the language.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Once you clearly separate these layers in your mind, networking becomes much easier to understand.&lt;/p&gt;

&lt;p&gt;And honestly, this clarity helps a lot when you start learning:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;HTTPS&lt;/li&gt;
&lt;li&gt;APIs&lt;/li&gt;
&lt;li&gt;WebSockets&lt;/li&gt;
&lt;li&gt;HTTP/2 and HTTP/3&lt;/li&gt;
&lt;li&gt;Microservices&lt;/li&gt;
&lt;li&gt;System design&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Because almost everything on the internet builds on these foundations.&lt;/p&gt;

&lt;p&gt;Happy learning.......&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>computerscience</category>
      <category>networking</category>
      <category>webdev</category>
    </item>
    <item>
      <title>How DNS Resolution Works</title>
      <dc:creator>Rajat Yadav</dc:creator>
      <pubDate>Wed, 11 Feb 2026 13:38:51 +0000</pubDate>
      <link>https://dev.to/rajat_yadav_/how-dns-resolution-works-4bic</link>
      <guid>https://dev.to/rajat_yadav_/how-dns-resolution-works-4bic</guid>
      <description>&lt;p&gt;Every single time we use the internet, DNS is working for you even if you never realized it existed.&lt;/p&gt;

&lt;p&gt;When you type &lt;code&gt;google.com&lt;/code&gt; in your browser and hit Enter, our computer doesn’t magically know where Google live. In the background, a system has to answer one basic question:&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;“What IP address belongs to google.com?”&lt;/strong&gt;&lt;/p&gt;

&lt;p&gt;That system is &lt;strong&gt;DNS&lt;/strong&gt;, and &lt;code&gt;dig&lt;/code&gt; is a tool that helps us look inside this process instead of treating it like black magic.&lt;/p&gt;

&lt;p&gt;In this article, we’ll understand:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What DNS is and why name resolution is needed&lt;/li&gt;
&lt;li&gt;What the &lt;code&gt;dig&lt;/code&gt; command does and why engineers use it&lt;/li&gt;
&lt;li&gt;How DNS lookup happens step by step: root → TLD → authoritative&lt;/li&gt;
&lt;li&gt;How commands like &lt;code&gt;dig . NS&lt;/code&gt;, &lt;code&gt;dig com NS&lt;/code&gt;, &lt;code&gt;dig google.com NS&lt;/code&gt;, and &lt;code&gt;dig google.com&lt;/code&gt; all fit together&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;I’ll keep the language simple and practical.&lt;/p&gt;




&lt;h2&gt;
  
  
  1. What Is DNS? (The Internet’s Phonebook Idea)
&lt;/h2&gt;

&lt;h3&gt;
  
  
  1.1 Names vs numbers
&lt;/h3&gt;

&lt;p&gt;Humans are comfortable with names:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;google.com&lt;/li&gt;
&lt;li&gt;facebook.com&lt;/li&gt;
&lt;li&gt;myblog.dev&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Computers don’t work like that. They talk using numbers called &lt;strong&gt;IP addresses&lt;/strong&gt;, such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;code&gt;142.250.72.14&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;2404:6800:4004:81b::200e&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Now imagine trying to remember IP addresses for every website you use. That would be painful and honestly impossible.&lt;/p&gt;

&lt;p&gt;That’s why DNS exists.&lt;/p&gt;

&lt;p&gt;DNS (Domain Name System) is basically a &lt;strong&gt;distributed phonebook for the internet&lt;/strong&gt;.&lt;/p&gt;

&lt;p&gt;You ask:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“What is the IP for google.com?”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;DNS replies:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Here it is.”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;This process converting a domain name into an IP address is called &lt;strong&gt;name resolution&lt;/strong&gt;.&lt;/p&gt;




&lt;h3&gt;
  
  
  1.2 Why name resolution is important
&lt;/h3&gt;

&lt;p&gt;Name resolution exists for some very practical reasons:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Humans prefer names, not numbers&lt;/li&gt;
&lt;li&gt;Servers and IP addresses can change over time&lt;/li&gt;
&lt;li&gt;We want stable domain names even if infrastructure changes&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;DNS also enables some powerful features:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Load balancing&lt;/strong&gt; - one domain can point to multiple IPs&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;High availability&lt;/strong&gt; – traffic can move if a server goes down&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Geo routing&lt;/strong&gt; – users get routed to the nearest server&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So DNS isn’t just a lookup table. It’s an &lt;strong&gt;abstraction layer&lt;/strong&gt; that makes the internet flexible and scalable.&lt;/p&gt;




&lt;h2&gt;
  
  
  2. What Is &lt;code&gt;dig&lt;/code&gt; and Why Do People Use It?
&lt;/h2&gt;

&lt;p&gt;&lt;code&gt;dig&lt;/code&gt; stands for &lt;strong&gt;Domain Information Groper&lt;/strong&gt;. The name sounds funny, but the tool itself is serious.&lt;/p&gt;

&lt;h3&gt;
  
  
  2.1 What &lt;code&gt;dig&lt;/code&gt; actually does
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;dig&lt;/code&gt; is a command-line utility that lets you directly question DNS servers.&lt;/p&gt;

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

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dig google.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This command shows you:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;What question was asked&lt;/li&gt;
&lt;li&gt;What DNS server answered&lt;/li&gt;
&lt;li&gt;Which records came back&lt;/li&gt;
&lt;li&gt;Extra DNS details that browsers usually hide&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;With &lt;code&gt;dig&lt;/code&gt;, you can ask things like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;“What IP does this domain resolve to?”&lt;/li&gt;
&lt;li&gt;“Which name servers manage this TLD?”&lt;/li&gt;
&lt;li&gt;“Who is authoritative for this domain?”&lt;/li&gt;
&lt;/ul&gt;




&lt;h3&gt;
  
  
  2.2 When &lt;code&gt;dig&lt;/code&gt; is useful in real life
&lt;/h3&gt;

&lt;p&gt;You usually reach for &lt;code&gt;dig&lt;/code&gt; when:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A website isn’t loading and DNS might be the issue&lt;/li&gt;
&lt;li&gt;You updated DNS records and want to check propagation&lt;/li&gt;
&lt;li&gt;You’re learning networking or backend systems&lt;/li&gt;
&lt;li&gt;You’re working in DevOps, cloud, or infrastructure&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;If &lt;code&gt;curl&lt;/code&gt; is essential for HTTP debugging, &lt;code&gt;dig&lt;/code&gt; plays the same role for DNS.&lt;/p&gt;




&lt;h2&gt;
  
  
  3. DNS Is Hierarchical (This Part Is Very Important)
&lt;/h2&gt;

&lt;p&gt;DNS is not flat. It is organized in layers.&lt;/p&gt;

&lt;p&gt;Think of it like a tree structure:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Root (.)&lt;/strong&gt; – the top of everything&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;TLDs&lt;/strong&gt; – &lt;code&gt;.com&lt;/code&gt;, &lt;code&gt;.org&lt;/code&gt;, &lt;code&gt;.net&lt;/code&gt;, &lt;code&gt;.in&lt;/code&gt;, &lt;code&gt;.io&lt;/code&gt;, etc&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Domains&lt;/strong&gt; – google.com, example.com&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Subdomains&lt;/strong&gt; – &lt;a href="http://www.google.com" rel="noopener noreferrer"&gt;www.google.com&lt;/a&gt;, api.example.com&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Each layer knows &lt;em&gt;just enough&lt;/em&gt; and points you to the next one.&lt;/p&gt;

&lt;h3&gt;
  
  
  3.1 Who knows what?
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Root servers&lt;/strong&gt;&lt;br&gt;
Know which servers handle each TLD&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;TLD servers (.com, .org, etc.)&lt;/strong&gt;&lt;br&gt;
Know which servers handle domains under them&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Authoritative servers&lt;/strong&gt;&lt;br&gt;
Know the actual DNS records for a domain&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;Your &lt;strong&gt;recursive resolver&lt;/strong&gt; (ISP DNS, 8.8.8.8, 1.1.1.1, etc.) walks through these layers on your behalf.&lt;/p&gt;




&lt;h2&gt;
  
  
  4. &lt;code&gt;dig . NS&lt;/code&gt; – Starting at the Root
&lt;/h2&gt;

&lt;p&gt;Let’s begin from the very top.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dig &lt;span class="nb"&gt;.&lt;/span&gt; NS
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  4.1 What this command is asking
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;.&lt;/code&gt; means the root of DNS&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;NS&lt;/code&gt; asks for Name Server records&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So the question is:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Which name servers are responsible for the DNS root?”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  4.2 What you’ll see
&lt;/h3&gt;

&lt;p&gt;You’ll get results like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;a.root-servers.net&lt;/li&gt;
&lt;li&gt;b.root-servers.net&lt;/li&gt;
&lt;li&gt;…&lt;/li&gt;
&lt;li&gt;m.root-servers.net&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;There are &lt;strong&gt;13 logical root servers&lt;/strong&gt;, but each one is backed by many physical servers around the world.&lt;/p&gt;

&lt;h3&gt;
  
  
  4.3 Why root servers matter
&lt;/h3&gt;

&lt;p&gt;Root servers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Don’t know IPs for websites&lt;/li&gt;
&lt;li&gt;Don’t know google.com directly&lt;/li&gt;
&lt;li&gt;Only know who manages TLDs like &lt;code&gt;.com&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;They basically say:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“I don’t know the answer, but I know who to ask next.”&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  5. &lt;code&gt;dig com NS&lt;/code&gt; – The TLD Layer
&lt;/h2&gt;

&lt;p&gt;Now let’s move one level down.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dig com NS
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  5.1 What this means
&lt;/h3&gt;

&lt;p&gt;You’re asking:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“Which name servers are responsible for the &lt;code&gt;.com&lt;/code&gt; domain?”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  5.2 Typical output
&lt;/h3&gt;

&lt;p&gt;You’ll see servers like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;a.gtld-servers.net&lt;/li&gt;
&lt;li&gt;b.gtld-servers.net&lt;/li&gt;
&lt;li&gt;…&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These are &lt;strong&gt;TLD name servers for &lt;code&gt;.com&lt;/code&gt;&lt;/strong&gt;.&lt;/p&gt;

&lt;h3&gt;
  
  
  5.3 What TLD servers do
&lt;/h3&gt;

&lt;p&gt;TLD servers don’t store IP addresses for every website.&lt;/p&gt;

&lt;p&gt;Instead, they know:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Which servers are authoritative for &lt;code&gt;google.com&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Which servers are authoritative for &lt;code&gt;facebook.com&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So their answer is basically:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“I don’t know the IP, but these servers are allowed to answer for google.com.”&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h2&gt;
  
  
  6. &lt;code&gt;dig google.com NS&lt;/code&gt; – Authoritative Name Servers
&lt;/h2&gt;

&lt;p&gt;Now we reach the domain itself.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dig google.com NS
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  6.1 What this command asks
&lt;/h3&gt;

&lt;blockquote&gt;
&lt;p&gt;“Which name servers are authoritative for google.com?”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h3&gt;
  
  
  6.2 What you’ll see
&lt;/h3&gt;

&lt;p&gt;Usually something like:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;ns1.google.com&lt;/li&gt;
&lt;li&gt;ns2.google.com&lt;/li&gt;
&lt;li&gt;ns3.google.com&lt;/li&gt;
&lt;li&gt;ns4.google.com&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;These servers are controlled by Google and are the &lt;strong&gt;source of truth&lt;/strong&gt; for that domain.&lt;/p&gt;

&lt;h3&gt;
  
  
  6.3 Why authoritative servers are important
&lt;/h3&gt;

&lt;p&gt;Authoritative servers store real DNS records:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;A / AAAA → IP addresses&lt;/li&gt;
&lt;li&gt;MX → mail servers&lt;/li&gt;
&lt;li&gt;TXT → verification, SPF, etc&lt;/li&gt;
&lt;li&gt;CNAME → aliases&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;When asked:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“What is the IP for google.com?”&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;They can answer directly.&lt;/p&gt;

&lt;p&gt;From a system design view, this is where your domain configuration actually lives.&lt;/p&gt;




&lt;h2&gt;
  
  
  7. &lt;code&gt;dig google.com&lt;/code&gt; – The Complete DNS Lookup
&lt;/h2&gt;

&lt;p&gt;Now the most common command.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dig google.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h3&gt;
  
  
  7.1 What happens behind the scenes
&lt;/h3&gt;

&lt;p&gt;When you run this:&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Your recursive resolver checks cache&lt;/li&gt;
&lt;li&gt;If not found, it asks root servers&lt;/li&gt;
&lt;li&gt;Then it asks &lt;code&gt;.com&lt;/code&gt; TLD servers&lt;/li&gt;
&lt;li&gt;Then it asks google.com authoritative servers&lt;/li&gt;
&lt;li&gt;It returns the final IP&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;&lt;code&gt;dig&lt;/code&gt; then prints:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;QUESTION section&lt;/li&gt;
&lt;li&gt;ANSWER section&lt;/li&gt;
&lt;li&gt;Sometimes AUTHORITY and ADDITIONAL info&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  7.2 Why you don’t see all steps by default
&lt;/h3&gt;

&lt;p&gt;Normally, recursive resolvers hide this complexity.&lt;/p&gt;

&lt;p&gt;To force every step to be shown, you can use:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dig +trace google.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This displays the full root → TLD → authoritative journey.&lt;/p&gt;




&lt;h2&gt;
  
  
  8. How Recursive Resolvers Tie Everything Together
&lt;/h2&gt;

&lt;p&gt;Assume nothing is cached.&lt;/p&gt;

&lt;ol&gt;
&lt;li&gt;Browser needs google.com&lt;/li&gt;
&lt;li&gt;OS asks the recursive resolver&lt;/li&gt;
&lt;li&gt;Resolver asks root&lt;/li&gt;
&lt;li&gt;Root points to &lt;code&gt;.com&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;.com&lt;/code&gt; points to google.com NS&lt;/li&gt;
&lt;li&gt;Authoritative server gives IP&lt;/li&gt;
&lt;li&gt;Resolver caches it (TTL)&lt;/li&gt;
&lt;li&gt;Browser connects using TCP/TLS&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;DNS finishes &lt;strong&gt;before&lt;/strong&gt; HTTP even starts.&lt;/p&gt;




&lt;h2&gt;
  
  
  9. Why This Matters in Real Systems
&lt;/h2&gt;

&lt;p&gt;DNS directly affects:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Website performance&lt;/li&gt;
&lt;li&gt;Application availability&lt;/li&gt;
&lt;li&gt;CDN routing&lt;/li&gt;
&lt;li&gt;Multi-region architectures&lt;/li&gt;
&lt;li&gt;Failover strategies&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;A broken DNS setup can make a perfectly healthy server look “down”.&lt;/p&gt;

&lt;p&gt;Understanding DNS and &lt;code&gt;dig&lt;/code&gt; makes you better at:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Debugging&lt;/li&gt;
&lt;li&gt;Designing scalable systems&lt;/li&gt;
&lt;li&gt;Working with cloud and infra&lt;/li&gt;
&lt;/ul&gt;




&lt;h2&gt;
  
  
  10. Final Recap
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;DNS maps domain names to IP addresses&lt;/li&gt;
&lt;li&gt;Name resolution exists for usability and flexibility&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;dig&lt;/code&gt; helps inspect DNS behavior&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;DNS works in layers:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Root → &lt;code&gt;dig . NS&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;TLD → &lt;code&gt;dig com NS&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Authoritative → &lt;code&gt;dig google.com NS&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Final IP → &lt;code&gt;dig google.com&lt;/code&gt;
&lt;/li&gt;
&lt;/ul&gt;


&lt;/li&gt;

&lt;li&gt;&lt;p&gt;Recursive resolvers walk these layers for you&lt;/p&gt;&lt;/li&gt;

&lt;/ul&gt;

&lt;p&gt;To practice, try running:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;dig &lt;span class="nb"&gt;.&lt;/span&gt; NS
dig com NS
dig google.com NS
dig google.com
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Slowly, step by step.&lt;/p&gt;

&lt;p&gt;Once this clicks, DNS stops feeling confusing and starts feeling logical.&lt;/p&gt;

&lt;p&gt;Happy learning....&lt;/p&gt;

</description>
      <category>beginners</category>
      <category>cli</category>
      <category>networking</category>
      <category>tutorial</category>
    </item>
    <item>
      <title>Mastering Redux-Saga: The Missing Piece for Async Redux Flows</title>
      <dc:creator>Rajat Yadav</dc:creator>
      <pubDate>Thu, 02 Oct 2025 16:50:20 +0000</pubDate>
      <link>https://dev.to/rajat_yadav_/mastering-redux-saga-the-missing-piece-for-async-redux-flows-m08</link>
      <guid>https://dev.to/rajat_yadav_/mastering-redux-saga-the-missing-piece-for-async-redux-flows-m08</guid>
      <description>&lt;blockquote&gt;
&lt;p&gt;Subtitle: Learn how Redux-Saga simplifies complex async logic, why it's better than Thunk for certain use cases, and how to use its powerful effects.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;h1&gt;
  
  
  Introduction
&lt;/h1&gt;

&lt;p&gt;If you've worked with Redux, you already know its biggest strength: &lt;strong&gt;predictability&lt;/strong&gt;. But as soon as you try to handle asynchronous logic like API calls, retries, or debounced search it can get messy.&lt;/p&gt;

&lt;p&gt;The default recommendation is &lt;strong&gt;Redux Thunk&lt;/strong&gt;, which lets you write async code inside action creators. That works fine for small projects, but as your app grows, you’ll find yourself tangled in a web of callback-like async flows that are hard to test, cancel, or control.&lt;/p&gt;

&lt;p&gt;This is where &lt;strong&gt;Redux-Saga&lt;/strong&gt; really shines. I recently worked with it and found it both powerful and straightforward to apply. Redux-Saga acts like a background worker or &lt;em&gt;“smart assistant”&lt;/em&gt; it listens for specific actions, executes side effects such as API calls, and then dispatches new actions accordingly. By leveraging JavaScript’s generator functions, it enables writing asynchronous code in a way that feels synchronous, making complex workflows much easier to manage.&lt;/p&gt;

&lt;p&gt;Let’s dive in.&lt;/p&gt;




&lt;h1&gt;
  
  
  What is Redux-Saga?
&lt;/h1&gt;

&lt;p&gt;Redux-Saga is a middleware library for Redux that manages &lt;strong&gt;side effects&lt;/strong&gt;, such as:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;API requests&lt;/li&gt;
&lt;li&gt;Delays, throttling, and debouncing&lt;/li&gt;
&lt;li&gt;Background tasks (polling, websockets, syncing)&lt;/li&gt;
&lt;li&gt;Complex async flows (cancellation, retries, races)&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;It uses generator functions (&lt;code&gt;function*&lt;/code&gt;) to make async flows look synchronous and testable.&lt;/p&gt;

&lt;p&gt;Install it with:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight shell"&gt;&lt;code&gt;npm &lt;span class="nb"&gt;install &lt;/span&gt;redux-saga
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;At its core, a saga is just a generator function that listens for actions and performs work:&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="kd"&gt;function&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nf"&gt;fetchUserSaga&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;action&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;data&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;yield&lt;/span&gt; &lt;span class="nf"&gt;call&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;api&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;fetchUser&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;action&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;payload&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;yield&lt;/span&gt; &lt;span class="nf"&gt;put&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;type&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_USER_SUCCESS&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;payload&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;data&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;h1&gt;
  
  
  Why Use Redux-Saga?
&lt;/h1&gt;

&lt;p&gt;Redux itself only handles synchronous state changes. If you want to:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Fetch data from an API&lt;/li&gt;
&lt;li&gt;Cancel an ongoing request&lt;/li&gt;
&lt;li&gt;Retry on failure&lt;/li&gt;
&lt;li&gt;Debounce a search input&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;…you need middleware.&lt;/p&gt;

&lt;p&gt;👉 &lt;strong&gt;Thunk&lt;/strong&gt; works for simple cases.&lt;br&gt;
👉 &lt;strong&gt;Saga&lt;/strong&gt; provides first-class helpers for cancellation, retries, and concurrency.&lt;/p&gt;

&lt;p&gt;In short:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;Thunk&lt;/strong&gt; = good enough for small apps&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Saga&lt;/strong&gt; = robust, testable async layer for large apps&lt;/li&gt;
&lt;/ul&gt;


&lt;h1&gt;
  
  
  How Redux-Saga Works (Big Picture)
&lt;/h1&gt;

&lt;ol&gt;
&lt;li&gt;Component dispatches an action → &lt;code&gt;{ type: "FETCH_USER_REQUEST", payload: 42 }&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Saga watches for that action using helpers like &lt;code&gt;takeEvery&lt;/code&gt; or &lt;code&gt;takeLatest&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Saga runs async logic (API call, debounce, retry)&lt;/li&gt;
&lt;li&gt;Saga dispatches another action → &lt;code&gt;{ type: "FETCH_USER_SUCCESS", payload: data }&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;Reducer updates state&lt;/li&gt;
&lt;/ol&gt;

&lt;p&gt;Think of Saga as the &lt;strong&gt;async middleman&lt;/strong&gt; between your actions and reducers.&lt;/p&gt;


&lt;h1&gt;
  
  
  Generator Functions in Sagas
&lt;/h1&gt;

&lt;p&gt;A saga is always a generator 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="kd"&gt;function&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nf"&gt;mySaga&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="s2"&gt;Saga started&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;);&lt;/span&gt;
  &lt;span class="k"&gt;yield&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;hello&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt; &lt;span class="c1"&gt;// pause here until middleware resumes&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="s2"&gt;Saga ended&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;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Key point: when you &lt;code&gt;yield&lt;/code&gt;, you’re not executing the effect directly. Instead, you return an &lt;strong&gt;effect object&lt;/strong&gt; that Redux-Saga interprets.&lt;/p&gt;

&lt;p&gt;Example:&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;yield&lt;/span&gt; &lt;span class="nf"&gt;put&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="s2"&gt;USER_FETCH_SUCCESS&lt;/span&gt;&lt;span class="dl"&gt;"&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;payload&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;data&lt;/span&gt; &lt;span class="p"&gt;});&lt;/span&gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;This doesn’t immediately dispatch the action it tells Redux-Saga:&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;“When you resume me, dispatch this action.”&lt;/p&gt;
&lt;/blockquote&gt;




&lt;h1&gt;
  
  
  Core Saga Effects
&lt;/h1&gt;

&lt;h3&gt;
  
  
  1. Core Side-Effect Creators
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;call(fn, ...args)&lt;/code&gt; → Call a function and wait for the result&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;put(action)&lt;/code&gt; → Dispatch an action&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;select(selector)&lt;/code&gt; → Read from the Redux store&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;delay(ms)&lt;/code&gt; → Pause for a duration&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  2. Listening / Watching for Actions
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;take(pattern)&lt;/code&gt; → Wait for a specific action&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;takeEvery(pattern, saga)&lt;/code&gt; → Run saga for every action&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;takeLatest(pattern, saga)&lt;/code&gt; → Cancel previous, run latest&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;throttle(ms, pattern, saga)&lt;/code&gt; → Run saga at most once per interval&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;debounce(ms, pattern, saga)&lt;/code&gt; → Run saga only after inactivity&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  3. Concurrency &amp;amp; Task Control
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;code&gt;all([...effects])&lt;/code&gt; → Run multiple effects in parallel&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;race({...effects})&lt;/code&gt; → Compete between tasks&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;fork(saga)&lt;/code&gt; → Run saga in background, non-blocking&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;cancel(task)&lt;/code&gt; → Cancel a forked saga&lt;/li&gt;
&lt;li&gt;
&lt;code&gt;retry(count, delayMs, fn, ...args)&lt;/code&gt; → Retry with backoff&lt;/li&gt;
&lt;/ul&gt;




&lt;h1&gt;
  
  
  Real-World Example: Search with Debounce + Cancellation
&lt;/h1&gt;

&lt;p&gt;Let’s say you’re building a search bar that should:&lt;br&gt;
✅ Wait until the user stops typing (debounce)&lt;br&gt;
✅ Cancel any previous requests if the user types again (cancellation)&lt;/p&gt;

&lt;p&gt;With Redux-Saga, this is straightforward:&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="p"&gt;{&lt;/span&gt; &lt;span class="nx"&gt;call&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;put&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;debounce&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;redux-saga/effects&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;;&lt;/span&gt;

&lt;span class="c1"&gt;// worker saga&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nf"&gt;searchSaga&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;action&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&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;yield&lt;/span&gt; &lt;span class="nf"&gt;call&lt;/span&gt;&lt;span class="p"&gt;(&lt;/span&gt;&lt;span class="nx"&gt;fetch&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="s2"&gt;`/api/search?q=&lt;/span&gt;&lt;span class="p"&gt;${&lt;/span&gt;&lt;span class="nx"&gt;action&lt;/span&gt;&lt;span class="p"&gt;.&lt;/span&gt;&lt;span class="nx"&gt;payload&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;results&lt;/span&gt; &lt;span class="o"&gt;=&lt;/span&gt; &lt;span class="k"&gt;yield&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;json&lt;/span&gt;&lt;span class="p"&gt;();&lt;/span&gt;
    &lt;span class="k"&gt;yield&lt;/span&gt; &lt;span class="nf"&gt;put&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;SEARCH_SUCCESS&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;payload&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="nx"&gt;results&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;error&lt;/span&gt;&lt;span class="p"&gt;)&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
    &lt;span class="k"&gt;yield&lt;/span&gt; &lt;span class="nf"&gt;put&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;SEARCH_FAILURE&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;error&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;// watcher saga with debounce&lt;/span&gt;
&lt;span class="kd"&gt;function&lt;/span&gt;&lt;span class="o"&gt;*&lt;/span&gt; &lt;span class="nf"&gt;watchSearch&lt;/span&gt;&lt;span class="p"&gt;()&lt;/span&gt; &lt;span class="p"&gt;{&lt;/span&gt;
  &lt;span class="k"&gt;yield&lt;/span&gt; &lt;span class="nf"&gt;debounce&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="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;SEARCH_QUERY&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="nx"&gt;searchSaga&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;Usage in a component:&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="nf"&gt;dispatch&lt;/span&gt;&lt;span class="p"&gt;({&lt;/span&gt; &lt;span class="na"&gt;type&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;SEARCH_QUERY&lt;/span&gt;&lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="p"&gt;,&lt;/span&gt; &lt;span class="na"&gt;payload&lt;/span&gt;&lt;span class="p"&gt;:&lt;/span&gt; &lt;span class="dl"&gt;'&lt;/span&gt;&lt;span class="s1"&gt;redux saga&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;p&gt;What happens:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;If the user types “redux” quickly, previous requests are cancelled.&lt;/li&gt;
&lt;li&gt;Only after &lt;strong&gt;500ms of no typing&lt;/strong&gt;, &lt;code&gt;searchSaga&lt;/code&gt; executes.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;👉 Clean, declarative, and testable.&lt;/p&gt;

&lt;p&gt;This kind of flow is &lt;strong&gt;painful with Thunk&lt;/strong&gt; but &lt;strong&gt;trivial with Saga&lt;/strong&gt;.&lt;/p&gt;




&lt;h1&gt;
  
  
  Saga vs Reducer: Who Does What?
&lt;/h1&gt;

&lt;p&gt;Think of Redux like a factory:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;
&lt;strong&gt;State / Slice&lt;/strong&gt; = The storage room (where data lives)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Reducer&lt;/strong&gt; = Workers who update inventory (pure synchronous updates)&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Action&lt;/strong&gt; = Instruction notes sent to workers&lt;/li&gt;
&lt;li&gt;
&lt;strong&gt;Saga&lt;/strong&gt; = Special robots that handle complicated async tasks before sending new instructions&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;So:&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Reducers → change state&lt;/li&gt;
&lt;li&gt;Sagas → perform async work, then ask reducers to update state&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;They don’t replace each other they complement each other.&lt;/p&gt;




&lt;h1&gt;
  
  
  Redux Thunk vs Redux-Saga
&lt;/h1&gt;

&lt;div class="table-wrapper-paragraph"&gt;&lt;table&gt;
&lt;thead&gt;
&lt;tr&gt;
&lt;th&gt;Feature&lt;/th&gt;
&lt;th&gt;Redux Thunk&lt;/th&gt;
&lt;th&gt;Redux-Saga&lt;/th&gt;
&lt;/tr&gt;
&lt;/thead&gt;
&lt;tbody&gt;
&lt;tr&gt;
&lt;td&gt;API Calls&lt;/td&gt;
&lt;td&gt;✅ Simple&lt;/td&gt;
&lt;td&gt;✅ Powerful&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Cancellation&lt;/td&gt;
&lt;td&gt;❌ Hard&lt;/td&gt;
&lt;td&gt;✅ Built-in&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Retry/Backoff&lt;/td&gt;
&lt;td&gt;❌ Manual&lt;/td&gt;
&lt;td&gt;✅ Built-in&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Debounce/Throttle&lt;/td&gt;
&lt;td&gt;❌ Manual&lt;/td&gt;
&lt;td&gt;✅ Built-in&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Testing&lt;/td&gt;
&lt;td&gt;Medium&lt;/td&gt;
&lt;td&gt;Easy&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;Best For&lt;/td&gt;
&lt;td&gt;Small apps&lt;/td&gt;
&lt;td&gt;Large/complex apps&lt;/td&gt;
&lt;/tr&gt;
&lt;/tbody&gt;
&lt;/table&gt;&lt;/div&gt;




&lt;h1&gt;
  
  
  Key Takeaways
&lt;/h1&gt;

&lt;ul&gt;
&lt;li&gt;Redux-Saga is a middleware that makes async Redux flows &lt;strong&gt;declarative, testable, and powerful&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;It uses &lt;strong&gt;generator functions and effects&lt;/strong&gt; (&lt;code&gt;call&lt;/code&gt;, &lt;code&gt;put&lt;/code&gt;, &lt;code&gt;takeEvery&lt;/code&gt;, etc.) to manage side effects.&lt;/li&gt;
&lt;li&gt;It handles &lt;strong&gt;cancellation, retry, debounce, and concurrency&lt;/strong&gt; out of the box—things that are painful with Thunk.&lt;/li&gt;
&lt;li&gt;It doesn’t replace reducers it complements them as the async layer.&lt;/li&gt;
&lt;/ul&gt;

&lt;p&gt;👉 For apps with &lt;strong&gt;complex async needs&lt;/strong&gt;, Saga is a better long-term investment.&lt;/p&gt;

&lt;p&gt;Once you get comfortable with generators, Redux-Saga feels like giving Redux a &lt;strong&gt;brain that thinks asynchronously&lt;/strong&gt;.&lt;/p&gt;




</description>
      <category>redux</category>
      <category>reduxsaga</category>
      <category>webdev</category>
    </item>
    <item>
      <title>🛠️ pdf-parse ENOENT Error Explained: Fixing the “05-versions-space.pdf” Crash in Node.js</title>
      <dc:creator>Rajat Yadav</dc:creator>
      <pubDate>Wed, 04 Jun 2025 10:13:58 +0000</pubDate>
      <link>https://dev.to/rajat_yadav_/pdf-parse-enoent-error-explained-fixing-the-05-versions-spacepdf-crash-in-nodejs-5ce3</link>
      <guid>https://dev.to/rajat_yadav_/pdf-parse-enoent-error-explained-fixing-the-05-versions-spacepdf-crash-in-nodejs-5ce3</guid>
      <description>&lt;p&gt;TL;DR: If you're seeing ENOENT related to 05-versions-space.pdf while using pdf-parse in Node.js - it's not your fault. It's hidden debug logic inside the library. Here's the fix.&lt;/p&gt;




&lt;p&gt;🧩 The Problem: A Mysterious Crash&lt;br&gt;
I was building a pdf parsing backend in Node.js. Everything was working until I added pdf-parse to extract text from uploaded PDFs.&lt;br&gt;
My code was clean:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;import fs from "fs/promises";
import pdfParser from "pdf-parse";
const buffer = await fs.readFile("uploads/file.pdf");
const data = await pdfParser(buffer);
console.log(data.text);
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;Then suddenly… boom:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;Error: ENOENT: no such file or directory, open 'C:\\...\\test\\data\\05-versions-space.pdf'
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;What file? What path? I never wrote that!&lt;/p&gt;




&lt;p&gt;🤯 The Real Culprit&lt;br&gt;
The problem isn't your code - it's debug logic inside pdf-parse itself.&lt;br&gt;
If you peek inside node_modules/pdf-parse/index.js, you'll find this block:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let isDebugMode = !module.parent;
if (isDebugMode) {
  const filePath = path.join(__dirname, "test/data/05-versions-space.pdf");
  const dataBuffer = fs.readFileSync(filePath);
  ...
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;🟥 If this runs, and the file doesn't exist (and it won't), the app crashes.&lt;/p&gt;




&lt;p&gt;✅ The Fixes&lt;br&gt;
🔧 Option 1: Create the Missing File&lt;br&gt;
Quickest workaround:&lt;br&gt;
1- Create this folder:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;mkdir -p node_modules/pdf-parse/test/data
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;2- Add any valid PDF file to it and name it:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;05-versions-space.pdf
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;✅ Done. Your app won't crash anymore.&lt;/p&gt;




&lt;p&gt;🛡️ Option 2: Permanently Disable Debug Mode (Recommended)&lt;br&gt;
You can patch the module to prevent future issues:&lt;br&gt;
1- Install patch-package:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npm install patch-package
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;2- Edit node_modules/pdf-parse/index.js:&lt;br&gt;
 Change this line:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let isDebugMode = !module.parent;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;To:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;let isDebugMode = false;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;3- Save the file and run:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;npx patch-package pdf-parse
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;4- Add this to your package.json scripts to ensure the patch survives reinstalls:&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;"scripts": {
  "postinstall": "patch-package"
}
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;






&lt;p&gt;💡 Lessons Learned&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;Not all bugs are in your code.&lt;/li&gt;
&lt;li&gt;Always check a library's index.js if you're getting unexpected behavior.&lt;/li&gt;
&lt;li&gt;Defensive code matters. Production libraries should avoid running debug logic by default.&lt;/li&gt;
&lt;/ul&gt;




&lt;p&gt;🧠 Final Thoughts&lt;br&gt;
If you're building a backend using pdf-parse, make sure you:&lt;br&gt;
❌ Disable the debug mode&lt;br&gt;
📁 Handle file paths using path.resolve() to avoid OS path issues&lt;br&gt;
🛡️ Always wrap file reads in try/catch&lt;/p&gt;

&lt;p&gt;Like this post? Bookmark it or share with your dev group - because these "WTF" bugs deserve visibility.&lt;/p&gt;

&lt;p&gt;Have you faced a similar issue with another library? Drop a comment, and let's debug together.&lt;/p&gt;

</description>
      <category>node</category>
      <category>javascript</category>
      <category>backend</category>
      <category>pdfparser</category>
    </item>
  </channel>
</rss>
