<?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 Angel Cordova on Medium]]></title>
        <description><![CDATA[Stories by Angel Cordova on Medium]]></description>
        <link>https://medium.com/@ae_cordova?source=rss-b897491802f------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/2*6-JycxsfzXEYBkqxGW6KBA.jpeg</url>
            <title>Stories by Angel Cordova on Medium</title>
            <link>https://medium.com/@ae_cordova?source=rss-b897491802f------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Sun, 24 May 2026 02:26:00 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@ae_cordova/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[Avoid Headaches by Understanding CSS Specificity]]></title>
            <link>https://medium.com/@ae_cordova/avoid-headaches-by-understanding-css-specificity-4aa214557ebf?source=rss-b897491802f------2</link>
            <guid isPermaLink="false">https://medium.com/p/4aa214557ebf</guid>
            <category><![CDATA[web-design]]></category>
            <category><![CDATA[specificity]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[css3]]></category>
            <category><![CDATA[web-development]]></category>
            <dc:creator><![CDATA[Angel Cordova]]></dc:creator>
            <pubDate>Thu, 13 Feb 2020 00:00:53 GMT</pubDate>
            <atom:updated>2020-02-13T00:00:53.218Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*keyLMOf2L_Z_Buth.png" /></figure><p>Among all the concepts you have to understand in CSS, Specificity is a tricky one; and, it may be the reason why that font-size is not being applied to the element you’re trying to target.</p><p>If you want to spend less time yelling at your DEV tools, you should understand how the browser reads your code and decides which styling to apply upon conflicting rules.</p><p>If there are two or more CSS rules that point to the same element, and changing the same property, the browser gives more weight to the one with the most specific selector.</p><figure><img alt="Comparison between Universal and ID Selector" src="https://cdn-images-1.medium.com/max/1024/0*98sPvOwldRL-ajkn" /><figcaption>Specificity level: Universal vs ID Selector</figcaption></figure><p>So, given the case, the universal selector * is less specific than an id selector #. The browser will apply the style of the rule using the latter.</p><h3>Hierarchy, Specificity Value, and Calculation</h3><p>Four (…well, I’d say 5) categories define the level of specificity and they hold different values:</p><figure><img alt="Hierarchy and Values of CSS Specificity" src="https://cdn-images-1.medium.com/max/1024/0*lDS3zPR-kdcnBjwV" /><figcaption>Hierarchy by Type of Selector and its Value</figcaption></figure><p><strong><em>Note:</em></strong><em> I added a 5th one because it’s a good idea to clarify that the Universal Selector and Inherited Style have value of 0</em></p><p>To calculate specificity you should add the values of each selector category and compare the total. <strong>The highest value wins!</strong></p><p>for example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*pP_-O1Tj9osvSkFo" /><figcaption>Example 1</figcaption></figure><h3>What if they have the same specificity?</h3><p>The general rule is: <strong>the one closer to the HTML wins</strong>, but you can keep an eye on the following:</p><p><strong>The latest</strong>. Upon conflicting rules, The one appearing latest in the style-sheet wins.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*it5ZNthTdxhJ6TDI" /><figcaption>Example 2</figcaption></figure><p><strong>Position counts</strong>. If you have an external CSS style-sheet and also wrote CSS embedded in your HTML, in case of conflicts, the embedded one wins.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Fu760BPijXX_bx3A" /><figcaption>Example 3</figcaption></figure><h3>This is !important</h3><p>If you have a rule you want to apply, <strong>no matter what</strong>, there is a keyword to override everything: <strong>!important</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*Yvr-w9-PNWkENQiQ" /><figcaption>Example 4</figcaption></figure><p>Be careful and keep it as the last resource. It can make a mess out of your code if you over-use it.</p><p>Maybe that’s why it’s considered a bad practice.</p><p>You can read more about the correct and recommended usage in the<a href="https://developer.mozilla.org/en-US/docs/Web/CSS/Specificity"> MDN web docs</a>.</p><h3>More about the subject and references:</h3><p>So, now you know!</p><p>…but, if you still want to read more about specificity, check out the following resources, which also happen to be my references for this story:</p><ul><li><a href="https://www.w3schools.com/css/css_specificity.asp">W3Schools</a></li><li><a href="https://specificity.keegan.st/">Specificity Calculator</a></li><li><a href="https://css-tricks.com/specifics-on-css-specificity/">CSS Tricks</a></li><li>I already mentioned <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/Specificity">MDN</a></li></ul><p>You can print these out to have as a QRC:</p><ul><li><a href="https://specifishity.com/">Specifishity</a></li><li><a href="https://stuffandnonsense.co.uk/archives/css_specificity_wars.html">CSS Specificity Wars</a></li></ul><p>Happy coding!</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=4aa214557ebf" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>