<?xml version="1.0" encoding="UTF-8"?><rss version="2.0" xmlns:content="http://purl.org/rss/1.0/modules/content/"><channel><title>Articles | Arpit&apos;s Blog</title><description>Long form articles from Arpit Agrawal, a web designer-developer from India.</description><link>https://arpit.blog/</link><item><title>Selector scoping in element.querySelector() and element.querySelectorAll()</title><link>https://arpit.blog/articles/2025/12/selector-scoping-element-query-selector/</link><guid isPermaLink="true">https://arpit.blog/articles/2025/12/selector-scoping-element-query-selector/</guid><pubDate>Tue, 02 Dec 2025 09:27:00 GMT</pubDate><content:encoded>&lt;p&gt;I was reading the &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/API/Element/querySelector&quot;&gt;MDN docs for &lt;code&gt;element.querySelector()&lt;/code&gt;&lt;/a&gt; and learnt something totally unexpected about selector scope when this method is called on an element.&lt;/p&gt;
&lt;p&gt;Let’s say I have the following HTML:&lt;/p&gt;
&lt;pre class=&quot;astro-code css-variables&quot; style=&quot;background-color:var(--astro-code-background);color:var(--astro-code-foreground);overflow-x:auto&quot; tabindex=&quot;0&quot; data-language=&quot;html&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:var(--astro-code-foreground)&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-string-expression)&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-foreground)&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:var(--astro-code-foreground)&quot;&gt;	&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-string-expression)&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-foreground)&quot;&gt;&amp;gt;This is a paragraph and it has a &amp;lt;&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-string-expression)&quot;&gt;span&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-foreground)&quot;&gt;&amp;gt;span inside&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-string-expression)&quot;&gt;span&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-foreground)&quot;&gt;&amp;gt; it.&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-string-expression)&quot;&gt;p&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-foreground)&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:var(--astro-code-foreground)&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-string-expression)&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-foreground)&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:var(--astro-code-foreground)&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-string-expression)&quot;&gt;script&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-foreground)&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:var(--astro-code-token-keyword)&quot;&gt;	const&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-constant)&quot;&gt; baseElement&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-keyword)&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-constant)&quot;&gt; document&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-function)&quot;&gt;.querySelector&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-foreground)&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-string-expression)&quot;&gt;&amp;#39;p&amp;#39;&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-foreground)&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:var(--astro-code-token-comment)&quot;&gt;	// Note: We are querying relative to the &amp;lt;p&amp;gt; element, not the document&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:var(--astro-code-token-keyword)&quot;&gt;	const&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-constant)&quot;&gt; matchedSpan&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-keyword)&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-constant)&quot;&gt; baseElement&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-function)&quot;&gt;.querySelector&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-foreground)&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-string-expression)&quot;&gt;&amp;#39;div span&amp;#39;&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-foreground)&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:var(--astro-code-token-constant)&quot;&gt;	console&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-function)&quot;&gt;.log&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-foreground)&quot;&gt;(matchedSpan);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:var(--astro-code-foreground)&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-string-expression)&quot;&gt;script&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-foreground)&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Once the above JavaScript is executed, what do you expect to happen?&lt;/p&gt;
&lt;p&gt;I expected it to log &lt;code&gt;null&lt;/code&gt; to the console. My reasoning was simple: I am calling the method on &lt;code&gt;baseElement&lt;/code&gt; (the &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt; tag), and that paragraph clearly does not contain a &lt;code&gt;&amp;lt;div&amp;gt;&lt;/code&gt; inside it.&lt;/p&gt;
&lt;p&gt;But here’s what actually gets logged to the console:&lt;/p&gt;
&lt;pre class=&quot;astro-code css-variables&quot; style=&quot;background-color:var(--astro-code-background);color:var(--astro-code-foreground);overflow-x:auto&quot; tabindex=&quot;0&quot; data-language=&quot;console&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:var(--astro-code-foreground)&quot;&gt;&amp;lt;span&amp;gt;span inside&amp;lt;/span&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This surprisingly returns the &lt;code&gt;&amp;lt;span&amp;gt;&lt;/code&gt; from &lt;em&gt;inside&lt;/em&gt; the &lt;code&gt;&amp;lt;p&amp;gt;&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Why does this happen? MDN explains it like this:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;[…] &lt;code&gt;selectors&lt;/code&gt; is first applied to the whole document, not the &lt;code&gt;baseElement&lt;/code&gt;, to generate an initial list of potential elements. The resulting elements are then examined to see if they are descendants of &lt;code&gt;baseElement&lt;/code&gt;.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Note: &lt;code&gt;element.querySelectorAll()&lt;/code&gt; also applies selector scoping in the same manner.&lt;/p&gt;
&lt;p&gt;If we want to restrict the selector to the element on which it is called then we should use the &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Selectors/:scope&quot;&gt;&lt;code&gt;:scope&lt;/code&gt; pseudo-class&lt;/a&gt;.&lt;/p&gt;
&lt;pre class=&quot;astro-code css-variables&quot; style=&quot;background-color:var(--astro-code-background);color:var(--astro-code-foreground);overflow-x:auto&quot; tabindex=&quot;0&quot; data-language=&quot;js&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:var(--astro-code-token-keyword)&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-constant)&quot;&gt; scopedQuery&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-keyword)&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-constant)&quot;&gt; baseElement&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-function)&quot;&gt;.querySelector&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-foreground)&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-string-expression)&quot;&gt;&amp;#39;:scope div span&amp;#39;&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-foreground)&quot;&gt;);&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:var(--astro-code-token-constant)&quot;&gt;console&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-function)&quot;&gt;.log&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-foreground)&quot;&gt;(scopedQuery); &lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-comment)&quot;&gt;// Returns null, as expected&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;As mentioned in the &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/CSS/Reference/Selectors/:scope&quot;&gt;MDN docs for &lt;code&gt;:scope&lt;/code&gt;&lt;/a&gt;, this works because:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;When used within a DOM API call — such as &lt;code&gt;querySelector()&lt;/code&gt;, &lt;code&gt;querySelectorAll()&lt;/code&gt;, &lt;code&gt;matches()&lt;/code&gt;, or &lt;code&gt;Element.closest()&lt;/code&gt; — &lt;code&gt;:scope&lt;/code&gt; matches the element on which the method was called.&lt;/p&gt;
&lt;/blockquote&gt;</content:encoded><category>dom</category><category>css-selector</category><category>web-api</category><category>javascript</category></item><item><title>Safari drops support for the theme-color meta tag</title><link>https://arpit.blog/articles/2025/11/safari-drops-support-theme-color/</link><guid isPermaLink="true">https://arpit.blog/articles/2025/11/safari-drops-support-theme-color/</guid><pubDate>Sun, 09 Nov 2025 11:00:00 GMT</pubDate><content:encoded>&lt;p&gt;The &lt;code&gt;&amp;#x3C;meta name=&quot;theme-color&quot;&gt;&lt;/code&gt; tag is no longer supported in Safari 26 on macOS and iOS.&lt;/p&gt;
&lt;p&gt;If a fixed or sticky element touches the top or bottom edge of the window, then and only then, Safari extends that element’s background color into the corresponding top or bottom bar. Otherwise, on iOS, the bars remain translucent and have no solid color background.&lt;/p&gt;
&lt;p&gt;As &lt;a href=&quot;https://bugs.webkit.org/show_bug.cgi?id=301756#c2&quot;&gt;Wenson Hseih explained on WebKit Bugzilla&lt;/a&gt;:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;A solid background color extension (“top bar tint”) is only needed in cases where there’s a viewport-constrained (fixed or sticky) element near one of the edges of the viewport that borders an obscured content inset (such as the top toolbar on macOS, or compact tab bar on iOS), in order to avoid a gap above or below fixed elements in the page that would otherwise appear when scrolling. This color extension behaviour is more critical on iPhone, where there’s a much “softer” blur effect underneath the browser UI (and so more of the page underneath is otherwise directly visible).&lt;/p&gt;
&lt;/blockquote&gt;</content:encoded><category>theme-color</category><category>html</category><category>safari</category></item><item><title>Natural sorting of strings that contain numbers in JavaScript</title><link>https://arpit.blog/articles/2025/04/sorting-strings-that-contain-numbers-in-javascript/</link><guid isPermaLink="true">https://arpit.blog/articles/2025/04/sorting-strings-that-contain-numbers-in-javascript/</guid><pubDate>Fri, 18 Apr 2025 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;In JavaScript, things get interesting when you need to sort strings that contain numbers in a way that matches human expectations.&lt;/p&gt;
&lt;pre class=&quot;astro-code css-variables&quot; style=&quot;background-color:var(--astro-code-background);color:var(--astro-code-foreground);overflow-x:auto&quot; tabindex=&quot;0&quot; data-language=&quot;js&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:var(--astro-code-token-keyword)&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-constant)&quot;&gt; files&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-keyword)&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-foreground)&quot;&gt; [&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-string-expression)&quot;&gt;&amp;#39;IMG_2.png&amp;#39;&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-punctuation)&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-string-expression)&quot;&gt; &amp;#39;IMG_1.png&amp;#39;&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-punctuation)&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-string-expression)&quot;&gt; &amp;#39;IMG_10.png&amp;#39;&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-punctuation)&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-string-expression)&quot;&gt; &amp;#39;IMG_20.png&amp;#39;&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-foreground)&quot;&gt;];&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:var(--astro-code-token-constant)&quot;&gt;files&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-function)&quot;&gt;.sort&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-foreground)&quot;&gt;();&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:var(--astro-code-token-comment)&quot;&gt;// Output: [&amp;#39;IMG_1.png&amp;#39;, &amp;#39;IMG_10.png&amp;#39;, &amp;#39;IMG_2.png&amp;#39;, &amp;#39;IMG_20.png&amp;#39;]&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This happens because, by default, when no compare function is provided, JavaScript’s array &lt;code&gt;sort()&lt;/code&gt; method converts the elements into strings, then compares their sequences of UTF-16 code unit values.&lt;/p&gt;
&lt;p&gt;This behaviour is well documented on &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/sort&quot;&gt;MDN&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;So, how do we sort arrays like the ones above in a more accurate, human-friendly order?&lt;/p&gt;
&lt;p&gt;This is where the &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Intl/Collator/compare&quot;&gt;&lt;code&gt;compare()&lt;/code&gt; method of the &lt;code&gt;Intl.Collator&lt;/code&gt; API&lt;/a&gt; with the &lt;code&gt;numeric: true&lt;/code&gt; option shines. It provides the natural sorting behaviour that correctly handles numbers alongside other characters.&lt;/p&gt;
&lt;p&gt;When &lt;code&gt;numeric: true&lt;/code&gt; is set, the collator detects numeric substrings inside the strings and parses those substrings as actual numbers, not as sequences of digits. And then it compares the numbers numerically, not character by character.&lt;/p&gt;
&lt;pre class=&quot;astro-code css-variables&quot; style=&quot;background-color:var(--astro-code-background);color:var(--astro-code-foreground);overflow-x:auto&quot; tabindex=&quot;0&quot; data-language=&quot;js&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:var(--astro-code-token-keyword)&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-constant)&quot;&gt; naturalOrder&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-keyword)&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-keyword)&quot;&gt; new&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-constant)&quot;&gt; Intl&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-function)&quot;&gt;.Collator&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-foreground)&quot;&gt;(&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-constant)&quot;&gt;undefined&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-punctuation)&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-foreground)&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:var(--astro-code-foreground)&quot;&gt;	numeric&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-keyword)&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-constant)&quot;&gt; true&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-punctuation)&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:var(--astro-code-foreground)&quot;&gt;}).compare;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:var(--astro-code-token-keyword)&quot;&gt;const&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-constant)&quot;&gt; files&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-keyword)&quot;&gt; =&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-foreground)&quot;&gt; [&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-string-expression)&quot;&gt;&amp;#39;IMG_2.png&amp;#39;&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-punctuation)&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-string-expression)&quot;&gt; &amp;#39;IMG_1.png&amp;#39;&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-punctuation)&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-string-expression)&quot;&gt; &amp;#39;IMG_10.png&amp;#39;&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-punctuation)&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-string-expression)&quot;&gt; &amp;#39;IMG_20.png&amp;#39;&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-foreground)&quot;&gt;];&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:var(--astro-code-token-constant)&quot;&gt;files&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-function)&quot;&gt;.sort&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-foreground)&quot;&gt;((a&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-punctuation)&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-foreground)&quot;&gt; b) &lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-keyword)&quot;&gt;=&amp;gt;&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-function)&quot;&gt; naturalOrder&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-foreground)&quot;&gt;(a&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-punctuation)&quot;&gt;,&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-foreground)&quot;&gt; b));&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:var(--astro-code-token-comment)&quot;&gt;// Output: [&amp;#39;IMG_1.png&amp;#39;, &amp;#39;IMG_2.png&amp;#39;, &amp;#39;IMG_10.png&amp;#39;, &amp;#39;IMG_20.png&amp;#39;]&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Hat tip to &lt;a href=&quot;https://jan.miksovsky.com/posts/2025/04-17-zero-dependencies&quot;&gt;Jan Miksovsky&lt;/a&gt;, whose &lt;a href=&quot;https://github.com/WebOrigami/pondlife-zero-deps&quot;&gt;zero dependencies SSG project&lt;/a&gt; led me to discover this.&lt;/p&gt;</content:encoded><category>sort</category><category>internationalization</category><category>javascript</category></item><item><title>Why is `grid-row: 1/-1` not working?</title><link>https://arpit.blog/articles/2025/02/why-is-grid-row-1--1-not-working/</link><guid isPermaLink="true">https://arpit.blog/articles/2025/02/why-is-grid-row-1--1-not-working/</guid><pubDate>Wed, 05 Feb 2025 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;The &lt;code&gt;grid-row&lt;/code&gt; grid-placement property is shorthand for &lt;code&gt;grid-row-start&lt;/code&gt; and &lt;code&gt;grid-row-end&lt;/code&gt;.&lt;/p&gt;
&lt;pre class=&quot;astro-code css-variables&quot; style=&quot;background-color:var(--astro-code-background);color:var(--astro-code-foreground);overflow-x:auto&quot; tabindex=&quot;0&quot; data-language=&quot;css&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:var(--astro-code-token-function)&quot;&gt;.grid-item&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-foreground)&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:var(--astro-code-token-constant)&quot;&gt;	grid-row&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-keyword)&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-constant)&quot;&gt; 1/-1&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-foreground)&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:var(--astro-code-token-comment)&quot;&gt;	/* is equivalent to */&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:var(--astro-code-token-constant)&quot;&gt;	grid-row-start&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-keyword)&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-constant)&quot;&gt; 1&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-foreground)&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:var(--astro-code-token-constant)&quot;&gt;	grid-row-end&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-keyword)&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-constant)&quot;&gt; -1&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-foreground)&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:var(--astro-code-foreground)&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In the above declaration, we use integers to position and size the grid item by line numbers.&lt;/p&gt;
&lt;p&gt;As per the &lt;a href=&quot;https://www.w3.org/TR/css-grid-1/#:~:text=Numeric,-indexes%20in%20the&quot;&gt;spec&lt;/a&gt;:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Numeric indexes in the grid-placement properties count from the edges of the explicit grid. Positive indexes count from the start side (starting from 1 for the start-most explicit line), while negative indexes count from the end side (starting from -1 for the end-most explicit line).&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;The important bit is the explicit grid. This begs the question …&lt;/p&gt;
&lt;h2 id=&quot;what-is-the-explicit-grid&quot;&gt;What is the explicit grid?&lt;/h2&gt;
&lt;p&gt;As per the &lt;a href=&quot;https://www.w3.org/TR/css-grid-1/#explicit-grids&quot;&gt;spec&lt;/a&gt;:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;The three properties &lt;code&gt;grid-template-rows&lt;/code&gt;, &lt;code&gt;grid-template-columns&lt;/code&gt;, and &lt;code&gt;grid-template-areas&lt;/code&gt; together define the explicit grid of a grid container by specifying its explicit grid tracks.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;Simply put, the explicit grid consists of manually defined rows and columns.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;The size of the explicit grid is determined by the larger of the number of rows/columns defined by &lt;code&gt;grid-template-areas&lt;/code&gt; and the number of rows/columns sized by &lt;code&gt;grid-template-rows&lt;/code&gt;/&lt;code&gt;grid-template-columns&lt;/code&gt;. Any rows/columns defined by &lt;code&gt;grid-template-areas&lt;/code&gt; but not sized by &lt;code&gt;grid-template-rows&lt;/code&gt;/&lt;code&gt;grid-template-columns&lt;/code&gt; take their size from the &lt;code&gt;grid-auto-rows&lt;/code&gt;/&lt;code&gt;grid-auto-columns&lt;/code&gt; properties. If these properties don’t define any explicit tracks the explicit grid still contains one grid line in each axis.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;That last bit is what leads to line -1 being the same line as 1 because the explicit grid still contains one grid line in each axis.&lt;/p&gt;
&lt;h2 id=&quot;what-is-the-implicit-grid&quot;&gt;What is the implicit grid?&lt;/h2&gt;
&lt;p&gt;As &lt;a href=&quot;https://css-tricks.com/difference-explicit-implicit-grids/#aa-implicit-grids&quot;&gt;Manuel Matuzovic&lt;/a&gt; puts it:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;If there are more grid items than cells in the grid or when a grid item is placed outside of the explicit grid, the grid container automatically generates grid tracks by adding grid lines to the grid. The explicit grid together with these additional implicit tracks and lines forms the so called implicit grid.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;Paraphrasing &lt;a href=&quot;https://x.com/jensimmons/status/1239587367046037504&quot;&gt;Jen Simmons&lt;/a&gt;:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;-1 is the last line of the &lt;em&gt;explicit&lt;/em&gt; grid&lt;/li&gt;
&lt;li&gt;If you haven’t defined any explicit rows, then all your rows are implicit&lt;/li&gt;
&lt;li&gt;For implicit rows, -1 is the same line as 1&lt;/li&gt;
&lt;li&gt;Define explicit rows and &lt;code&gt;grid-row: 1/-1&lt;/code&gt; will work as expected&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;further-reading&quot;&gt;Further Reading&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/63775143/how-does-grid-row-1-1-actually-work-references-needed&quot;&gt;How does grid-row: 1 / -1 actually work?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://stackoverflow.com/questions/73559099/what-defines-an-explicit-grid&quot;&gt;What defines an explicit grid?&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;</content:encoded><category>grid</category><category>grid-placement</category><category>css</category></item><item><title>Transparent borders</title><link>https://arpit.blog/articles/2024/05/transparent-borders/</link><guid isPermaLink="true">https://arpit.blog/articles/2024/05/transparent-borders/</guid><pubDate>Sun, 12 May 2024 00:00:00 GMT</pubDate><content:encoded>&lt;p&gt;In web development, small design decisions can have a significant impact on accessibility and user experience. One such decision is how we handle borders on interactive elements.&lt;/p&gt;
&lt;h2 id=&quot;the-problem-with-border-none&quot;&gt;The problem with border: none&lt;/h2&gt;
&lt;p&gt;When styling interactive elements like buttons, it’s common practice to remove default borders using &lt;code&gt;border: none&lt;/code&gt;. However, this approach can lead to accessibility issues, especially in &lt;a href=&quot;https://arpit.blog/blog/testing-in-forced-colors-mode/&quot;&gt;high contrast mode&lt;/a&gt;. As demonstrated in the image below, removing the border entirely can cause buttons to appear as floating text on the page, making it difficult for users with low vision to distinguish interactive elements.&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://arpit.blog/_astro/slae-before-after-high-contrast-mode.DZV7xYGL_Z2b3SWO.webp&quot; alt=&quot;Side-by-side comparison of the contact form on Slae.app. The left image shows the contact form with forced colors disabled, displaying the default color scheme. The right image shows the contact form with forced colors enabled. In the right image, the submit button appears as floating text on the page.&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; fetchpriority=&quot;auto&quot; width=&quot;960&quot; height=&quot;596&quot;&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://frontendmasters.com/blog/you-want-border-color-transparent-not-border-none/&quot;&gt;Dave Rupert&lt;/a&gt; explains the importance of the default border and why it exists:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;In the case of interactive form controls (inputs, textareas, buttons, etc.), those pesky borders were put there because they have an accessibility benefit when using High Contrast Mode, a feature &lt;a href=&quot;https://webaim.org/projects/lowvisionsurvey2/#at&quot;&gt;used by 30.6% of low-vision users&lt;/a&gt;.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;h2 id=&quot;the-transparent-border-solution&quot;&gt;The transparent border solution&lt;/h2&gt;
&lt;p&gt;To address this issue, Dave recommends making the border or outline transparent instead of removing it entirely. This can be achieved with the following CSS:&lt;/p&gt;
&lt;pre class=&quot;astro-code css-variables&quot; style=&quot;background-color:var(--astro-code-background);color:var(--astro-code-foreground);overflow-x:auto&quot; tabindex=&quot;0&quot; data-language=&quot;css&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:var(--astro-code-token-string-expression)&quot;&gt;button&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-foreground)&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:var(--astro-code-token-constant)&quot;&gt;	border-color&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-keyword)&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-constant)&quot;&gt; transparent&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-foreground)&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:var(--astro-code-foreground)&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;As demonstrated in the image below, this approach is effective for several reasons. First, sighted users will not notice the difference. Second, as &lt;a href=&quot;https://polypane.app/blog/forced-colors-explained-a-practical-guide/&quot;&gt;Kilian Valkhof&lt;/a&gt; explains, in forced color mode, the border color or outline color “will be overwritten with the current text color, making it nicely visible again without needing any special adaption or re-styling for forced color mode.”&lt;/p&gt;
&lt;p&gt;&lt;img src=&quot;https://arpit.blog/_astro/slae-before-after-transparent-border.sJpjMR8c_Z1FuV5Y.webp&quot; alt=&quot;Side-by-side comparison of the contact form on Slae.app with the transparent border solution applied. The left image shows the contact form with forced colors disabled, displaying the default color scheme. The right image shows the contact form with forced colors enabled. In the right image, the submit button appears as a button.&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; fetchpriority=&quot;auto&quot; width=&quot;959&quot; height=&quot;596&quot;&gt;&lt;/p&gt;
&lt;h2 id=&quot;user-experience-benefits&quot;&gt;User experience benefits&lt;/h2&gt;
&lt;p&gt;Using transparent borders offers additional benefits for user experience. Consider hover effects, for example.&lt;/p&gt;
&lt;pre class=&quot;astro-code css-variables&quot; style=&quot;background-color:var(--astro-code-background);color:var(--astro-code-foreground);overflow-x:auto&quot; tabindex=&quot;0&quot; data-language=&quot;css&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:var(--astro-code-token-string-expression)&quot;&gt;button&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-foreground)&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:var(--astro-code-token-constant)&quot;&gt;	border&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-keyword)&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-constant)&quot;&gt; none&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-foreground)&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:var(--astro-code-foreground)&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:var(--astro-code-token-string-expression)&quot;&gt;button&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-function)&quot;&gt;:hover&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-foreground)&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:var(--astro-code-token-constant)&quot;&gt;	border&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-keyword)&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-constant)&quot;&gt; 2&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-keyword)&quot;&gt;px&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-constant)&quot;&gt; solid navy&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-foreground)&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:var(--astro-code-foreground)&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In such situations, applying a visible border on hover can inadvertently change the element’s dimensions. This change in size can result in a jarring visual effect.&lt;/p&gt;
&lt;p&gt;By setting a transparent border in the default state, we ensure smooth transitions and consistent element sizes across different states.&lt;/p&gt;
&lt;pre class=&quot;astro-code css-variables&quot; style=&quot;background-color:var(--astro-code-background);color:var(--astro-code-foreground);overflow-x:auto&quot; tabindex=&quot;0&quot; data-language=&quot;html&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:var(--astro-code-foreground)&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-string-expression)&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-foreground)&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:var(--astro-code-foreground)&quot;&gt;	&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-string-expression)&quot;&gt;button&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-function)&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-keyword)&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-string-expression)&quot;&gt;&amp;quot;no-border-btn&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-foreground)&quot;&gt;&amp;gt;Button with no border&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-string-expression)&quot;&gt;button&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-foreground)&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:var(--astro-code-foreground)&quot;&gt;	&amp;lt;&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-string-expression)&quot;&gt;button&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-function)&quot;&gt; class&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-keyword)&quot;&gt;=&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-string-expression)&quot;&gt;&amp;quot;transparent-border-btn&amp;quot;&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-foreground)&quot;&gt;&amp;gt;Button with transparent border&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-string-expression)&quot;&gt;button&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-foreground)&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:var(--astro-code-foreground)&quot;&gt;&amp;lt;/&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-string-expression)&quot;&gt;div&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-foreground)&quot;&gt;&amp;gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&quot;astro-code css-variables&quot; style=&quot;background-color:var(--astro-code-background);color:var(--astro-code-foreground);overflow-x:auto&quot; tabindex=&quot;0&quot; data-language=&quot;css&quot;&gt;&lt;code&gt;&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:var(--astro-code-token-function)&quot;&gt;.no-border-btn&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-foreground)&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:var(--astro-code-token-constant)&quot;&gt;	border&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-keyword)&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-constant)&quot;&gt; none&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-foreground)&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:var(--astro-code-foreground)&quot;&gt;	&amp;amp;&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-keyword)&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-constant)&quot;&gt;hover {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:var(--astro-code-token-constant)&quot;&gt;		border: 2&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-keyword)&quot;&gt;px&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-constant)&quot;&gt; solid navy&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-foreground)&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:var(--astro-code-foreground)&quot;&gt;	}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:var(--astro-code-foreground)&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:var(--astro-code-token-function)&quot;&gt;.transparent-border-btn&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-foreground)&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:var(--astro-code-token-constant)&quot;&gt;	border&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-keyword)&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-constant)&quot;&gt; 2&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-keyword)&quot;&gt;px&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-constant)&quot;&gt; solid transparent&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-foreground)&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:var(--astro-code-foreground)&quot;&gt;	&amp;amp;&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-keyword)&quot;&gt;:&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-token-constant)&quot;&gt;hover {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:var(--astro-code-token-constant)&quot;&gt;		border-color: navy&lt;/span&gt;&lt;span style=&quot;color:var(--astro-code-foreground)&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:var(--astro-code-foreground)&quot;&gt;	}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;line&quot;&gt;&lt;span style=&quot;color:var(--astro-code-foreground)&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;implications-for-design-systems&quot;&gt;Implications for design systems&lt;/h2&gt;
&lt;p&gt;Transparent borders are also valuable in the context of themeable design systems. &lt;a href=&quot;https://bradfrost.com/blog/post/transparent-borders/&quot;&gt;Brad Frost&lt;/a&gt; elaborates:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;When supporting multiple theme, it can be common for some themes to use borders while others don’t. This flexibility is great! Each brand is able to express themselves how they see fit. But if implemented using different border widths, shifts in the box model happen.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;By using &lt;code&gt;border-color: transparent&lt;/code&gt; for themes without visible borders, designers and developers can maintain consistent element sizes across different variants and themes. This approach provides the flexibility to adapt the visual design while preserving the underlying structure and layout of the components.&lt;/p&gt;
&lt;h2 id=&quot;conclusion&quot;&gt;Conclusion&lt;/h2&gt;
&lt;p&gt;Implementing transparent borders in your CSS addresses crucial accessibility concerns, enhances user experience across different display modes, and provides the flexibility needed for robust, adaptable design systems.&lt;/p&gt;</content:encoded><category>accessibility</category><category>high-contrast-mode</category><category>design-systems</category><category>css</category><category>dave-rupert</category><category>brad-frost</category><category>code-pen-demo</category></item></channel></rss>