<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Umut Yusuf Çınar  on Medium]]></title>
        <description><![CDATA[Stories by Umut Yusuf Çınar  on Medium]]></description>
        <link>https://medium.com/@umut.yusuf.cinar?source=rss-161c03d77043------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*bUrAZRL4BIGmXgfPO0Z7bg.jpeg</url>
            <title>Stories by Umut Yusuf Çınar  on Medium</title>
            <link>https://medium.com/@umut.yusuf.cinar?source=rss-161c03d77043------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Tue, 24 Nov 2026 19:04:17 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@umut.yusuf.cinar/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[C#’ta Value Type ve Reference Type Kavramlarının Boxing ve Unboxing ile İncelenmesi]]></title>
            <link>https://medium.com/@umut.yusuf.cinar/c-ta-value-type-ve-reference-type-kavramlar%C4%B1n%C4%B1n-boxing-ve-unboxing-ile-i%CC%87ncelenmesi-2e5a9d6bd340?source=rss-161c03d77043------2</link>
            <guid isPermaLink="false">https://medium.com/p/2e5a9d6bd340</guid>
            <category><![CDATA[c-sharp-programming]]></category>
            <category><![CDATA[reference-type]]></category>
            <category><![CDATA[value-type]]></category>
            <category><![CDATA[reference-and-value-types]]></category>
            <dc:creator><![CDATA[Umut Yusuf Çınar ]]></dc:creator>
            <pubDate>Wed, 04 Feb 2026 14:51:12 GMT</pubDate>
            <atom:updated>2026-02-04T14:51:12.714Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/480/1*0oehArCCeluiam-_LwP6Hg.jpeg" /></figure><p>C# öğrenirken çoğu geliştiricinin karşısına bir noktada şu sorular çıkar:</p><ul><li>“Neden bir metot içinde değiştirdiğim değer dışarı yansımadı?”</li><li>“İki değişken aynı nesneyi mi tutuyor?”</li><li>“Bu kod neden beklediğimden daha yavaş çalışıyor?”</li></ul><p>Bu soruların cevabı çoğunlukla <strong>C#’taki yerleşik veri türlerinin value type (değer tip) ve reference type (referans tip) olarak ayrılması</strong> ve bunun doğal sonucu olan <strong>boxing (kutulama) / unboxing (kutudan çıkarma) </strong>kavramlarında yatıyor.</p><p>Bu yazıda bu konuları temelden ve kafa karıştırmadan ele alacağız.</p><h3>Value Type (Değer Tip) Nedir?</h3><p><strong>Value type</strong>, adından da anlaşılacağı gibi <strong>değerin kendisini</strong> tutar.<br> Bir value type değişkenini başka bir değişkene atadığınızda, <strong>değer kopyalanır</strong>.</p><p>C#’ta bazı yaygın value type’lar:</p><ul><li>int</li><li>double</li><li>bool</li><li>char</li><li>struct</li><li>enums</li></ul><p>Basit bir örnekle başlayalım:</p><pre>int a = 10;<br>int b = a;<br>b = 20;<br>Console.WriteLine(a); // 10<br>Console.WriteLine(b); // 20</pre><p>Burada:</p><ul><li>a ve b <strong>iki ayrı değere</strong> sahiptir</li><li>b değiştiğinde a etkilenmez</li></ul><p>Çünkü value type’lar <strong>kopyalanarak</strong> aktarılır.</p><p><em>Kısaca: </em><strong><em>Value type = Değer kopyalanır</em></strong></p><h3>Reference Type (Referans Tip) Nedir?</h3><p><strong>Reference type</strong>’lar ise değerin kendisini değil, <strong>o değerin bulunduğu adresi (referansı)</strong> tutar.</p><p>Yaygın reference type’lar:</p><ul><li>class</li><li>array</li><li>object</li><li>string</li><li>interface</li></ul><p>Bir örnek görelim:</p><pre>var list1 = new List&lt;int&gt; { 1, 2, 3 };<br>var list2 = list1;<br>list2.Add(4);<br>Console.WriteLine(list1.Count); // 4</pre><p>Burada olan şey şu:</p><ul><li>list1 ve list2 <strong>aynı nesneyi</strong> işaret eder</li><li>Nesne tek, referanslar iki tanedir</li><li>Birinden yapılan değişiklik diğerini de etkiler</li></ul><p><em>Kısaca: </em><strong><em>Reference type = Aynı nesne paylaşılır</em></strong></p><h3>Stack ve Heap (Yazı bünyesinde kısa ve temel açıklama)</h3><p>Bu konudan bahsetmeden geçmek zor ama abartmaya da gerek yok.</p><ul><li><strong>Value type</strong>’lar genellikle <strong>stack</strong>’te tutulur</li><li><strong>Reference type</strong> nesnelerin kendisi <strong>heap</strong>’te, referansları stack’te tutulur</li></ul><p>Asıl önemli olan şudur:</p><p><em>Value type → kopyalanır</em></p><p><em>Reference type → paylaşılır</em></p><p>Gerisini bu bilgiyle zaten doğru yorumlarsın.</p><h3>string Neden Özel Bir Durum?</h3><p>string, teknik olarak bir <strong>reference type</strong>’tır.<br> Ama aynı zamanda <strong>immutable</strong>’dır (değiştirilemez).</p><p>Örnek:</p><pre>string name = &quot;Ahmet&quot;;<br>name = &quot;Mehmet&quot;;</pre><p>Burada:</p><ul><li>&quot;Ahmet&quot; değişmez</li><li>&quot;Mehmet&quot; için <strong>yeni bir string nesnesi</strong> oluşturulur</li><li>name artık yeni nesneyi işaret eder</li></ul><p>Bu yüzden string davranış olarak <strong>value type gibi hissedilir</strong>, ama aslında <strong>reference type’tır</strong>.</p><h3>Boxing Nedir?</h3><p><strong>Boxing</strong>, bir <strong>value type</strong>’ın object veya bir interface türüne dönüştürülmesidir.</p><pre>int number = 42;<br>object boxedNumber = number; // Boxing</pre><p>Bu satırda olanlar:</p><ol><li>number değeri alınır</li><li>Heap’te yeni bir nesne oluşturulur</li><li>Değer bu nesnenin içine kopyalanır</li></ol><p>Yani boxing:</p><ul><li>Ek bellek kullanır</li><li>Performans maliyeti oluşturur</li></ul><h3>Unboxing Nedir?</h3><p><strong>Unboxing</strong>, daha önce boxing yapılmış bir değerin tekrar value type’a çevrilmesidir.</p><pre>object boxedNumber = 42;<br>int number = (int)boxedNumber; // Unboxing</pre><p>Önemli noktalar:</p><ul><li>Unboxing <strong>cast (dönüşüm) gerektirir</strong></li><li>Boxing olmadan unboxing <strong>olamaz</strong></li></ul><p><em>Akılda kalıcı cümle: </em><strong><em>Her unboxing’in arkasında bir boxing vardır.</em></strong></p><h3>Boxing &amp; Unboxing Neden Tehlikelidir?</h3><p>Özellikle şu durumlarda problem çıkar:</p><ul><li>Döngülerin içinde fark edilmeden yapılırsa</li><li>Eski koleksiyon yapıları (ArrayList gibi) kullanılırsa</li><li>Performans kritik kodlarda</li></ul><p>Bu yüzden:</p><ul><li>Generic koleksiyonlar (List&lt;T&gt;, Dictionary&lt;TKey, TValue&gt;)<br> boxing ihtiyacını ortadan kaldırır</li><li>Modern C# kodunda boxing genellikle <strong>istenmeyen</strong> bir durumdur</li></ul><h3>Özetle Ne Öğrenmeliyiz?</h3><ul><li>Value type’lar <strong>kopyalanır</strong></li><li>Reference type’lar <strong>paylaşılır</strong></li><li>string<strong> reference type olsa da immutable’dır</strong></li><li>Boxing &amp; unboxing gizli performans problemlerine yol açabilir</li><li>Generic yapılar bu sorunları büyük ölçüde çözer</li></ul><p>C#’ta sağlam ve öngörülebilir kod yazmanın yolu, bu temel farkları gerçekten anlamaktan geçiyor.</p><p><strong>Eğer bu konular kafanı karıştırıyorsa, yalnız değilsin.</strong> Ama bir kez netleştiğinde, hem bug’ların azalır hem de yazdığın kodun <strong>neden</strong> böyle davrandığını gerçekten anlarsın.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=2e5a9d6bd340" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CSS ID and Class Selectors]]></title>
            <link>https://medium.com/@umut.yusuf.cinar/css-id-and-class-selectors-7ec3dad9b60d?source=rss-161c03d77043------2</link>
            <guid isPermaLink="false">https://medium.com/p/7ec3dad9b60d</guid>
            <category><![CDATA[css]]></category>
            <dc:creator><![CDATA[Umut Yusuf Çınar ]]></dc:creator>
            <pubDate>Mon, 26 Jan 2026 15:09:27 GMT</pubDate>
            <atom:updated>2026-01-26T15:09:27.966Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/736/1*f2Lb4tL_5b-u4aFYEvX2Pg.jpeg" /></figure><p>When writing CSS, we use <strong>selectors</strong> to decide <strong>which HTML elements</strong> should be styled.<br> Among all selectors, the two most commonly used ones are <strong>ID selectors</strong> and <strong>Class selectors</strong>.</p><p>At first glance, they may look similar, but their <strong>purpose and impact are very different</strong>.<br> In this article, we’ll explain ID and Class selectors with <strong>clear and practical examples.</strong></p><h3>What Is a Selector?</h3><p>A selector tells CSS <strong>which elements</strong> the style rules should apply to.</p><p>Example:</p><pre>p {<br>  color: red;<br>}</pre><p>Here, p is a selector that targets all &lt;p&gt; elements.</p><h3>What Is an ID Selector?</h3><p>An ID selector is used to target <strong>a single, unique HTML element</strong>.</p><p>In HTML:</p><ul><li>An id value should be <strong>unique within the page</strong></li><li>The same id must not be used more than once</li></ul><h3>Using an ID Selector</h3><p><strong>HTML:</strong></p><pre>&lt;h1 id=&quot;title&quot;&gt;Hello&lt;/h1&gt;</pre><p><strong>CSS:</strong></p><pre>#title {<br>  color: blue;<br>}</pre><p>In this example:</p><ul><li>#title is an ID selector</li><li>Only the element with id=&quot;title&quot; is affected</li></ul><h3>When Should You Use an ID Selector?</h3><ul><li>For elements that appear <strong>only once</strong> on the page</li><li>For structural elements like headers or main titles</li><li>When an element needs to be accessed directly via JavaScript</li></ul><h3>Disadvantages of ID Selectors ❌</h3><ul><li>Cannot be reused</li><li>Have high CSS specificity</li><li>Reduce flexibility in large projects</li></ul><h3>What Is a Class Selector?</h3><p>A Class selector is used to apply styles to <strong>multiple HTML elements</strong>.</p><p>In HTML:</p><ul><li>The same class can be used on <strong>multiple elements</strong></li><li>An element can have <strong>multiple classes</strong></li></ul><h3>Using a Class Selector</h3><p><strong>HTML:</strong></p><pre>&lt;p class=&quot;text&quot;&gt;Paragraph 1&lt;/p&gt;<br>&lt;p class=&quot;text&quot;&gt;Paragraph 2&lt;/p&gt;</pre><p><strong>CSS:</strong></p><pre>.text {<br>  color: green;<br>}</pre><p>Here:</p><ul><li>.text is a class selector</li><li>All elements with the text class are affected</li></ul><h3>Using Multiple Classes on One Element</h3><pre>&lt;button class=&quot;btn primary&quot;&gt;Save&lt;/button&gt;</pre><p>This makes your CSS:</p><ul><li>More modular</li><li>Easier to maintain</li><li>Less repetitive</li></ul><h3>An Important Note About CSS Specificity ⚠️</h3><p>ID selectors are <strong>stronger</strong> than class selectors.</p><pre>#title {<br>  color: red;<br>}</pre><pre>.title {<br>  color: blue;<br>}</pre><p>If an element has both id=&quot;title&quot; and class=&quot;title&quot;:<br> <strong>Red</strong> will be applied.</p><p><strong>Because of this: <em>It’s a good practice to keep ID selectors out of your CSS as much as possible.</em></strong></p><h3>Which One Should You Use?</h3><ul><li><strong>Class selectors</strong> → ✅ default choice for styling</li><li><strong>ID selectors</strong> → special and limited cases</li></ul><p>A golden rule for junior developers: <strong><em>Use class for styling, id for identification.</em></strong></p><h3>Quick Summary</h3><ul><li>ID → unique and powerful</li><li>Class → flexible and reusable</li><li>In large projects, <strong>class selectors</strong> scale much better</li></ul><h3>Final Thoughts</h3><p>Using ID and Class selectors correctly is not just about writing CSS — <br> it’s about building <strong>clean, scalable, and maintainable frontend code</strong>.</p><p>Developing this habit early will save you from many problems later on.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7ec3dad9b60d" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Inline, Internal, and External CSS Explained for Beginners]]></title>
            <link>https://medium.com/@umut.yusuf.cinar/inline-internal-and-external-css-explained-for-beginners-55ee10123789?source=rss-161c03d77043------2</link>
            <guid isPermaLink="false">https://medium.com/p/55ee10123789</guid>
            <dc:creator><![CDATA[Umut Yusuf Çınar ]]></dc:creator>
            <pubDate>Tue, 20 Jan 2026 21:50:48 GMT</pubDate>
            <atom:updated>2026-01-20T21:50:48.297Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/736/1*f2Lb4tL_5b-u4aFYEvX2Pg.jpeg" /></figure><p>One of the first questions every beginner frontend developer faces is:<br> <strong>How should I add CSS to my project?</strong></p><p>There are three main ways to apply CSS to HTML:</p><ul><li>Inline CSS</li><li>Internal CSS</li><li>External CSS</li></ul><p>In this article, we’ll look at <strong>what each method is</strong>, <strong>how it works</strong>, and <strong>when it should be used</strong>.</p><h3>What Is Inline CSS?</h3><p>Inline CSS means writing CSS rules <strong>directly inside an HTML element</strong>, using the style attribute.</p><h3>Example</h3><pre>&lt;p style=&quot;color: red; font-size: 16px;&quot;&gt;<br>  Hello World<br>&lt;/p&gt;</pre><p>In this case:</p><ul><li>The CSS applies <strong>only to that element</strong></li><li>The style is tightly coupled with the HTML</li></ul><h3>When Should You Use Inline CSS?</h3><ul><li>For quick testing</li><li>For very small, one-time style changes</li><li>In email templates (often required)</li></ul><h3>Disadvantages of Inline CSS ❌</h3><ul><li>Reduces code readability</li><li>Causes repeated CSS rules</li><li>Hard to maintain in large projects</li><li>Breaks separation of concerns</li></ul><h3>What Is Internal CSS?</h3><p>Internal CSS is written inside a &lt;style&gt; tag within the &lt;head&gt; section of an HTML document.</p><pre>&lt;head&gt;<br>  &lt;style&gt;<br>    p {<br>      color: blue;<br>      font-size: 16px;<br>    }<br>  &lt;/style&gt;<br>&lt;/head&gt;</pre><p>This CSS → Applies only to <strong>that specific HTML page</strong>.</p><h3>When Should You Use Internal CSS?</h3><ul><li>Small, single-page projects</li><li>Demos or practice examples</li><li>When you don’t want to create a separate CSS file</li></ul><h3>Disadvantages of Internal CSS ❌</h3><ul><li>Styles must be repeated for multiple pages</li><li>Becomes difficult to manage as the project grows</li><li>Makes HTML files longer and harder to read</li></ul><h3>What Is External CSS?</h3><p>External CSS means writing all CSS rules in a <strong>separate </strong><strong>.css file</strong> and linking it to the HTML file.</p><p><strong>HTML file:</strong></p><pre>&lt;link rel=&quot;stylesheet&quot; href=&quot;styles.css&quot;&gt;</pre><p><strong>styles.css:</strong></p><pre>p {<br>  color: green;<br>  font-size: 16px;<br>}</pre><h3>When Should You Use External CSS?</h3><ul><li>In real-world projects</li><li>When working with multiple pages</li><li>When clean, maintainable code is important</li></ul><p><strong>This is the standard approach in professional projects.</strong></p><h3>CSS Priority Order (Important!)</h3><p>If the same element is styled using all three methods, the priority order is:</p><ol><li>Inline CSS</li><li>Internal CSS</li><li>External CSS</li></ol><p>This is part of the <strong>CSS specificity</strong> concept and is very important to understand.</p><h3>Which One Should You Use?</h3><ul><li><strong>Inline CSS</strong> → Special and exceptional cases</li><li><strong>Internal CSS</strong> → Small, single-page projects</li><li><strong>External CSS</strong> → ✅ The preferred choice in almost all cases</li></ul><p>For junior frontend developers <strong><em>Getting used to using External CSS early is a big advantage.</em></strong></p><p>Using CSS correctly is not just about styling elements — it’s about writing <strong>clean, maintainable, and scalable code</strong>.</p><p>Building this habit early will save you a lot of time and confusion as your projects grow.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=55ee10123789" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[CSS Flexbox Explained: flex-container and flex-item Concepts]]></title>
            <link>https://medium.com/@umut.yusuf.cinar/css-flexbox-explained-flex-container-and-flex-item-concepts-8a447185674c?source=rss-161c03d77043------2</link>
            <guid isPermaLink="false">https://medium.com/p/8a447185674c</guid>
            <dc:creator><![CDATA[Umut Yusuf Çınar ]]></dc:creator>
            <pubDate>Mon, 19 Jan 2026 10:22:09 GMT</pubDate>
            <atom:updated>2026-01-20T21:18:39.415Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/736/1*f2Lb4tL_5b-u4aFYEvX2Pg.jpeg" /></figure><p>When working with CSS layouts, one of the most common challenges is aligning elements — placing them side by side, centering them, or making them responsive.</p><p>This is where <strong>Flexbox (Flexible Box Layout)</strong> becomes one of the most powerful tools in CSS.</p><p>In this article, we’ll cover:</p><ul><li>What Flexbox is</li><li>What flex-container and flex-item mean</li><li>The most commonly used Flexbox properties</li></ul><p>This explanation is especially aimed at <strong>junior frontend developers</strong>.</p><h3>What Is Flexbox?</h3><p>Flexbox is a CSS layout model designed to help align elements along <strong>a single axis</strong> (horizontal or vertical) in a flexible and predictable way.</p><p>With Flexbox, you can:</p><ul><li>Easily place elements next to each other</li><li>Center elements vertically and horizontally</li><li>Build responsive layouts with less effort</li></ul><h3>How to Enable Flexbox</h3><p>To start using Flexbox, you only need one line of CSS:</p><pre>.container {<br>  display: flex;<br>}</pre><p>After this:</p><ul><li>.container becomes a <strong>flex-container</strong></li><li>All its direct children become <strong>flex-items</strong></li></ul><h3>What Is a flex-container?</h3><p>A flex-containeris the parent element that has display: flex;.<br> It <strong>defines the layout rules</strong> and controls how its child elements are aligned.</p><h3>Most Common flex-container Properties</h3><h3>flex-direction</h3><p>Defines the direction in which flex items are placed.</p><pre>.container {<br>  flex-direction: row; /* default */<br>}</pre><h3>justify-content</h3><p>Controls alignment along the <strong>main axis</strong>.</p><pre>.container {<br>  justify-content: center;<br>}</pre><p>Common values:</p><ul><li>flex-start</li><li>center</li><li>space-between</li><li>space-around</li><li>space-evenly</li></ul><h3>align-items</h3><p>Controls alignment along the <strong>cross axis</strong>.</p><pre>.container {<br>  align-items: center;<br>}</pre><p>This property is commonly used for <strong>vertical centering</strong>.</p><h3>What Is a flex-item?</h3><p>A flex-item is a <strong>direct child</strong> of a flex-container.<br> Flex items follow the rules defined by the container, but they can also have <strong>their own individual behavior</strong>.</p><h3>Most Common flex-item Properties</h3><h3>flex-grow</h3><p>Defines how much a flex item should grow to fill available space.</p><pre>.item {<br>  flex-grow: 1;<br>}</pre><ul><li>0 → does not grow (default)</li><li>1 → fills available space</li></ul><h3>flex-shrink</h3><p>Defines how much a flex item should shrink when space is limited.</p><pre>.item {<br>  flex-shrink: 0;<br>}</pre><ul><li>0 → does not shrink</li><li>1 → can shrink (default)</li></ul><h3>flex-basis</h3><p>Defines the initial size of a flex item.</p><pre>.item {<br>  flex-basis: 200px;<br>}</pre><p>It is often preferred over width in Flexbox layouts.</p><h3>The flex Shorthand Property</h3><pre>.item {<br>  flex: 1 1 200px;<br>}</pre><p>This is equivalent to:</p><pre>flex-grow: 1;<br>flex-shrink: 1;<br>flex-basis: 200px;</pre><h3>A Small but Important Note!</h3><ul><li>justify-content → works on the <strong>main axis</strong></li><li>align-items → works on the <strong>cross axis</strong></li></ul><p>The direction of the main axis depends on flex-direction:</p><p>row → horizontal</p><p>column → vertical</p><p>Understanding this relationship means you truly understand Flexbox.</p><h3>Quick Summary</h3><ul><li>display: flex enables Flexbox</li><li>flex-container defines layout rules</li><li>flex-item follows those rules but can override some behavior</li><li>The key concept: <strong>main axis vs cross axis</strong></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8a447185674c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[em vs rem in CSS]]></title>
            <link>https://medium.com/@umut.yusuf.cinar/em-vs-rem-in-css-e8a0a7a6bffe?source=rss-161c03d77043------2</link>
            <guid isPermaLink="false">https://medium.com/p/e8a0a7a6bffe</guid>
            <dc:creator><![CDATA[Umut Yusuf Çınar ]]></dc:creator>
            <pubDate>Wed, 14 Jan 2026 16:28:40 GMT</pubDate>
            <atom:updated>2026-01-14T16:37:33.386Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/736/1*f2Lb4tL_5b-u4aFYEvX2Pg.jpeg" /></figure><p>When you start learning frontend development, you often come across two CSS units that look very similar but behave quite differently: em and rem.</p><p>At first, they may seem interchangeable. Many beginners wonder:<br> <em>“Does it really matter which one I use?”</em></p><p>In this article, I’ll explain the difference between em and rem in a <strong>simple</strong>, <strong>clear</strong>, and <strong>practical</strong> way — especially for junior developers.</p><h3>First Things First: Both Are Relative Units</h3><p>Unlike px, which is a fixed unit, both em and rem are <strong>relative units</strong>.<br> This means their values are calculated <strong>based on another value</strong>.</p><p>The key difference is <strong>what they are relative to</strong>:</p><p>em → relative to the <strong>parent element</strong></p><p>rem → relative to the <strong>root (</strong><strong>html) element</strong></p><h3>What Is em?</h3><p>em is calculated based on the <strong>font-size of its parent element</strong>.</p><pre>.parent {<br>  font-size: 20px;<br>}<br><br>.child {<br>  font-size: 1.5em;<br>}</pre><p>.child font-size = <strong>20px × 1.5 = 30px</strong></p><p>So em depends directly on the parent’s font size.</p><p>A Common Problem with em:</p><pre>.parent {<br>  font-size: 20px;<br>}<br><br>.child {<br>  font-size: 1.5em;<br>}<br><br>.grandchild {<br>  font-size: 1.5em;<br>}</pre><p>Now the result is:</p><p>.child → 30px</p><p>.grandchild → 30px × 1.5 = <strong>45px</strong></p><p>This is called the <strong>cascading (or compounding) effect</strong>. For junior developers, this often causes <strong>unexpected layout issues</strong>.</p><h3>What Is rem?</h3><p>rem stands for <strong>root em</strong> and is always calculated relative to the <strong>root (html) element</strong>.</p><p>rem example:</p><pre>html {<br>  font-size: 16px;<br>}<br><br>.title {<br>  font-size: 2rem;<br>}</pre><p>Result: 2rem = <strong>32px</strong></p><p>No matter where .title is in the DOM, rem always refers to the html font size.</p><h3>When Should You Use Which?</h3><h3>Use rem When:</h3><ul><li>Defining global font sizes</li><li>Setting margin and padding values</li><li>Building scalable layouts</li><li>Working on medium or large projects</li></ul><p><strong>For juniors, rem should be the default choice.</strong></p><h3>Use em When:</h3><ul><li>You want a component to scale <strong>relative to its parent</strong></li><li>You need proportional sizing (e.g., icons inside buttons)</li></ul><p>But always ask yourself: <em>“What is this element relative to?” </em>before using em.</p><h3>Quick Summary</h3><ul><li>em → relative to the parent element and can compound</li><li>rem → always relative to the root (html)</li></ul><p>For junior developers:</p><ul><li>Learn and prefer rem first</li><li>Use em consciously and intentionally</li></ul><h3>Final Thoughts</h3><p>Understanding the difference between em and rem is not just about CSS syntax, it’s about <strong>building predictable and scalable designs</strong>.</p><p>Learning this early will save you from asking: <em>“Why did this suddenly get so big?” </em>later in your projects.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e8a0a7a6bffe" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>