<?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 Christina Howard on Medium]]></title>
        <description><![CDATA[Stories by Christina Howard on Medium]]></description>
        <link>https://medium.com/@christina.vhoward?source=rss-8f9604d5f0bc------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*PrfLHlYIBms8sRVP</url>
            <title>Stories by Christina Howard on Medium</title>
            <link>https://medium.com/@christina.vhoward?source=rss-8f9604d5f0bc------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 20:58:38 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@christina.vhoward/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[Pseudo-Classes in CSS]]></title>
            <link>https://medium.com/better-programming/pseudo-classes-what-are-they-and-why-you-shouldnt-use-them-8d78b64a760b?source=rss-8f9604d5f0bc------2</link>
            <guid isPermaLink="false">https://medium.com/p/8d78b64a760b</guid>
            <category><![CDATA[css]]></category>
            <category><![CDATA[engineering]]></category>
            <category><![CDATA[front-end-development]]></category>
            <category><![CDATA[web-development]]></category>
            <category><![CDATA[programming]]></category>
            <dc:creator><![CDATA[Christina Howard]]></dc:creator>
            <pubDate>Sat, 11 Jul 2020 02:16:11 GMT</pubDate>
            <atom:updated>2020-07-15T14:39:10.981Z</atom:updated>
            <content:encoded><![CDATA[<h4>What they are and why you shouldn’t use them</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*UCRcggv3ATfUfcLC" /><figcaption>Photo by <a href="https://unsplash.com/@drieaugu?utm_source=medium&amp;utm_medium=referral">Dries Augustyns</a> on <a href="https://unsplash.com/?utm_source=medium&amp;utm_medium=referral">Unsplash</a>.</figcaption></figure><p>The other day, I was working on some styling bugs that a designer noticed for my web app at work. As per usual, I checked the mocks the designer so graciously made and did my best to recreate them on the UI. Trying to remove a bottom border for the last row in a table was a pesky little task. So I did it. That’s right, I decided to use a pseudo-class to get my way.</p><p>For those who don’t know what they are, pseudo-classes are elements that are in a specific state. Pseudo-classes are keywords that start with a colon:</p><ul><li>:last-child</li><li>:nth-of-type</li><li>:invalid</li><li>:hover</li><li>:focus</li><li><a href="https://developer.mozilla.org/en-US/docs/Learn/CSS/Building_blocks/Selectors/Pseudo-classes_and_pseudo-elements#:~:text=A%20pseudo%2Dclass%20is%20a,over%20by%20the%20mouse%20pointer.">etc.</a></li></ul><p>They are useful for cutting down on excess classes in your markup, more flexibility in styling, and are maintainable. Here’s a quick example of how to use one.</p><p>HTML:</p><pre>&lt;article&gt;<br> &lt;p&gt;Hello&lt;/p&gt;<br> &lt;p&gt;I&#39;m a&lt;/p&gt;<br> &lt;p&gt;PSUEDO-ClASS&lt;/p&gt;<br>&lt;/article&gt;</pre><p>CSS:</p><pre>article p:last-child {<br> background-color: red;<br>}</pre><p>As you can see, the background color for PSEUDO-CLASS is red, while the rest of the p tags stay the same without having to change the HTML.</p><p>Adding last-child to the table row and setting it to border-bottom: none seemed harmless, but something felt wrong about it. I was happy because it did work, but I could feel the PR gods weeping. So I did some digging.</p><p>There was a catch to this neat trick, and it was <em>performance</em>.</p><p>To illustrate the issues with pseudo-classes, I’ll go back to my example. Say we want to style on the other paragraph tags.</p><p>HTML:</p><pre>&lt;article&gt;<br> &lt;p&gt;Hello&lt;/p&gt;<br> &lt;p &gt;I&#39;m a&lt;/p&gt;<br> &lt;p&gt;PSUEDO-ClASS&lt;/p&gt;<br>&lt;/article&gt;</pre><p>CSS:</p><iframe src="" width="0" height="0" frameborder="0" scrolling="no"><a href="https://medium.com/media/507dd8f647cbd36df757fd4ec61d6d71/href">https://medium.com/media/507dd8f647cbd36df757fd4ec61d6d71/href</a></iframe><p>The issue may not be obvious, but you’ve now described a styling for all the paragraphs and then a more specific styling for the last paragraph on the page. What ends up happening is that your page will redraw the last paragraph to reflect the more specific styling as denoted by the pseudo-class. This causes inefficient CSS and hurts performance. Styling elements over again with duplicate properties do cause a redraw since pseudo-selectors are applied at a later time in the CSS rendering timeline.</p><p>Usually, article p would style all the paragraphs first and then :last-child would only style the last paragraph on the page. What happens is that all the p tags are given the overall styling and then the last-child is redrawn to its more specific styling.</p><p>On larger applications, there is a small performance hit using pseudo-classes like these. Let’s say you want to find the last div on a page that uses thousands of divs. Yes, there is some performance hit for finding the div, but the real monster is redrawing the styling of that div. So maybe on a POC or even a personal blog project, using pseudo-classes is neat. But be wary of committing a PR with them in a large codebase serving millions of users. Web performance is always a relevant and important topic.</p><p>While CSS selectors aren’t going to destroy your web app, be mindful of how and when you use them.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8d78b64a760b" width="1" height="1" alt=""><hr><p><a href="https://medium.com/better-programming/pseudo-classes-what-are-they-and-why-you-shouldnt-use-them-8d78b64a760b">Pseudo-Classes in CSS</a> was originally published in <a href="https://betterprogramming.pub/">Better Programming</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>