<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title>FED Mentor</title>
	<subtitle>Tips to help the modern Front End Developer (FED) build inclusive and  intelligent solutions..</subtitle>
	
	<link href="https://fedmentor.dev/feed/feed.xml" rel="self"/>
	<link href="https://fedmentor.dev"/>
	<updated>2024-12-27T00:00:00Z</updated>
	<id>https://fedmentor.dev/</id>
	<author>
		<name>Grace Snow &lt;span aria-hidden=&#39;true&#39;&gt;🌈&lt;/span&gt;</name>
		<email>grace@fedmentor.dev</email>
	</author>
	
	<entry>
		<title>Why heading order matters in HTML</title>
		<link href="https://fedmentor.dev/posts/heading-order/"/>
		<updated>2024-12-27T00:00:00Z</updated>
		<id>https://fedmentor.dev/posts/heading-order/</id>
		<content type="html">&lt;p&gt;Heading levels are &lt;em&gt;not&lt;/em&gt; about font size. They are all about &lt;em&gt;meaning&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;Think of it this way:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;h1&amp;gt;&lt;/code&gt; is the page title.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;h2&amp;gt;&lt;/code&gt; is a major section within that page.&lt;/li&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;h3&amp;gt;&lt;/code&gt; is a subsection within that major section, and so on.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;While not explicitly a WCAG failure, maintaining proper heading order (h1-h6) improves accessibility. It creates a clear document structure, aids screen reader users and helps search engines understand page content.&lt;/p&gt;
&lt;h2 id=&quot;why-does-order-matter&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/heading-order/#why-does-order-matter&quot;&gt;&lt;span&gt;Why does order matter?&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Screen readers are tools that help people with visual, mobility and cognitive impairments read and navigate web pages. They rely on the heading order to understand the structure and jump directly to sections of interest.&lt;/p&gt;
&lt;p&gt;Some people using screen readers rely heavily on shortcuts in the tool to jump from heading to heading.&lt;/p&gt;
&lt;p&gt;Search engines use headings to understand the page&#39;s topic and how information is organised. This can improve your search engine ranking.&lt;/p&gt;
&lt;p&gt;A well-structured page with appropriate headings is also easier for all users to understand and navigate, regardless of disability.&lt;/p&gt;
&lt;h2 id=&quot;appropriate-heading-content&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/heading-order/#appropriate-heading-content&quot;&gt;&lt;span&gt;Appropriate heading content&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;When you consider that headings are meant to communicate content structure like this (Chapter 1, Section 1.1, Subsection 1.1.1), it should become clear that only certain pieces of content are appropriate to &lt;em&gt;be&lt;/em&gt; heading elements.&lt;/p&gt;
&lt;p&gt;Numbers might be large in a design with a word underneath, like this:&lt;/p&gt;
&lt;figure class=&quot;[ flex flex-col  ]&quot;&gt;&lt;picture&gt;&lt;source type=&quot;image/webp&quot; srcset=&quot;https://fedmentor.dev/posts/heading-order/stats-list-800w.webp 800w, https://fedmentor.dev/posts/heading-order/stats-list-1200w.webp 1200w&quot; sizes=&quot;(min-width: 30em) 50vw, 100vw&quot; /&gt;&lt;source type=&quot;image/jpeg&quot; srcset=&quot;https://fedmentor.dev/posts/heading-order/stats-list-800w.jpeg 800w, https://fedmentor.dev/posts/heading-order/stats-list-1200w.jpeg 1200w&quot; sizes=&quot;(min-width: 30em) 50vw, 100vw&quot; /&gt;&lt;img alt=&quot;Three statistics with the numbers large and bold on the first row, and small grey words underneath each of them&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; src=&quot;https://fedmentor.dev/posts/heading-order/stats-list-800w.jpeg&quot; width=&quot;1200&quot; height=&quot;286&quot; /&gt;&lt;/picture&gt;&lt;/figure&gt;
&lt;p&gt;But those numbers wouldn&#39;t make any sense as headings. If you saw &amp;quot;80k&amp;quot; on a contents page, you wouldn&#39;t understand what that section of content would be about. The numbers have to be read &lt;em&gt;together&lt;/em&gt; with their accompanying word to make sense. They are not acting as headings — as titles — for any other content. So you know they shouldn&#39;t be headings.&lt;/p&gt;
&lt;p&gt;So, in assessing what should be headings, think:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;em&gt;&amp;quot;Is this a title for some nearby content?&amp;quot;&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;If no, then it&#39;s not a heading. Maybe it&#39;s a paragraph or list item&lt;br /&gt; If yes, then it&#39;s a heading. &lt;br /&gt; So the next question is, &lt;em&gt;&amp;quot;Does this heading and its content &lt;strong&gt;belong&lt;/strong&gt; to the section above?&amp;quot;&lt;/em&gt; (i.e. Is the heading a subtitle?)&lt;/li&gt;
&lt;li&gt;If yes, then it needs to be one level below it&#39;s parent heading. &lt;br /&gt;i.e. If the main section has a &lt;code&gt;h2&lt;/code&gt;, this would be a &lt;code&gt;h3&lt;/code&gt;.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;what-if-designs-lack-headings&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/heading-order/#what-if-designs-lack-headings&quot;&gt;&lt;span&gt;What if designs lack headings?&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Consider whether headings are necessary to understand the content of the page. It might make sense visually because of how content is grouped. But would you understand this if reading the content (or having the page read to you by a screen reader)?&lt;/p&gt;
&lt;p&gt;If headings are missing from a design, you may need to raise that with the designer, or you may need to add additional &lt;strong&gt;screen reader-only&lt;/strong&gt; (&lt;code&gt;visually-hidden&lt;/code&gt; or &lt;code&gt;sr-only&lt;/code&gt;) headings on the page.&lt;/p&gt;
&lt;p&gt;For example, take a look at this design for a News website:&lt;/p&gt;
&lt;figure class=&quot;[ flex flex-col  ]&quot;&gt;&lt;picture&gt;&lt;source type=&quot;image/webp&quot; srcset=&quot;https://fedmentor.dev/posts/heading-order/news-desktop-800w.webp 800w, https://fedmentor.dev/posts/heading-order/news-desktop-1200w.webp 1200w&quot; sizes=&quot;(min-width: 30em) 50vw, 100vw&quot; /&gt;&lt;source type=&quot;image/jpeg&quot; srcset=&quot;https://fedmentor.dev/posts/heading-order/news-desktop-800w.jpeg 800w, https://fedmentor.dev/posts/heading-order/news-desktop-1200w.jpeg 1200w&quot; sizes=&quot;(min-width: 30em) 50vw, 100vw&quot; /&gt;&lt;img alt=&quot;The desktop design of the Frontend Mentor News Homepage challenge that has no obvious page heading and only one heading for one of 3 sections of articles.&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; src=&quot;https://fedmentor.dev/posts/heading-order/news-desktop-800w.jpeg&quot; width=&quot;1200&quot; height=&quot;853&quot; /&gt;&lt;/picture&gt;&lt;/figure&gt;
&lt;p&gt;There is a big heading visible in the design, but that is for a featured article, and not an appropriate heading for the whole page. In fact, visibly there are no obvious candidates for the page&#39;s &lt;code&gt;h1&lt;/code&gt; element... If you consider what we&#39;ve covered about headings, this page may end up with a heading structure as follows:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;h1 class=&amp;quot;sr-only&amp;quot;&amp;gt;News Homepage&amp;lt;/h1&amp;gt;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;h2 class=&amp;quot;sr-only&amp;quot;&amp;gt;Featured Post&amp;lt;/h2&amp;gt;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;h3&amp;gt;The Bright Future of Web 3.0?&amp;lt;/h2&amp;gt;&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;&amp;lt;h2&amp;gt;New&amp;lt;/h2&amp;gt;&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;See if you can work out the rest! &lt;em&gt;(Remember some headings may need links inside so people can reach these articles.)&lt;/em&gt;&lt;/p&gt;
&lt;aside class=&quot;c-aside c-aside--alert [ relative text-body ]&quot; aria-labelledby=&quot;87c99a93-59b5-4097-b7bd-7dcf681d3c29&quot;&gt;
  &lt;div class=&quot;c-aside__icon [ grid place-content-center ]&quot;&gt;
    &lt;svg 2000=&quot;&quot; aria-hidden=&quot;true&quot; focusable=&quot;false xmlns=&quot; http:=&quot;&quot; www.w3.org=&quot;&quot; svg&quot;=&quot;&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;var(--icon-fill, var(--post-bg))&quot; stroke=&quot;var(--icon-stroke, var(--rainbow--teal))&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;[ h-full w-full ]&quot;&gt;&lt;polygon points=&quot;7.86 2 16.14 2 22 7.86 22 16.14 16.14 22 7.86 22 2 16.14 2 7.86 7.86 2&quot;&gt;&lt;/polygon&gt;&lt;line x1=&quot;12&quot; y1=&quot;8&quot; x2=&quot;12&quot; y2=&quot;12&quot;&gt;&lt;/line&gt;&lt;line x1=&quot;12&quot; y1=&quot;16&quot; x2=&quot;12.01&quot; y2=&quot;16&quot;&gt;&lt;/line&gt;&lt;/svg&gt;
  &lt;/div&gt;
  &lt;div class=&quot;c-aside__content flow&quot;&gt;&lt;strong id=&quot;87c99a93-59b5-4097-b7bd-7dcf681d3c29&quot; class=&quot;c-aside__title [  block font-heading leading-tight no-underline uppercase tracking-wide text-sm ]&quot;&gt;Key skill!&lt;/strong&gt;&lt;div class=&quot;flow&quot;&gt;&lt;p&gt;Translating a design into appropriate, well-structured HTML is an important skill for all front end developers. Make sure you dedicate the time and attention it deserves.&lt;/p&gt;
&lt;p&gt;See this &lt;a href=&quot;https://fedmentor.dev/posts/html-plan-product-preview/&quot;&gt;related post on how to translate a design into HTML&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;/aside&gt;
&lt;h2 id=&quot;summary&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/heading-order/#summary&quot;&gt;&lt;span&gt;Summary&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Only use heading elements where it is appropriate to do so.&lt;/p&gt;
&lt;p&gt;In essence, proper heading order:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Improves accessibility, making web pages easier to navigate.&lt;/li&gt;
&lt;li&gt;Enhances Search Engine Optimisation (SEO) because page content and structure is easy for bots to digest.&lt;/li&gt;
&lt;li&gt;Makes your website more intuitive to use.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;strong&gt;Key takeaway:&lt;/strong&gt; Always use headings in a logical order (&lt;code&gt;&amp;lt;h1&amp;gt;&lt;/code&gt; to &lt;code&gt;&amp;lt;h6&amp;gt;&lt;/code&gt;) to create a clear and accessible structure for your web pages.&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>How to ask for help (and actually get it!)</title>
		<link href="https://fedmentor.dev/posts/help-me-help-you/"/>
		<updated>2024-12-26T00:00:00Z</updated>
		<id>https://fedmentor.dev/posts/help-me-help-you/</id>
		<content type="html">&lt;h2 id=&quot;1-set-up-a-repo-and-deploy-early&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/help-me-help-you/#1-set-up-a-repo-and-deploy-early&quot;&gt;&lt;span&gt;1. Set up a repo and deploy early&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Git version control is key to success anyway, so get into this habit now if you don&#39;t alreay do this as a first step in every project!&lt;/p&gt;
&lt;p&gt;Having a fresh git repository set up from the start will help you to get help quickly. Committing regularly not only tracks your progress but also &lt;strong&gt;allows you to easily share your code with others&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;As well as the code repository link, we need to &lt;strong&gt;see&lt;/strong&gt; the result. Show, don&#39;t tell. Deploy your work (even a basic, unfinished version) to a live environment — like Netlify or Vercel (or even Github Pages for simple projects). This gives your mentor a clear picture of the issue and allows them to interact directly with your code in the browser.&lt;/p&gt;
&lt;h2 id=&quot;2-share-links-not-screenshots&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/help-me-help-you/#2-share-links-not-screenshots&quot;&gt;&lt;span&gt;2. Share links, not screenshots&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Code is readable, but screenshots, photos and videos are usually not. Instead of sharing screenshots of your code, just provide those links to your repository and deployed version up front!&lt;/p&gt;
&lt;p&gt;Context matters, and often we need to see more of it than you think. Being able to see how files are structured in the project, to check a completely different file to what you expect, or to inspect in browser is often essential. And for some issues — like styling problems — it is simply FAR quicker to debug in browser.&lt;/p&gt;
&lt;p&gt;Provide both links, so we can find the information we need quickly and efficiently to be able to help you.&lt;/p&gt;
&lt;aside class=&quot;c-aside c-aside--info [ relative text-body ]&quot; aria-labelledby=&quot;31c12407-0fef-4b20-b39a-12a27e1d2184&quot;&gt;
  &lt;div class=&quot;c-aside__icon [ grid place-content-center ]&quot;&gt;
    &lt;svg aria-hidden=&quot;true&quot; focusable=&quot;false&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;var(--icon-fill, var(--post-bg))&quot; stroke=&quot;var(--icon-stroke, var(--rainbow--teal))&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;[ h-full w-full ]&quot;&gt;&lt;circle cx=&quot;12&quot; cy=&quot;12&quot; r=&quot;10&quot;&gt;&lt;/circle&gt;&lt;line x1=&quot;12&quot; y1=&quot;16&quot; x2=&quot;12&quot; y2=&quot;12&quot;&gt;&lt;/line&gt;&lt;line x1=&quot;12&quot; y1=&quot;8&quot; x2=&quot;12.01&quot; y2=&quot;8&quot;&gt;&lt;/line&gt;&lt;/svg&gt;
  &lt;/div&gt;
  &lt;div class=&quot;c-aside__content flow&quot;&gt;&lt;strong id=&quot;31c12407-0fef-4b20-b39a-12a27e1d2184&quot; class=&quot;c-aside__title [  block font-heading leading-tight no-underline uppercase tracking-wide text-sm ]&quot;&gt;Quick Note&amp;hellip;&lt;/strong&gt;&lt;div class=&quot;flow&quot;&gt;&lt;p&gt;&lt;abbr class=&quot;[ no-underline undefined ]&quot; title=&quot; emoji&quot;&gt;⭐️&lt;/abbr&gt; When asking for &lt;strong&gt;general feedback&lt;/strong&gt; on a FrontEnd Mentor project, it&#39;s better to simply share the submitted solution link from &lt;a href=&quot;http://frontendmentor.io/&quot;&gt;FrontEndMentor.io&lt;/a&gt; instead of separate links to the repo and live version.&lt;/p&gt;
&lt;p&gt;Both of those links are on that page anyway, but it has the added benefit of the desktop comparison tool and offers a centralised place for us to leave lasting feedback that you&#39;ll be able to find later.&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;/aside&gt;
&lt;h2 id=&quot;3-be-specific&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/help-me-help-you/#3-be-specific&quot;&gt;&lt;span&gt;3. Be specific!&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Saying things like: &amp;quot;It&#39;s not working&amp;quot; just isn&#39;t helpful. Clearly articulate the problem, like &amp;quot;My button isn&#39;t changing color on hover&amp;quot; or &amp;quot;I&#39;m seeing a horizontal scrollbar unexpectedly&amp;quot;.&lt;/p&gt;
&lt;p&gt;Try to explain how you&#39;ve already tried to solve the problem, what isn&#39;t working as you expected it to, or any steps you&#39;ve followed along with what happened as a result.&lt;/p&gt;
&lt;p&gt;For example, this is a great &lt;em&gt;start&lt;/em&gt;: &amp;quot;The form is not submitting correctly. I&#39;m getting an error in the console&amp;quot;. But we need more information than that. If you&#39;re encountering errors, &lt;strong&gt;copy and paste the exact error messages&lt;/strong&gt; so we can see what you see.&lt;/p&gt;
&lt;p&gt;Similarly, if you are encountering problems deploying, list out every command you&#39;ve done, in order and include what the output was in the console each time. In these cases you can take screenshots of the console, but it helps to write out specifics of any errors.&lt;/p&gt;
&lt;h2 id=&quot;4-visual-aids-can-help&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/help-me-help-you/#4-visual-aids-can-help&quot;&gt;&lt;span&gt;4. Visual aids can help&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;With some queries, some extra information or context can really help.&lt;/p&gt;
&lt;p&gt;For example, if your question relates to design, include sketches, mockups, or links to those designs.&lt;/p&gt;
&lt;p&gt;If we need specific images or extra information to understand your issue, don&#39;t hesitate to provide them! Just try to make sure they are clear and have relevant parts &lt;mark&gt;highlighted&lt;/mark&gt; where necessary.&lt;/p&gt;
&lt;h2 id=&quot;5-put-yourself-in-a-mentor-s-shoes&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/help-me-help-you/#5-put-yourself-in-a-mentor-s-shoes&quot;&gt;&lt;span&gt;5. Put yourself in a mentor&#39;s shoes&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Remember that locker-room scene from Jerry Maguire when he yells &amp;quot;Help ME help YOU&amp;quot; over and over again?&lt;/p&gt;
&lt;figure class=&quot;[ flex flex-col  ]&quot;&gt;&lt;picture&gt;&lt;source type=&quot;image/webp&quot; srcset=&quot;https://fedmentor.dev/posts/help-me-help-you/help-me-help-you-600w.webp 600w&quot; sizes=&quot;(min-width: 30em) 50vw, 100vw&quot; /&gt;&lt;img alt=&quot;Still from the movie &#39;Jerry Maguire&#39; where he&#39;s looking imploringly to the camera and words overlaid say &#39;Help ME, Help YOU!&#39;&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; src=&quot;https://fedmentor.dev/posts/help-me-help-you/help-me-help-you-600w.jpeg&quot; width=&quot;600&quot; height=&quot;344&quot; /&gt;&lt;/picture&gt;&lt;/figure&gt;
&lt;p&gt;I think of this almost every day in the context of trying to help people with front end developmemt or accessibility queries. It&#39;s so frustrating for us when we can&#39;t help you because of simple steps you&#39;ve &lt;em&gt;not&lt;/em&gt; taken (like sharing code AND deployed links).&lt;/p&gt;
&lt;p&gt;Bear in mind that mentors are busy. Make it easy for us to understand your problem. Think about what information someone with &lt;strong&gt;no prior context of the problem&lt;/strong&gt; will need in order to understand and answer it.&lt;/p&gt;
&lt;p&gt;The more organised and clear you are, the quicker and easier it will be for everyone.&lt;/p&gt;
&lt;h2 id=&quot;6-embrace-all-feedback&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/help-me-help-you/#6-embrace-all-feedback&quot;&gt;&lt;span&gt;6. Embrace ALL feedback&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;When experienced professionals look at your requests for help, we bring our own expertise and will look at the problems through our own lens. Often that means we will look &lt;em&gt;beyond&lt;/em&gt; the question you&#39;ve asked.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Welcome feedback that extends beyond your initial question.&lt;/strong&gt; Mentors may identify areas for improvement you hadn&#39;t considered and that&#39;s a great thing, even if it doesn&#39;t answer the original query at all!&lt;/p&gt;
&lt;p&gt;Also, consider that sometimes the best solution may differ from what you initially envisioned. Be open to alternative approaches and suggestions.&lt;/p&gt;
&lt;h2 id=&quot;7-be-prepared-for-advice-to-step-back&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/help-me-help-you/#7-be-prepared-for-advice-to-step-back&quot;&gt;&lt;span&gt;7. Be prepared for advice to &amp;quot;Step back&amp;quot;&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Mentors may sometimes suggest revisiting earlier parts of your project, moving back to an easier challenge, or even starting all over again. This isn&#39;t meant to be discouraging and doesn&#39;t come from a desire to be overly-critical or perfectionist. It&#39;s not personal either.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;If this happens to you, please understand that mentors have your best interests at heart.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;When learners overstretch themselves, move onto projects they&#39;re not ready for, or are missing some foundational understandings, they&#39;re setting themselves up for frustration and failure.&lt;/p&gt;
&lt;p&gt;We want to help you build strong base. Unfortunately, just as with phyisical building construction, sometimes that means digging up what&#39;s there and re-laying those foundations!&lt;/p&gt;
&lt;p&gt;It feels horrible to be told you need to go back a step (or several), but it&#39;s worth it in the long run, trust me. Once those foundations are solid and those missing pieces are in place, you&#39;ll start to make much faster progress with your learning.&lt;/p&gt;
&lt;h2 id=&quot;8-understand-the-issue-dump&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/help-me-help-you/#8-understand-the-issue-dump&quot;&gt;&lt;span&gt;8. Understand the &amp;quot;Issue Dump&amp;quot;&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;I do this a lot. My feedback style is generally a bulleted list of problems or potential improvements I can spot in someone&#39;s front end code. It may come across as abrubt sometimes, but this is simply &lt;strong&gt;efficiency in action&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;When a mentor lists out multiple issues, it&#39;s an effort to help you efficiently address potential problems upfront.&lt;/p&gt;
&lt;p&gt;There isn&#39;t often time for long conversations, calls or videos, although I will always try and answer follow up queries if things are unclear.&lt;/p&gt;
&lt;p&gt;It&#39;s also good to get used to this while you&#39;re learning... because once you&#39;re on the job you will encounter long bug lists and comments on your pull requests regularly!&lt;/p&gt;
&lt;h2 id=&quot;9-leverage-the-frontend-mentor-discord-server&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/help-me-help-you/#9-leverage-the-frontend-mentor-discord-server&quot;&gt;&lt;span&gt;9. Leverage the Frontend Mentor Discord server&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The &lt;a href=&quot;https://discord.gg/UAfh3qzhYb&quot;&gt;Frontend Mentor Discord server&lt;/a&gt; is a valuable resource for anyone learning front end development.&lt;/p&gt;
&lt;p&gt;Just make sure you use the appropriate channels (like &lt;code&gt;#🤔-help&lt;/code&gt; for questions or &lt;code&gt;#🦄-random&lt;/code&gt; for random chat!) and follow the server rules.&lt;/p&gt;
&lt;p&gt;It&#39;s a very active community. There are loads of questions already answered and feedback you can search through. And there are lots of talented people on hand to help you learn.&lt;/p&gt;
&lt;h2 id=&quot;10-there-are-no-stupid-questions&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/help-me-help-you/#10-there-are-no-stupid-questions&quot;&gt;&lt;span&gt;10. There are NO stupid questions&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Don&#39;t be scared to ask!&lt;/p&gt;
&lt;p&gt;I&#39;ll add: Don&#39;t be down on yourself, don&#39;t call yourself a &amp;quot;noob&amp;quot; and don&#39;t apologise for asking more questions. We&#39;ve &lt;em&gt;all&lt;/em&gt; been there. That&#39;s how we learn — by asking!&lt;/p&gt;
&lt;p&gt;Everyone is on their own journey, and everyone has their own strengths. Even after decades, I still learn new things every day.  I may be an expert in some areas but there are plenty of others where I am woefully ignorant.&lt;/p&gt;
&lt;p&gt;Remember that we&#39;re all learners, even experienced senior developes. Every one of us writes bad code or builds inaccessible stuff sometimes and looks back on it horrified later on. The point is, &lt;strong&gt;we learn, we improve, we grow.&lt;/strong&gt; There is nothing remotely shameful about that.&lt;/p&gt;
&lt;p&gt;Never delete solutions after receiving feedback or feel ashamed of making mistakes, no matter how many there are. You&#39;ll want that work and that feedback to look back on later and celebrate how far you&#39;ve come.&lt;/p&gt;
&lt;p&gt;Ask. Learn. Refactor. Ask again...&lt;/p&gt;
&lt;h2 id=&quot;summary&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/help-me-help-you/#summary&quot;&gt;&lt;span&gt;Summary&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;My top 10 tips to be a good mentee and get help with front end are:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Set up a repo and deploy early&lt;/li&gt;
&lt;li&gt;Share links, not screenshots&lt;/li&gt;
&lt;li&gt;Be specific&lt;/li&gt;
&lt;li&gt;Visual aids can help, if needed&lt;/li&gt;
&lt;li&gt;Put yourself in a mentor&#39;s shoes:&lt;/li&gt;
&lt;li&gt;Embrace ALL feedback&lt;/li&gt;
&lt;li&gt;Be prepared for advice to &amp;quot;Step back&amp;quot;&lt;/li&gt;
&lt;li&gt;Understand the &amp;quot;Issue Dump&amp;quot;&lt;/li&gt;
&lt;li&gt;Leverage the Frontend Mentor Discord server&lt;/li&gt;
&lt;li&gt;There are NO stupid questions&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;By following these tips, you&#39;ll become a more effective learner and be able to access help more quickly when you need it.&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Join me for free lunch &amp; learn sessions on digital accessibility!</title>
		<link href="https://fedmentor.dev/posts/a11y-talks-2024/"/>
		<updated>2024-09-07T00:00:00Z</updated>
		<id>https://fedmentor.dev/posts/a11y-talks-2024/</id>
		<content type="html">&lt;p&gt;Although I&#39;m still actively mentoring Front End Developers (FEDs) as much as I can, my real passion has always been &lt;strong&gt;inclusion&lt;/strong&gt; and accessibility. So when some opportunities to deliver accessibility-related online talks came my way through my work at &lt;a href=&quot;https://www.nomensa.com/services/web-accessibility/&quot;&gt;Nomensa&lt;/a&gt;, I jumped at the chance!&lt;/p&gt;
&lt;p&gt;I&#39;ve delivered training sessions before and done talks at tech-focused events in the past, but these sessions have rarely been open to the public... until now.&lt;/p&gt;
&lt;p&gt;A brilliant organisation that delivers accessibility apprenticeships — &lt;a href=&quot;https://purplebeard.co.uk/&quot;&gt;Purple Beard&lt;/a&gt; — is hosting a series of free monthly &amp;quot;lunch and learn&amp;quot; online sessions and I&#39;ll be delivering the next two.&lt;/p&gt;
&lt;p&gt;You are welcome to join!&lt;/p&gt;
&lt;hr /&gt;
&lt;h2 id=&quot;emerging-trends-in-digital-accessibility&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/a11y-talks-2024/#emerging-trends-in-digital-accessibility&quot;&gt;&lt;span&gt;Emerging trends in digital accessibility&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;&lt;abbr class=&quot;[ no-underline undefined ]&quot; title=&quot;Date: emoji&quot;&gt;🗓️&lt;/abbr&gt; &lt;strong&gt;Tuesday, 10th September 2024 at 12.30pm-2pm (BST time)&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Let&#39;s look at the GOOD, the BAD and the UGLY in recent trends! In this session we explore the current state of digital accessibility, examining both promising advancements and persistent challenges. We&#39;ll look at the role of AI in accessibility testing, design and development, and learn about some best practices and pitfalls to avoid.&lt;/p&gt;
&lt;div class=&quot;c-iframe c-iframe--youtube&quot;&gt;&lt;iframe class=&quot;c-iframe__iframe [ w-full ]&quot; src=&quot;https://www.youtube-nocookie.com/embed/Y_U_zFYv6xw&quot; title=&quot;YouTube video player for Emerging Trends in Digital Accessibility (2024)&quot; frameborder=&quot;0&quot; allowfullscreen=&quot;&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;p class=&quot;print-only&quot;&gt;
    &lt;a href=&quot;https://www.youtu.be/Y_U_zFYv6xw&quot;&gt;Youtube video: Emerging Trends in Digital Accessibility (2024)&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Let me know what you think of the session. I also sent around these links to attendees afterwards, based off the questions we had at the end:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://www.w3.org/TR/wcag-3.0/&quot;&gt;WCAG 3.0 Guide&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://www.w3.org/WAI/ARIA/apg/&quot;&gt;ARIA Authoring Practices Guide&lt;/a&gt; and &lt;a href=&quot;https://www.w3.org/TR/2017/REC-wai-aria-1.1-20171214/&quot;&gt;ARIA spec&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Maturity Models &amp;amp; Accessibility Assessments:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://www.w3.org/TR/maturity-model/&quot;&gt;W3C Accessibility Maturity Model&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;“Quick” scorecards: &lt;a href=&quot;https://www.nomensa.com/aa/&quot;&gt;Nomensa Accessibility Assessment Tool&lt;/a&gt; and &lt;a href=&quot;https://www.hassellinclusion.com/accessibility-maturity-scorecard/&quot;&gt;Hassell inclusion&#39;s maturity scorecard&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;hr /&gt;
&lt;h2 id=&quot;how-to-identify-issues-and-prioritise-an-accessibility-backlog&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/a11y-talks-2024/#how-to-identify-issues-and-prioritise-an-accessibility-backlog&quot;&gt;&lt;span&gt;How to identify issues and prioritise an accessibility backlog&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;&lt;abbr class=&quot;[ no-underline undefined ]&quot; title=&quot;Date: emoji&quot;&gt;🗓️&lt;/abbr&gt; &lt;strong&gt;Tuesday, 8th October 2024 at 12.30pm-2pm (BST time)&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Learn how to effectively tackle accessibility issues by understanding their impact and complexity. Discover practical methods to identify, categorise and assign actions to different teams. Leave with actionable tips to run a workshop exercise and create a clear roadmap for improving digital accessibility.&lt;/p&gt;
&lt;div class=&quot;c-iframe c-iframe--youtube&quot;&gt;&lt;iframe class=&quot;c-iframe__iframe [ w-full ]&quot; src=&quot;https://www.youtube-nocookie.com/embed/P-Hon_3Nxxg&quot; title=&quot;YouTube video player for Not all issues are created equal - How to prioritise an accessibility backlog (2024)&quot; frameborder=&quot;0&quot; allowfullscreen=&quot;&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;p class=&quot;print-only&quot;&gt;
    &lt;a href=&quot;https://www.youtu.be/P-Hon_3Nxxg&quot;&gt;Youtube video: Not all issues are created equal - How to prioritise an accessibility backlog (2024)&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;I hope you find the session beneficial. Let me know if you need help building an accessibility backlog that&#39;s ordered by priority.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2 id=&quot;more-lunch-and-learns&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/a11y-talks-2024/#more-lunch-and-learns&quot;&gt;&lt;span&gt;More &amp;quot;lunch and learns&amp;quot;&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;I am really pleased to be connecting more with Purple Beard. If you&#39;re interested in a career in accessibility where you can help break down barriers and build up inclusion, you really should check them out!&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://www.linkedin.com/school/purplebeardtraining/&quot;&gt;Follow Purple Beard training on LinkedIn&lt;/a&gt; to get notified when the Zoom registration opens for future sessions.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2 id=&quot;speaking-requests&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/a11y-talks-2024/#speaking-requests&quot;&gt;&lt;span&gt;Speaking requests&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;I am always happy to consider new speaking engagements.&lt;/p&gt;
&lt;p&gt;You can either request this via &lt;a href=&quot;https://www.nomensa.com/services/web-accessibility/&quot;&gt;Nomensa&lt;/a&gt;, where we have a whole team of experienced consultants ready to share expertise as well as myself, or &lt;a href=&quot;https://fedmentor.dev/posts/a11y-talks-2024/grace@fedmentor.dev&quot;&gt;contact me directly&lt;/a&gt; to discuss.&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Let&#39;s build an accessible disclosure (show/hide accordion)</title>
		<link href="https://fedmentor.dev/posts/disclosure-ui/"/>
		<updated>2023-08-12T00:00:00Z</updated>
		<id>https://fedmentor.dev/posts/disclosure-ui/</id>
		<content type="html">&lt;p&gt;In this guide, we&#39;ll explore how to create an &lt;mark&gt;accessible&lt;/mark&gt; pattern for expandable content.&lt;/p&gt;
&lt;p&gt;By the end, you&#39;ll have a solid pattern in your pocket you can adapt for accordions, mobile navigation toggles (often called &#39;burger&#39; menus) and any other components that reveal content following user interaction. The pattern I&#39;m teaching should work for all users, no matter what modality they&#39;re using (keyboard, screen reader, switch control, voice control or any others).&lt;/p&gt;
&lt;p&gt;&lt;abbr class=&quot;[ no-underline undefined ]&quot; title=&quot;Idea emoji&quot;&gt;💡&lt;/abbr&gt; I&#39;ll do separate posts specifically looking at accordions and mobile navigation, as there is some extra &#39;nice to have&#39; functionality you may want in those!&lt;/p&gt;
&lt;p&gt;Let&#39;s get started!&lt;/p&gt;
&lt;h2 id=&quot;accessibility-a11y-essentials&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/disclosure-ui/#accessibility-a11y-essentials&quot;&gt;&lt;span&gt;Accessibility (A11y) Essentials&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;It&#39;s really important to:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;open disclosures with a button &lt;strong&gt;click&lt;/strong&gt; (not hover or mouseover)&lt;/li&gt;
&lt;li&gt;use &lt;strong&gt;&lt;code&gt;aria-expanded&lt;/code&gt;&lt;/strong&gt; to communicate state to assistive tech&lt;/li&gt;
&lt;li&gt;use &lt;strong&gt;&lt;code&gt;aria-controls&lt;/code&gt;&lt;/strong&gt; to programmatically link buttons with the content they&#39;re controlling for the JAWS screen reader&lt;/li&gt;
&lt;li&gt;give the button an &lt;strong&gt;accessible name&lt;/strong&gt; (usually with child content, although it can be done with &lt;code&gt;aria-label&lt;/code&gt;)&lt;/li&gt;
&lt;li&gt;Test any transitions or animations with assistive technologies&lt;/li&gt;
&lt;li&gt;Turn off or reduce animations for those who prefer reduced motion&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;html-structure&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/disclosure-ui/#html-structure&quot;&gt;&lt;span&gt;HTML Structure&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Start by setting up your HTML structure with appropriate meaningful elements. Disclosures should always be triggered by a &lt;strong&gt;button click&lt;/strong&gt;, which reveals content within a sibling element, such as a div.&lt;/p&gt;
&lt;p&gt;The button must have an &lt;a href=&quot;https://www.w3.org/WAI/ARIA/apg/practices/names-and-descriptions/&quot;&gt;accessible name&lt;/a&gt;, which we&#39;ll do by placing some text inside the button.&lt;/p&gt;
&lt;p&gt;Using &lt;code&gt;aria-expanded&lt;/code&gt; on the button is also essential. This is what will communicate &#39;state&#39; to screen readers, announcing the button as something like &amp;quot;Button, Expandable, Collapsed&amp;quot; or &amp;quot;Button, Expandable, Expanded&amp;quot;.&lt;/p&gt;
&lt;p&gt;Optionally, it&#39;s good to also include &lt;code&gt;aria-controls&lt;/code&gt;, which will point to the unique ID of the content being toggled. This isn&#39;t used by all screen readers, but is used by one called &#39;JAWS&#39;.&lt;/p&gt;
&lt;p&gt;Lastly, we will want to give the button an icon to help people understand that this will trigger some expanding content. Note, this is decorative so should be hidden from the accessibility tree.&lt;/p&gt;
&lt;p&gt;Here&#39;s what this HTML looks like:&lt;/p&gt;
&lt;pre class=&quot;language-html&quot; tabindex=&quot;0&quot; data-language=&quot;html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;disclosure js-disclosure&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token attr-name&quot;&gt;aria-expanded&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;false&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;disclosure__button js-disclosure-btn&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token attr-name&quot;&gt;aria-controls&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;content&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- Accessible name goes here--&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    Disclosure trigger&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- An icon to indicate this is a disclosure --&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;svg&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;      &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;disclosure__icon&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;      &lt;span class=&quot;token attr-name&quot;&gt;aria-hidden&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;true&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;      &lt;span class=&quot;token attr-name&quot;&gt;focusable&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;false&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;      &lt;span class=&quot;token attr-name&quot;&gt;xmlns&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;http://www.w3.org/2000/svg&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token attr-name&quot;&gt;viewBox&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;0 0 10 6&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;polygon&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;points&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;8.97 0 5.01 3.9 1 0.03 0 1.03 4.96 6 10 1.08 8.97 0&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;polygon&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;svg&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;disclosure__content&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;content&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- Additional content goes here --&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;p&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Revealed content!&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;p&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;But, there are a few issues with this HTML:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;What happens when JavaScript (JS) fails to load or users turn it off? We will want to see all of the content&lt;/li&gt;
&lt;li&gt;If we make the content &lt;em&gt;open&lt;/em&gt; by default for no-JS users, then hidden once JS loads, it will introduce &lt;strong&gt;Cumulative Layout Shift&lt;/strong&gt; (CLS), resulting in poor site performance.&lt;/li&gt;
&lt;/ol&gt;
&lt;aside class=&quot;c-aside c-aside--alert [ relative text-body ]&quot; aria-labelledby=&quot;a39df120-f115-4920-9e81-d54e77fc0ca8&quot;&gt;
  &lt;div class=&quot;c-aside__icon [ grid place-content-center ]&quot;&gt;
    &lt;svg 2000=&quot;&quot; aria-hidden=&quot;true&quot; focusable=&quot;false xmlns=&quot; http:=&quot;&quot; www.w3.org=&quot;&quot; svg&quot;=&quot;&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;var(--icon-fill, var(--post-bg))&quot; stroke=&quot;var(--icon-stroke, var(--rainbow--teal))&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;[ h-full w-full ]&quot;&gt;&lt;polygon points=&quot;7.86 2 16.14 2 22 7.86 22 16.14 16.14 22 7.86 22 2 16.14 2 7.86 7.86 2&quot;&gt;&lt;/polygon&gt;&lt;line x1=&quot;12&quot; y1=&quot;8&quot; x2=&quot;12&quot; y2=&quot;12&quot;&gt;&lt;/line&gt;&lt;line x1=&quot;12&quot; y1=&quot;16&quot; x2=&quot;12.01&quot; y2=&quot;16&quot;&gt;&lt;/line&gt;&lt;/svg&gt;
  &lt;/div&gt;
  &lt;div class=&quot;c-aside__content flow&quot;&gt;&lt;strong id=&quot;a39df120-f115-4920-9e81-d54e77fc0ca8&quot; class=&quot;c-aside__title [  block font-heading leading-tight no-underline uppercase tracking-wide text-sm ]&quot;&gt;Progressive Enhancement&lt;/strong&gt;&lt;div class=&quot;flow&quot;&gt;&lt;p&gt;To quote &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Glossary/Progressive_Enhancement&quot;&gt;MDN&lt;/a&gt;:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Progressive enhancement is a design philosophy that provides a baseline of essential content and functionality to as many users as possible, while delivering the best possible experience only to users of the most modern browsers that can run all the required code.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;We can follow this approach and address those two issues with some additions to our baseline code...&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Add an inline &lt;code&gt;&amp;lt;style&amp;gt;&lt;/code&gt; at the top of the page that hides revealed content as the page first loads&lt;/li&gt;
&lt;li&gt;Add a custom attribute &lt;code&gt;data-state&lt;/code&gt; that updates from &amp;quot;no-js&amp;quot; to &amp;quot;ready&amp;quot; once JS successfully loads&lt;/li&gt;
&lt;li&gt;Make the button &lt;code&gt;disabled&lt;/code&gt; by default and give it a title explaining that JS needs to load for it to function&lt;/li&gt;
&lt;li&gt;Add an inline &lt;code&gt;&amp;lt;noscript&amp;gt;&lt;/code&gt; at the end of the page that reveals all content if there is no JS&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;We&#39;ll also update these properties in the JS file later.&lt;/p&gt;
&lt;p&gt;These simple changes should set us up well for a performant progressively-enhanced version of the disclosure.&lt;/p&gt;
&lt;pre class=&quot;language-html&quot; tabindex=&quot;0&quot; data-language=&quot;html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;style&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token style&quot;&gt;&lt;span class=&quot;token language-css&quot;&gt;&lt;br /&gt;  &lt;span class=&quot;token comment&quot;&gt;/**&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;   * Hide the menu during the &#39;no-js&#39; state&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;   * to solve Cumulative Layout Shift.&lt;/span&gt;&lt;br /&gt;   */&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token selector&quot;&gt;[data-state=&#39;no-js&#39;] .disclosure__content&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token property&quot;&gt;display&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; none&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;style&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;disclosure js-disclosure&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;data-state&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;no-js&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token attr-name&quot;&gt;aria-expanded&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;false&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;disclosure__button js-disclosure-btn&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token attr-name&quot;&gt;aria-controls&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;content&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token attr-name&quot;&gt;disabled&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token attr-name&quot;&gt;title&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;This button becomes functional once JavaScript is active&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- Accessible name goes here--&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    Disclosure trigger&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- An icon to indicate this is a disclosure --&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;svg&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;      &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;disclosure__icon&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;      &lt;span class=&quot;token attr-name&quot;&gt;aria-hidden&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;true&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;      &lt;span class=&quot;token attr-name&quot;&gt;focusable&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;false&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;      &lt;span class=&quot;token attr-name&quot;&gt;xmlns&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;http://www.w3.org/2000/svg&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;viewBox&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;0 0 10 6&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;...&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;svg&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;disclosure__content&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;content&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- Additional content goes here --&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;p&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Revealed content!&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;p&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;noscript&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- Show all content if no JS --&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;style&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token style&quot;&gt;&lt;span class=&quot;token language-css&quot;&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token selector&quot;&gt;[data-state=&#39;no-js&#39;] .disclosure__content&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;      &lt;span class=&quot;token property&quot;&gt;display&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; block&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;style&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;noscript&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;abbr class=&quot;[ no-underline undefined ]&quot; title=&quot;unknown emoji&quot;&gt;🌟&lt;/abbr&gt; Thanks to &lt;a href=&quot;https://cloudfour.com/thinks/removing-layout-shift-from-a-progressively-enhanced-burger-menu/#noscript-element-strategy&quot; target=&quot;_blank&quot;&gt;Gerardo Rodriguez&lt;/a&gt; for the noscript CLS fix applied in this demo&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;/aside&gt;
&lt;h2 id=&quot;styling-with-a11y-in-mind&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/disclosure-ui/#styling-with-a11y-in-mind&quot;&gt;&lt;span&gt;Styling with a11y in mind&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Write whatever styles you like to make your disclosure component look nice. The important point to note is that we&#39;re &lt;strong&gt;using the aria-expanded attribute as the hook to trigger content visibility changes&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;I prefer this approach over toggling classes or data-attributes because it makes it much easier to spot accessibility bugs! If aria-expanded isn&#39;t toggling correctly, the &lt;abbr title=&quot;User Interface&quot;&gt;UI&lt;/abbr&gt; will visibly break, as nothing will be revealed, forcing you to fix the root cause (that aria-attribute&#39;s state).&lt;/p&gt;
&lt;pre class=&quot;language-scss&quot; tabindex=&quot;0&quot; data-language=&quot;scss&quot;&gt;&lt;code class=&quot;language-scss&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// Some basic styles for the demo&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token selector&quot;&gt;.disclosure &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token property&quot;&gt;border&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 1px solid #ccc&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token property&quot;&gt;padding&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 10px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token property&quot;&gt;max-width&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 50rem&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token selector&quot;&gt;.disclosure__content &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token property&quot;&gt;margin-top&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 10px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// Size the icon proportionally to the button&#39;s font size&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token selector&quot;&gt;.disclosure__icon &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token property&quot;&gt;height&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 1em&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token property&quot;&gt;width&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 1em&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token property&quot;&gt;fill&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; currentcolor&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token property&quot;&gt;transition&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; transform 0.3s ease-out&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token selector&quot;&gt;.disclosure__button &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token property&quot;&gt;background-color&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; #222&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token property&quot;&gt;padding&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 0.25em 0.5em&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token property&quot;&gt;color&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; #fff&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token property&quot;&gt;border&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 0&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token property&quot;&gt;cursor&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; pointer&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token comment&quot;&gt;// align the icon correctly:&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token property&quot;&gt;display&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; flex&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token property&quot;&gt;align-items&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; center&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token property&quot;&gt;justify-content&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; space-between&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token property&quot;&gt;gap&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 1ch&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token comment&quot;&gt;// manage keyboard focus&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token selector&quot;&gt;&lt;span class=&quot;token parent important&quot;&gt;&amp;amp;&lt;/span&gt;:focus-visible &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token property&quot;&gt;outline&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; solid orange 3px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token property&quot;&gt;outline-offset&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 3px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token comment&quot;&gt;// ! Important functionality hooks&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token selector&quot;&gt;&lt;span class=&quot;token parent important&quot;&gt;&amp;amp;&lt;/span&gt;[aria-expanded=&quot;false&quot;] &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token selector&quot;&gt;+ .disclosure__content &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;      &lt;span class=&quot;token property&quot;&gt;display&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; none&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token selector&quot;&gt;&lt;span class=&quot;token parent important&quot;&gt;&amp;amp;&lt;/span&gt;[aria-expanded=&quot;true&quot;] &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token selector&quot;&gt;+ .disclosure__content &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;      &lt;span class=&quot;token property&quot;&gt;display&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; block&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token selector&quot;&gt;.disclosure__icon &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;      &lt;span class=&quot;token property&quot;&gt;transform&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;rotate&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;-180deg&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The above should be fairly self-explanatory. If the button&#39;s aria-expanded state is set to &amp;quot;true&amp;quot; we want to reveal the content. If it&#39;s false, we want to hide the content.&lt;/p&gt;
&lt;aside class=&quot;c-aside c-aside--info [ relative text-body ]&quot; aria-labelledby=&quot;240109c8-9c81-4daa-809d-358936a22625&quot;&gt;
  &lt;div class=&quot;c-aside__icon [ grid place-content-center ]&quot;&gt;
    &lt;svg aria-hidden=&quot;true&quot; focusable=&quot;false&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;var(--icon-fill, var(--post-bg))&quot; stroke=&quot;var(--icon-stroke, var(--rainbow--teal))&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;[ h-full w-full ]&quot;&gt;&lt;circle cx=&quot;12&quot; cy=&quot;12&quot; r=&quot;10&quot;&gt;&lt;/circle&gt;&lt;line x1=&quot;12&quot; y1=&quot;16&quot; x2=&quot;12&quot; y2=&quot;12&quot;&gt;&lt;/line&gt;&lt;line x1=&quot;12&quot; y1=&quot;8&quot; x2=&quot;12.01&quot; y2=&quot;8&quot;&gt;&lt;/line&gt;&lt;/svg&gt;
  &lt;/div&gt;
  &lt;div class=&quot;c-aside__content flow&quot;&gt;&lt;strong id=&quot;240109c8-9c81-4daa-809d-358936a22625&quot; class=&quot;c-aside__title [  block font-heading leading-tight no-underline uppercase tracking-wide text-sm ]&quot;&gt;Quick Note&amp;hellip;&lt;/strong&gt;&lt;div class=&quot;flow&quot;&gt;&lt;p&gt;Be aware if you want to add fancy animations, they will need to be &lt;strong&gt;performant&lt;/strong&gt; (e.g. using transform not height) and may need to be disabled for users who prefer-reduced-motion.&lt;/p&gt;
&lt;p&gt;The CSS display property cannot be animated, so opt for properties like opacity and transform instead.&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;/aside&gt;
&lt;h2 id=&quot;add-the-javascript&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/disclosure-ui/#add-the-javascript&quot;&gt;&lt;span&gt;Add the JavaScript&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;When adding JavaScript it&#39;s helpful to break down what you&#39;re trying to do into manageable steps. Here we need to&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;find all disclosure components on the page&lt;/li&gt;
&lt;li&gt;update the custom &lt;code&gt;data-state&lt;/code&gt; attribute now that JS has loaded&lt;/li&gt;
&lt;li&gt;remove the &lt;code&gt;disabled&lt;/code&gt; and &lt;code&gt;title&lt;/code&gt; attributes from the disclosure buttons&lt;/li&gt;
&lt;li&gt;listen for clicks on those buttons&lt;/li&gt;
&lt;li&gt;toggle the &lt;code&gt;aria-expanded&lt;/code&gt; boolean values on any disclosure button as it is clicked&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Remember, all we are doing in JS is toggling that aria attribute&#39;s value so that the state is correctly announced to assistive technology and the styling can use that state. We shouldn&#39;t be setting inline styles or toggling anything else. Let your CSS handle the content visibility changes as a styling concern.&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot; tabindex=&quot;0&quot; data-language=&quot;javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// disclosure.js&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// get all disclosure components on the page&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; disclosures &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;querySelectorAll&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;.js-disclosure&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// Simple toggle function&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;toggleDisclosure&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; isExpanded &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getAttribute&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;aria-expanded&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;===&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;true&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token keyword&quot;&gt;this&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;setAttribute&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;aria-expanded&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;!&lt;/span&gt;isExpanded&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;init&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token comment&quot;&gt;// early return if no disclosures present on page&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token keyword&quot;&gt;if&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token operator&quot;&gt;!&lt;/span&gt;disclosures&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;length&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token keyword&quot;&gt;return&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token comment&quot;&gt;// update state now JS has loaded&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  disclosures&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;forEach&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;component&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    component&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;dataset&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;state &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;ready&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; disclosureButtons &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; component&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;querySelectorAll&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;.js-disclosure-btn&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    disclosureButtons&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;forEach&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token parameter&quot;&gt;btn&lt;/span&gt; &lt;span class=&quot;token operator&quot;&gt;=&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;      &lt;span class=&quot;token comment&quot;&gt;// initialise button attributes now JS has loaded&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;      btn&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;removeAttribute&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;title&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;      btn&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;removeAttribute&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;disabled&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;      &lt;span class=&quot;token comment&quot;&gt;// listen for clicks&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;      btn&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;addEventListener&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;click&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; toggleDisclosure&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// export as JS module&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// NOTE: Optional! Call init() instead if not using modules&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;export&lt;/span&gt; &lt;span class=&quot;token keyword&quot;&gt;default&lt;/span&gt; init&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;the-html-only-disclosure&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/disclosure-ui/#the-html-only-disclosure&quot;&gt;&lt;span&gt;The HTML-only Disclosure&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;You may be thinking, &amp;quot;Why can&#39;t I use the details element instead&amp;quot; for all disclosures? You &lt;em&gt;could&lt;/em&gt; do this, but I first recommend you read more about it and make sure it is appropriate for what you are trying to build.&lt;/p&gt;
&lt;p&gt;You can read more about &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/HTML/Element/details&quot;&gt;the details disclosure element on MDN&lt;/a&gt;. And more about its inconsistent browser and assistive technology behaviour thanks to &lt;a href=&quot;https://www.scottohara.me/blog/2022/09/12/details-summary.html&quot;&gt;Scott O&#39;Hara&lt;/a&gt; and &lt;a href=&quot;https://adrianroselli.com/2019/04/details-summary-are-not-insert-control-here.html&quot;&gt;Adrian Roselli&lt;/a&gt;.&lt;/p&gt;
&lt;div class=&quot;no-print&quot;&gt;
  &lt;details class=&quot;c-details&quot;&gt;
    &lt;summary class=&quot;c-details__summary [ relative bg-bar ]&quot;&gt;
      &lt;strong class=&quot;c-details__title [ font-base text-body h4 ]&quot;&gt;A note on accordions&lt;/strong&gt;
    &lt;/summary&gt;
    &lt;div class=&quot;c-details__content [ flow bg-body text-body ]&quot;&gt;&lt;p&gt;If you want to build an &lt;strong&gt;accordion component&lt;/strong&gt; specifically, Adrian Roselli has written a post about how you can adapt the details element for this purpose: &lt;a href=&quot;https://adrianroselli.com/2023/08/progressively-enhanced-html-accordion.html&quot;&gt;Progressively enhanced HTML accordion&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;mark&gt;Note, the JS in Adrian&#39;s example needs modernising&lt;/mark&gt;, as he points out in the article. At the time of writing this, his example does not &#39;toggle&#39; the accordion items either — It does not close and open one on click as I believe it should.&lt;/p&gt;
&lt;p&gt;And actually, &lt;strong&gt;I disagree that an accordion must always close the others on open&lt;/strong&gt;. That will depend on the technical requirements for which you are building. I see no problem from a usability perspective with making each accordion item open and close independently, and in fact, I &lt;em&gt;prefer&lt;/em&gt; that as a user. It gives me explicit control, it means I can read and compare two sets of revealed content at once, and it reduces unexpected scrolling / jumping around.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;See how there are many ways to approach these UI patterns?!&lt;/strong&gt; It&#39;s fine to come to your own opinions on some of these finer details, as long as you consider the options and test thoroughly.&lt;/p&gt;
&lt;/div&gt;
  &lt;/details&gt;
&lt;/div&gt;
&lt;div class=&quot;c-details print-only&quot;&gt;
  &lt;h4&gt;A note on accordions&lt;/h4&gt;
  &lt;div class=&quot;c-details__content flow&quot;&gt;&lt;p&gt;If you want to build an &lt;strong&gt;accordion component&lt;/strong&gt; specifically, Adrian Roselli has written a post about how you can adapt the details element for this purpose: &lt;a href=&quot;https://adrianroselli.com/2023/08/progressively-enhanced-html-accordion.html&quot;&gt;Progressively enhanced HTML accordion&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&lt;mark&gt;Note, the JS in Adrian&#39;s example needs modernising&lt;/mark&gt;, as he points out in the article. At the time of writing this, his example does not &#39;toggle&#39; the accordion items either — It does not close and open one on click as I believe it should.&lt;/p&gt;
&lt;p&gt;And actually, &lt;strong&gt;I disagree that an accordion must always close the others on open&lt;/strong&gt;. That will depend on the technical requirements for which you are building. I see no problem from a usability perspective with making each accordion item open and close independently, and in fact, I &lt;em&gt;prefer&lt;/em&gt; that as a user. It gives me explicit control, it means I can read and compare two sets of revealed content at once, and it reduces unexpected scrolling / jumping around.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;See how there are many ways to approach these UI patterns?!&lt;/strong&gt; It&#39;s fine to come to your own opinions on some of these finer details, as long as you consider the options and test thoroughly.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;no-print&quot;&gt;
  &lt;details class=&quot;c-details&quot;&gt;
    &lt;summary class=&quot;c-details__summary [ relative bg-bar ]&quot;&gt;
      &lt;strong class=&quot;c-details__title [ font-base text-body h4 ]&quot;&gt;A note on mobile navs&lt;/strong&gt;
    &lt;/summary&gt;
    &lt;div class=&quot;c-details__content [ flow bg-body text-body ]&quot;&gt;&lt;p&gt;&lt;abbr class=&quot;[ no-underline undefined ]&quot; title=&quot;important emoji&quot;&gt;⚠️&lt;/abbr&gt; The details element should &lt;strong&gt;not be used for mobile navigation disclosures&lt;/strong&gt;. On that point, accessibility professionals are agreed.&lt;/p&gt;
&lt;p&gt;Instead, follow a standard JS-disclosure pattern using buttons. There are various options for how to handle the default no-JS versions of mobile menus, which I&#39;m not going into here.&lt;/p&gt;
&lt;/div&gt;
  &lt;/details&gt;
&lt;/div&gt;
&lt;div class=&quot;c-details print-only&quot;&gt;
  &lt;h4&gt;A note on mobile navs&lt;/h4&gt;
  &lt;div class=&quot;c-details__content flow&quot;&gt;&lt;p&gt;&lt;abbr class=&quot;[ no-underline undefined ]&quot; title=&quot;important emoji&quot;&gt;⚠️&lt;/abbr&gt; The details element should &lt;strong&gt;not be used for mobile navigation disclosures&lt;/strong&gt;. On that point, accessibility professionals are agreed.&lt;/p&gt;
&lt;p&gt;Instead, follow a standard JS-disclosure pattern using buttons. There are various options for how to handle the default no-JS versions of mobile menus, which I&#39;m not going into here.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&quot;testing-and-refinement&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/disclosure-ui/#testing-and-refinement&quot;&gt;&lt;span&gt;Testing and Refinement&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;As with all things, I always recommend you test UI patterns as much as you can across various browsers and devices. Verify that the component functions seamlessly and is accessible to all users, including those using different user-agent and screen-reader pairings.&lt;/p&gt;
&lt;aside class=&quot;c-aside c-aside--info [ relative text-body ]&quot; aria-labelledby=&quot;ff81c766-3a4e-4a9b-a9ed-4d488ce1a189&quot;&gt;
  &lt;div class=&quot;c-aside__icon [ grid place-content-center ]&quot;&gt;
    &lt;svg aria-hidden=&quot;true&quot; focusable=&quot;false&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;var(--icon-fill, var(--post-bg))&quot; stroke=&quot;var(--icon-stroke, var(--rainbow--teal))&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;[ h-full w-full ]&quot;&gt;&lt;circle cx=&quot;12&quot; cy=&quot;12&quot; r=&quot;10&quot;&gt;&lt;/circle&gt;&lt;line x1=&quot;12&quot; y1=&quot;16&quot; x2=&quot;12&quot; y2=&quot;12&quot;&gt;&lt;/line&gt;&lt;line x1=&quot;12&quot; y1=&quot;8&quot; x2=&quot;12.01&quot; y2=&quot;8&quot;&gt;&lt;/line&gt;&lt;/svg&gt;
  &lt;/div&gt;
  &lt;div class=&quot;c-aside__content flow&quot;&gt;&lt;strong id=&quot;ff81c766-3a4e-4a9b-a9ed-4d488ce1a189&quot; class=&quot;c-aside__title [  block font-heading leading-tight no-underline uppercase tracking-wide text-sm ]&quot;&gt;Other disclosures&lt;/strong&gt;&lt;div class=&quot;flow&quot;&gt;&lt;p&gt;This post has looked at a basic aria-triggered disclosure pattern that requires Javascript to function as a disclosure. &lt;mark&gt;We haven&#39;t covered specific requirements for common UIs like accordions and mobile navigation toggles in any detail.&lt;/mark&gt;&lt;/p&gt;
&lt;p&gt;For now, be aware that some disclosure components you&#39;re asked to build &lt;em&gt;may&lt;/em&gt; have additional technical requirements, depending on the UI you&#39;re building and the desired behaviour. For example, you may need to build in arrow key functionality, may need to close other disclosures when one is opened, or may need extra JS to open and focus on one disclosure if its ID is included in the page URL.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Do some extra reading around the a11y considerations for specific components you are trying to build.&lt;/strong&gt; Then you can identify additional relevant test criteria.&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;/aside&gt;
&lt;h2 id=&quot;summary-and-demo&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/disclosure-ui/#summary-and-demo&quot;&gt;&lt;span&gt;Summary and Demo&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;I hope this guide has helped you to better understand disclosures in general, and equipped you with a decent progressively enhanced starter pattern.&lt;/p&gt;
&lt;p&gt;Here is how our end solution looks:&lt;/p&gt;
&lt;div class=&quot;c-iframe c-iframe--codepen &quot;&gt;&lt;iframe class=&quot;c-iframe__iframe [ h-full w-full ]&quot; style=&quot;--media-ratio: 3/2&quot; title=&quot;Assistive tech quiz&quot; src=&quot;https://codepen.io/grace-snow/embed/zYMQZLr?default-tab=html,result&amp;theme-id=dark&quot; frameborder=&quot;0&quot; loading=&quot;lazy&quot; allowtransparency=&quot;true&quot; scrolling=&quot;no&quot; allowfullscreen=&quot;true&quot;&gt;&lt;p&gt;&lt;a href=&quot;https://codepen.io/grace-snow/pen/zYMQZLr&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;See the Pen&lt;/a&gt;&lt;/p&gt;&lt;/iframe&gt;&lt;/div&gt;
    &lt;p class=&quot;print-only&quot;&gt;
      &lt;a href=&quot;https://codepen.io/grace-snow/pen/zYMQZLr&quot;&gt;CodePen code example: Assistive tech quiz&lt;/a&gt;
    &lt;/p&gt;
&lt;p&gt;As you integrate this pattern (or others like it) into your projects, &lt;strong&gt;keep accessibility at the forefront of your mind&lt;/strong&gt; and rigorously test your work. Good luck!&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Understanding when to use padding Vs. margin in CSS</title>
		<link href="https://fedmentor.dev/posts/padding-margin/"/>
		<updated>2023-08-10T00:00:00Z</updated>
		<id>https://fedmentor.dev/posts/padding-margin/</id>
		<content type="html">&lt;p&gt;In the world of CSS, getting the spacing right is crucial for creating visually pleasing and well-structured layouts. Two fundamental properties for managing space are &lt;code&gt;padding&lt;/code&gt; and &lt;code&gt;margin&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;However, determining when to use each can be a bit confusing! In this post, we&#39;ll explore the differences between padding and margin, along with real-world examples to help you make informed decisions.&lt;/p&gt;
&lt;h2 id=&quot;the-box-model-a-quick-primer&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/padding-margin/#the-box-model-a-quick-primer&quot;&gt;&lt;span&gt;The Box Model: A Quick Primer&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Before we dive into the details, let&#39;s quickly revisit the box model concept.&lt;/p&gt;
&lt;figure class=&quot;[ flex flex-col  ]&quot;&gt;&lt;picture&gt;&lt;source type=&quot;image/webp&quot; srcset=&quot;https://fedmentor.dev/posts/padding-margin/box-model-800w.webp 800w, https://fedmentor.dev/posts/padding-margin/box-model-1200w.webp 1200w&quot; sizes=&quot;(min-width: 40rem) 50vw, 100vw&quot; /&gt;&lt;source type=&quot;image/jpeg&quot; srcset=&quot;https://fedmentor.dev/posts/padding-margin/box-model-800w.jpeg 800w, https://fedmentor.dev/posts/padding-margin/box-model-1200w.jpeg 1200w&quot; sizes=&quot;(min-width: 40rem) 50vw, 100vw&quot; /&gt;&lt;img alt=&quot;A diagram explaining the CSS box model with 4 boxes nested inside each other. Working outwards from the center they are labelled: Content, Padding, Border, Margin&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; src=&quot;https://fedmentor.dev/posts/padding-margin/box-model-800w.jpeg&quot; width=&quot;1200&quot; height=&quot;917&quot; /&gt;&lt;/picture&gt;&lt;/figure&gt;
&lt;p&gt;Each HTML element is essentially a rectangular box that encompasses content, padding, border, and margin. Understanding these components is vital for controlling spacing and layout.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Content:&lt;/strong&gt; The actual content of the element, such as text, images, or other media.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Padding:&lt;/strong&gt; The space between the content and the inner edges of the element.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Border:&lt;/strong&gt; The line that surrounds the padding and content, demarcating the element&#39;s boundaries.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Margin:&lt;/strong&gt; The space around the element, pushing other elements away.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;With this in mind, let&#39;s delve into the specifics of when to use padding and margin in your CSS.&lt;/p&gt;
&lt;h2 id=&quot;padding-space-inside-the-box&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/padding-margin/#padding-space-inside-the-box&quot;&gt;&lt;span&gt;Padding: Space Inside the Box&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Padding is for &lt;strong&gt;internal&lt;/strong&gt; spacing.&lt;/p&gt;
&lt;p&gt;Padding is the space between the content (children) of an element and its edges. It creates an internal buffer within the element, pushing the content away from the element&#39;s boundaries. Think of it as &#39;the space inside a box that stops children from hitting its edges&#39;.&lt;/p&gt;
&lt;p&gt;It&#39;s worth noting that &lt;strong&gt;padding doesn&#39;t collapse&lt;/strong&gt;. Two sibling elements each with their own padding and no border will give the illusion of double the amount of visual space because their paddings will stack up against each other (they both have &#39;internal&#39; space).&lt;/p&gt;
&lt;p&gt;Let&#39;s consider an example of a simple card component:&lt;/p&gt;
&lt;pre class=&quot;language-css&quot; tabindex=&quot;0&quot; data-language=&quot;css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token selector&quot;&gt;.card&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token comment&quot;&gt;/* Apply equal padding on all sides */&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token property&quot;&gt;padding&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 20px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In this case, the padding property adds 20 pixels of space within the &lt;code&gt;.card&lt;/code&gt; element. You can also define different values for each side:&lt;/p&gt;
&lt;pre class=&quot;language-css&quot; tabindex=&quot;0&quot; data-language=&quot;css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token selector&quot;&gt;.card&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token comment&quot;&gt;/* Apply 10px top and bottom, 20px left and right */&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token property&quot;&gt;padding&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 10px 20px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Padding doesn&#39;t need to be defined in pixels. In fact, it&#39;s often defined in &lt;strong&gt;rem&lt;/strong&gt; at a component or layout level, and occasionally in &lt;strong&gt;em&lt;/strong&gt; on elements like buttons so that the button padding can scale with the button&#39;s font size.&lt;/p&gt;
&lt;p&gt;I find it helpful to think of padding something that only belongs on boxes — on HTML elements that can have child block elements. It rarely makes sense to place padding on a paragraph, for example, because it only ever contains text and inline elements (like anchors or italics). It is not a &#39;box&#39; and has no concept of &#39;internal spacing&#39;.&lt;/p&gt;
&lt;h2 id=&quot;margin-space-outside&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/padding-margin/#margin-space-outside&quot;&gt;&lt;span&gt;Margin: Space Outside&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Margin is for &lt;strong&gt;external&lt;/strong&gt; spacing.&lt;/p&gt;
&lt;p&gt;Margin is the space &lt;em&gt;around&lt;/em&gt; an element, pushing other elements away. It defines the gap between the element and its neighbouring elements. Use margin to create space between different elements on the page.&lt;/p&gt;
&lt;p&gt;Note that &lt;strong&gt;margin collapses&lt;/strong&gt; by default. This means that when you have two sibling elements each with a margin between them, these margins will overlap each other and occupy the same space. Whichever margin is the largest will &#39;win&#39; visually.&lt;/p&gt;
&lt;p&gt;Suppose you have a list of items that you want to space out evenly:&lt;/p&gt;
&lt;pre class=&quot;language-css&quot; tabindex=&quot;0&quot; data-language=&quot;css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token selector&quot;&gt;.item&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token comment&quot;&gt;/* Add margin at the bottom of each item */&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token property&quot;&gt;margin-bottom&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 1em&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This adds a 1em gap between each &lt;code&gt;.item&lt;/code&gt; element, providing a clear visual separation.&lt;/p&gt;
&lt;p&gt;Personally, I prefer to use &lt;strong&gt;margin-top&lt;/strong&gt; in most cases.&lt;/p&gt;
&lt;p&gt;Let&#39;s say you want to add space above all items except the first one, and you want the spacing to be relative to the font size. You can achieve this by using margin-top with em units:&lt;/p&gt;
&lt;pre class=&quot;language-css&quot; tabindex=&quot;0&quot; data-language=&quot;css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token selector&quot;&gt;.item:not(:first-child)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token comment&quot;&gt;/* Add proportional margin top on all except the first item */&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token property&quot;&gt;margin-top&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 0.5em&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In this example, the &lt;code&gt;:not(:first-child)&lt;/code&gt; selector targets all &lt;code&gt;.item&lt;/code&gt; elements except the first one, and applies a margin of 0.5em on top, creating a relative spacing that adapts to the font size.&lt;/p&gt;
&lt;p&gt;This is a very common approach for &lt;em&gt;prose&lt;/em&gt; parts of a website, such as a blog article, because it creates a nice vertical rhythm, with proportional spacing above headings and paragraphs.&lt;/p&gt;
&lt;p&gt;Here is a technique colloquially known as Heydon Pickering&#39;s &lt;em&gt;&#39;lobotomised owl&#39;&lt;/em&gt; to add that vertical spacing (using margin) &lt;em&gt;without&lt;/em&gt; having to add a class to every child element:&lt;/p&gt;
&lt;pre class=&quot;language-css&quot; tabindex=&quot;0&quot; data-language=&quot;css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token selector&quot;&gt;.article &gt; * + *&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token comment&quot;&gt;/* Add margin top on all direct children except the first child */&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token property&quot;&gt;margin-top&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 0.5em&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;You can read more about it on &lt;a href=&quot;https://every-layout.dev/layouts/stack/&quot;&gt;Every Layout&lt;/a&gt;. Just be aware that using this approach significantly increases the CSS specificity of that selector, meaning it could be hard to override if you want one element to have a different margin-top later on.&lt;/p&gt;
&lt;h2 id=&quot;using-the-gap-property&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/padding-margin/#using-the-gap-property&quot;&gt;&lt;span&gt;Using the gap Property&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;For modern layout designs, you might consider using the gap property, which specifies the gap between grid and flex items.&lt;/p&gt;
&lt;p&gt;Unlike traditional margins, the gap property creates space between elements &lt;strong&gt;without collapsing margins&lt;/strong&gt;. It&#39;s especially useful when dealing with flexbox or grid layouts.&lt;/p&gt;
&lt;pre class=&quot;language-css&quot; tabindex=&quot;0&quot; data-language=&quot;css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token selector&quot;&gt;.container&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token property&quot;&gt;display&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; grid&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token property&quot;&gt;grid-template-columns&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;repeat&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;3&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; 1fr&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token property&quot;&gt;gap&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 1.5rem&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;/* Apply a 1.5rem (24px) gap between grid items */&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Note, if you also added &lt;code&gt;margin&lt;/code&gt; to one of this grid&#39;s children, it would create &lt;em&gt;additional&lt;/em&gt; space on top of the gap that is already there.&lt;/p&gt;
&lt;p&gt;The most common use-case for using margin on grid/flex child elements when that grid is already using gap is when you want to &#39;push&#39; a child to a specific place using &lt;code&gt;margin: auto&lt;/code&gt;. For example, if all cards in a grid need the button vertically aligned at the bottom, and content aligned to the top, you might do this:&lt;/p&gt;
&lt;pre class=&quot;language-css&quot; tabindex=&quot;0&quot; data-language=&quot;css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token selector&quot;&gt;.card-grid&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token property&quot;&gt;display&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; grid&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token property&quot;&gt;grid-template-columns&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;repeat&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;3&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; 1fr&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token property&quot;&gt;gap&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 2rem&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;/* Apply a 2rem (32px) gap between grid items */&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token selector&quot;&gt;.card-grid__card&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token property&quot;&gt;display&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; flex&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token property&quot;&gt;flex-direction&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; column&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token property&quot;&gt;gap&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 1.5rem&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;/* Apply a 1.5rem (24px) gap between card children */&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token selector&quot;&gt;.card-grid__btn&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token property&quot;&gt;margin-top&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; auto&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;/* Push all content up and button down */&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Now, no matter if some cards have longer titles or paragraphs inside, the buttons will always be aligned at the bottom of every card.&lt;/p&gt;
&lt;h2 id=&quot;knowing-when-to-choose&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/padding-margin/#knowing-when-to-choose&quot;&gt;&lt;span&gt;Knowing When to Choose&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Here&#39;s a simple rule of thumb:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;Use Padding:&lt;/strong&gt; When you want to control the space &lt;em&gt;inside&lt;/em&gt; an element, such as adjusting the spacing between a box and the text or other content inside it.&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;Use Margin:&lt;/strong&gt; When you want to create space &lt;em&gt;between&lt;/em&gt; elements, ensuring proper spacing and layout separation.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;combining-padding-margin-and-gap&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/padding-margin/#combining-padding-margin-and-gap&quot;&gt;&lt;span&gt;Combining Padding, Margin and Gap&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;In some cases, you might use both properties together to achieve the desired layout.&lt;/p&gt;
&lt;p&gt;Let&#39;s continue with the card grid example given above, and see how we can use all three properties to create a harmonious layout:&lt;/p&gt;
&lt;pre class=&quot;language-css&quot; tabindex=&quot;0&quot; data-language=&quot;css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;/* Example: Image Cards with Padding, Margin, and Gap in a Grid */&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token selector&quot;&gt;.card-grid&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token property&quot;&gt;display&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; grid&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token property&quot;&gt;grid-template-columns&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;repeat&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;auto-fit&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;minmax&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;17rem&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt;1fr&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token property&quot;&gt;gap&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 30px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;/* Apply gap between cards */&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token selector&quot;&gt;.card&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token property&quot;&gt;padding&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 1rem&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;/* Add padding around the content */&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token property&quot;&gt;background-color&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; #f5f5f5&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token property&quot;&gt;border-radius&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 10px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;/* Add rounded corners for style */&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token property&quot;&gt;box-shadow&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 0 2px 4px &lt;span class=&quot;token function&quot;&gt;rgba&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;0&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; 0&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; 0&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; 0.1&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;/* Add subtle shadow */&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token selector&quot;&gt;.card img&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token property&quot;&gt;margin-bottom&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 15px&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;/* Space between image and text */&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token selector&quot;&gt;.card p&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token property&quot;&gt;margin&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 0&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;/* Reset margin for the paragraph */&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;In this example,&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the gap on the grid creates space between each card&lt;/li&gt;
&lt;li&gt;the padding adds space within each card so its children (the image and paragraph) can&#39;t touch its edges&lt;/li&gt;
&lt;li&gt;the margin-bottom on the image creates space between the children.&lt;/li&gt;
&lt;li&gt;the margin reset on the paragraph makes sure no additional unwanted space is created inside the card&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;conclusion&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/padding-margin/#conclusion&quot;&gt;&lt;span&gt;Conclusion&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Understanding the difference between padding and margin is essential for creating well-proportioned and visually appealing layouts.&lt;/p&gt;
&lt;p&gt;Remember that padding affects the inner space of an element, while margin controls the space around an element.&lt;/p&gt;
&lt;p&gt;By grasping these distinctions and using examples like those discussed above, you&#39;ll be better equipped to make informed CSS choices and achieve balanced and organised designs in your projects.&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Mastering sass nesting: Benefits, drawbacks, and my top tips</title>
		<link href="https://fedmentor.dev/posts/sass-nesting/"/>
		<updated>2023-08-06T00:00:00Z</updated>
		<id>https://fedmentor.dev/posts/sass-nesting/</id>
		<content type="html">&lt;aside class=&quot;c-aside c-aside--info [ relative text-body ]&quot; aria-labelledby=&quot;9d98921b-9672-4d0d-923f-cdd451f2d0b4&quot;&gt;
  &lt;div class=&quot;c-aside__icon [ grid place-content-center ]&quot;&gt;
    &lt;svg aria-hidden=&quot;true&quot; focusable=&quot;false&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;var(--icon-fill, var(--post-bg))&quot; stroke=&quot;var(--icon-stroke, var(--rainbow--teal))&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;[ h-full w-full ]&quot;&gt;&lt;circle cx=&quot;12&quot; cy=&quot;12&quot; r=&quot;10&quot;&gt;&lt;/circle&gt;&lt;line x1=&quot;12&quot; y1=&quot;16&quot; x2=&quot;12&quot; y2=&quot;12&quot;&gt;&lt;/line&gt;&lt;line x1=&quot;12&quot; y1=&quot;8&quot; x2=&quot;12.01&quot; y2=&quot;8&quot;&gt;&lt;/line&gt;&lt;/svg&gt;
  &lt;/div&gt;
  &lt;div class=&quot;c-aside__content flow&quot;&gt;&lt;strong id=&quot;9d98921b-9672-4d0d-923f-cdd451f2d0b4&quot; class=&quot;c-aside__title [  block font-heading leading-tight no-underline uppercase tracking-wide text-sm ]&quot;&gt;Quick Note&amp;hellip;&lt;/strong&gt;&lt;div class=&quot;flow&quot;&gt;&lt;p&gt;Sass is an extremely popular &lt;strong&gt;CSS pre-processor&lt;/strong&gt;. This post is specifically looking at &lt;strong&gt;sass&lt;/strong&gt; nesting, not native CSS nesting, but all the same prinicples will apply.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://sass-lang.com/&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;More about Sass&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;/aside&gt;
&lt;h2 id=&quot;understanding-nesting-in-sass&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/sass-nesting/#understanding-nesting-in-sass&quot;&gt;&lt;span&gt;Understanding Nesting in Sass&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Sass nesting simply means placing selectors inside each other.&lt;/p&gt;
&lt;p&gt;It&#39;s a way of writing CSS selectors that is a little shorter, and places more emphasis on the parent-child relationships. Many people find it easier to read because it provides a clear visual hierarchy to stylesheets much like HTML, thanks to the indentation and general syntax.&lt;/p&gt;
&lt;p&gt;You can nest selectors in all sorts of ways using Sass. It&#39;s super flexible!&lt;/p&gt;
&lt;h3 id=&quot;demo-nested-selectors&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/sass-nesting/#demo-nested-selectors&quot;&gt;&lt;span&gt;Demo: Nested Selectors&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Consider the following example in Sass (scss):&lt;/p&gt;
&lt;pre class=&quot;language-scss&quot; tabindex=&quot;0&quot; data-language=&quot;scss&quot;&gt;&lt;code class=&quot;language-scss&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;/*  _card.scss  */&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token selector&quot;&gt;.card &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token comment&quot;&gt;// card styles here&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token selector&quot;&gt;h2 &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token comment&quot;&gt;// card heading styles here&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token selector&quot;&gt;.button &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token comment&quot;&gt;// card button styles here&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token selector&quot;&gt;&lt;span class=&quot;token parent important&quot;&gt;&amp;amp;&lt;/span&gt;:focus-visible &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;      &lt;span class=&quot;token comment&quot;&gt;// card button&#39;s keyboard focus styles here&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Compiled to CSS, this becomes:&lt;/p&gt;
&lt;pre class=&quot;language-css&quot; tabindex=&quot;0&quot; data-language=&quot;css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;/*  main.css  */&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token selector&quot;&gt;.card&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token comment&quot;&gt;/* card styles here */&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token selector&quot;&gt;.card h2&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token comment&quot;&gt;/* card heading styles here */&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token selector&quot;&gt;.card .button&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token comment&quot;&gt;/* card button styles here */&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token selector&quot;&gt;.card .button:focus-visible&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token comment&quot;&gt;/* card button&#39;s keyboard focus styles here */&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h3 id=&quot;demo-nested-bem-class-names&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/sass-nesting/#demo-nested-bem-class-names&quot;&gt;&lt;span&gt;Demo: Nested BEM Class Names&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Some tutorials suggest nesting partial class names according to the BEM (Block Element Modifier) naming convention &lt;em&gt;(&lt;a href=&quot;https://fedmentor.dev/glossary&quot;&gt;see glossary&lt;/a&gt;)&lt;/em&gt;. Here&#39;s an example:&lt;/p&gt;
&lt;pre class=&quot;language-scss&quot; tabindex=&quot;0&quot; data-language=&quot;scss&quot;&gt;&lt;code class=&quot;language-scss&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;/*  _card.scss  */&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token selector&quot;&gt;.card &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token comment&quot;&gt;// card styles here...&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token selector&quot;&gt;&lt;span class=&quot;token parent important&quot;&gt;&amp;amp;&lt;/span&gt;__heading &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token comment&quot;&gt;// card heading styles here&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token selector&quot;&gt;&lt;span class=&quot;token parent important&quot;&gt;&amp;amp;&lt;/span&gt;__button &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token comment&quot;&gt;// card button styles here...&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token selector&quot;&gt;&lt;span class=&quot;token parent important&quot;&gt;&amp;amp;&lt;/span&gt;:focus-visible &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;      &lt;span class=&quot;token comment&quot;&gt;// card button&#39;s keyboard focus styles here&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Compiled to CSS, this becomes:&lt;/p&gt;
&lt;pre class=&quot;language-css&quot; tabindex=&quot;0&quot; data-language=&quot;css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;/*  main.css  */&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token selector&quot;&gt;.card&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token comment&quot;&gt;/* card styles here */&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token selector&quot;&gt;.card__heading&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token comment&quot;&gt;/* card heading styles here */&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token selector&quot;&gt;.card__button&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token comment&quot;&gt;/* card button styles here */&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token selector&quot;&gt;.card__button:focus-visible&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token comment&quot;&gt;/* card button&#39;s keyboard focus styles here */&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;However, this Sass example can be harder to read and maintain over time. I recommend you &lt;strong&gt;avoid nesting partial class names&lt;/strong&gt; like this.&lt;/p&gt;
&lt;h2 id=&quot;benefits-of-nesting&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/sass-nesting/#benefits-of-nesting&quot;&gt;&lt;span&gt;Benefits of Nesting&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Nesting with Sass offers several advantages:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Readability:&lt;/strong&gt; Structuring styles according to HTML hierarchy enhances understanding.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Reduced Repetition:&lt;/strong&gt; Nested selectors eliminate the need for repeating parent selectors.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Modularity:&lt;/strong&gt; Nesting encourages modular styling by isolating styles within their components.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Easier Targeting:&lt;/strong&gt; Nested selectors allow targeting specific elements within parent contexts easily.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Efficient Compilation:&lt;/strong&gt; Sass compiles nested styles into optimised CSS output, merging nested selectors when applicable.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Selector Flexibility:&lt;/strong&gt; Nested selectors in Sass can help you construct more complex and expressive selectors if you want to.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Time Savings:&lt;/strong&gt; By reducing repetition, nesting can save a little time spent typing.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;drawbacks-of-nesting&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/sass-nesting/#drawbacks-of-nesting&quot;&gt;&lt;span&gt;Drawbacks of Nesting&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;However, there are potential downsides to excessive nesting:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Specificity Issues:&lt;/strong&gt; When beginners first delve into Sass, they often encounter the issue of specificity. Overusing nesting can result in selectors that are overly specific, creating significant hurdles when trying to override styles later and obscuring understanding of how styles have been applied.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Selector Repetition:&lt;/strong&gt; Intensive nesting might necessitate repeating selectors within a single SCSS file. For instance, this might be done to alter an element&#39;s appearance based on its parentage or to circumvent specificity conflicts in the CSS cascade. Such repetition can lead to considerable confusion.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Bloated CSS:&lt;/strong&gt; Deep nesting can generate large, complex CSS output, impacting performance.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Complicated Selectors:&lt;/strong&gt; Excessive nesting can result in complex and hard-to-maintain selectors.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Maintenance Challenges:&lt;/strong&gt; Deeply nested styles may be difficult to adjust or refactor as projects evolve.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Limited Modularity:&lt;/strong&gt; Over-nesting can hinder modularity by tightly coupling styles to a specific HTML structure.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Overrides and Conflicts:&lt;/strong&gt; Deeply nested selectors can lead to conflicts during overrides.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;my-best-practice-advice&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/sass-nesting/#my-best-practice-advice&quot;&gt;&lt;span&gt;My Best Practice Advice&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;To mitigate these issues, consider the following practices:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Limit nesting depth:&lt;/strong&gt; Keep nesting levels shallow for readability and simplicity.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Use single class selectors:&lt;/strong&gt; Maintain low CSS specificity by using single class selectors as much as possible and avoiding excessive nesting.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Selective Nesting:&lt;/strong&gt; Reserve nesting for pseudo states (like &lt;code&gt;:hover&lt;/code&gt;), pseudo elements (like &lt;code&gt;:before&lt;/code&gt;), media queries, and ARIA attributes.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Check CSS Output:&lt;/strong&gt; Your compiled CSS should look exactly the same as if you&#39;d written it without any preprocessor at all. If there are any unexpected or long selector chains in there, refactor the Sass.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Regular Review and Refactoring:&lt;/strong&gt; Periodically review and refactor styles to maintain clarity and organization.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;strong&gt;Taken all together, this should result in highly readable, easy to maintain CSS with low specificity.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;By embracing these practices, you can harness the benefits of Sass nesting while minimizing its potential drawbacks. This will result in more readable, maintainable, and efficient code.&lt;/p&gt;
&lt;hr /&gt;
&lt;h2 id=&quot;conclusion&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/sass-nesting/#conclusion&quot;&gt;&lt;span&gt;Conclusion&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Experiment with these strategies, &lt;strong&gt;particularly selective nesting&lt;/strong&gt;, and observe how they impact the legibility and maintainability of your code. I hope that taking these approaches to heart helps your Sass workflow.&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Recommended Frontend Mentor challenge order for junior devs (2023)</title>
		<link href="https://fedmentor.dev/posts/newbie-fm-challenge-order/"/>
		<updated>2023-07-31T00:00:00Z</updated>
		<id>https://fedmentor.dev/posts/newbie-fm-challenge-order/</id>
		<content type="html">&lt;aside class=&quot;c-aside c-aside--info [ relative text-body ]&quot; aria-labelledby=&quot;765657b0-1938-42a6-a870-f24b1785ed0f&quot;&gt;
  &lt;div class=&quot;c-aside__icon [ grid place-content-center ]&quot;&gt;
    &lt;svg aria-hidden=&quot;true&quot; focusable=&quot;false&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;var(--icon-fill, var(--post-bg))&quot; stroke=&quot;var(--icon-stroke, var(--rainbow--teal))&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;[ h-full w-full ]&quot;&gt;&lt;circle cx=&quot;12&quot; cy=&quot;12&quot; r=&quot;10&quot;&gt;&lt;/circle&gt;&lt;line x1=&quot;12&quot; y1=&quot;16&quot; x2=&quot;12&quot; y2=&quot;12&quot;&gt;&lt;/line&gt;&lt;line x1=&quot;12&quot; y1=&quot;8&quot; x2=&quot;12.01&quot; y2=&quot;8&quot;&gt;&lt;/line&gt;&lt;/svg&gt;
  &lt;/div&gt;
  &lt;div class=&quot;c-aside__content flow&quot;&gt;&lt;strong id=&quot;765657b0-1938-42a6-a870-f24b1785ed0f&quot; class=&quot;c-aside__title [  block font-heading leading-tight no-underline uppercase tracking-wide text-sm ]&quot;&gt;What&#39;s Frontend Mentor?!&lt;/strong&gt;&lt;div class=&quot;flow&quot;&gt;&lt;p&gt;&lt;a href=&quot;https://www.frontendmentor.io/&quot; target=&quot;_blank&quot;&gt;Frontend Mentor&lt;/a&gt; (FM) is a brilliant site that provides you with loads of realistic components or site designs you can build.
It&#39;s a place where you can stretch those front end muscles and embed your learning by actually &lt;strong&gt;building stuff&lt;/strong&gt; and &lt;strong&gt;getting feedback&lt;/strong&gt; or help as you go.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;It &lt;em&gt;is&lt;/em&gt; important to still do some courses first!&lt;/strong&gt; Don&#39;t try to start building projects until you feel ready, and &lt;mark&gt;please don&#39;t get disheartened&lt;/mark&gt; if you try the first one and get stuck. This stuff takes time to learn, but you&#39;ll get there.&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;/aside&gt;
&lt;aside class=&quot;c-aside c-aside--alert [ relative text-body ]&quot; aria-labelledby=&quot;5a50fb03-9d02-42b9-bdf5-7ac407956ae5&quot;&gt;
  &lt;div class=&quot;c-aside__icon [ grid place-content-center ]&quot;&gt;
    &lt;svg 2000=&quot;&quot; aria-hidden=&quot;true&quot; focusable=&quot;false xmlns=&quot; http:=&quot;&quot; www.w3.org=&quot;&quot; svg&quot;=&quot;&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;var(--icon-fill, var(--post-bg))&quot; stroke=&quot;var(--icon-stroke, var(--rainbow--teal))&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;[ h-full w-full ]&quot;&gt;&lt;polygon points=&quot;7.86 2 16.14 2 22 7.86 22 16.14 16.14 22 7.86 22 2 16.14 2 7.86 7.86 2&quot;&gt;&lt;/polygon&gt;&lt;line x1=&quot;12&quot; y1=&quot;8&quot; x2=&quot;12&quot; y2=&quot;12&quot;&gt;&lt;/line&gt;&lt;line x1=&quot;12&quot; y1=&quot;16&quot; x2=&quot;12.01&quot; y2=&quot;16&quot;&gt;&lt;/line&gt;&lt;/svg&gt;
  &lt;/div&gt;
  &lt;div class=&quot;c-aside__content flow&quot;&gt;&lt;strong id=&quot;5a50fb03-9d02-42b9-bdf5-7ac407956ae5&quot; class=&quot;c-aside__title [  block font-heading leading-tight no-underline uppercase tracking-wide text-sm ]&quot;&gt;Try the FM Learning Paths!&lt;/strong&gt;&lt;div class=&quot;flow&quot;&gt;&lt;p&gt;&lt;strong&gt;This post was prepared &lt;em&gt;before&lt;/em&gt; &lt;a href=&quot;https://www.frontendmentor.io/learning-paths&quot;&gt;FrontEnd Mentor added &#39;learning paths&#39;&lt;/a&gt; in 2024.&lt;/strong&gt; The learning paths suggest a challenge order based on specific topics like &amp;quot;Getting Started&amp;quot;, &amp;quot;Accessibility&amp;quot; or &amp;quot;JavaScript&amp;quot;, but accompany their challenges with resources to read or tasks to complete (like giving feedback or refactoring solutions).&lt;/p&gt;
&lt;p&gt;I suggest you use both the learning paths &lt;em&gt;and&lt;/em&gt; my recommended order for the best experience.&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;/aside&gt;
&lt;h2 id=&quot;my-list-for-beginners&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/newbie-fm-challenge-order/#my-list-for-beginners&quot;&gt;&lt;span&gt;My list for Beginners&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Although I&#39;m suggesting an order here, please remember it&#39;s not an exact science.&lt;/p&gt;
&lt;p&gt;I&#39;ll try to explain &lt;em&gt;why&lt;/em&gt; I suggest each challenge in this (rough) order. And hopefully, you&#39;ll see that I&#39;m trying to help you &lt;strong&gt;build skills progressively&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;As a self-taught developer, I have first-hand experience of feeling overwhelmed by challenges I couldn&#39;t do &lt;em&gt;(this still happens regularly by the way!)&lt;/em&gt;. &lt;strong&gt;I hope this list helps you avoid feeling overwhelmed&lt;/strong&gt;, even if you choose to skip challenges or take them in a different order.&lt;/p&gt;
&lt;p&gt;A good rule of thumb is to attempt challenges where you think you can comfortably do about 80% but will need to look up the last 20%. That&#39;s what this list intends to do.&lt;/p&gt;
&lt;aside class=&quot;c-aside c-aside--alert [ relative text-body ]&quot; aria-labelledby=&quot;f7483a78-99fe-454e-b414-4752b3c6ba3b&quot;&gt;
  &lt;div class=&quot;c-aside__icon [ grid place-content-center ]&quot;&gt;
    &lt;svg 2000=&quot;&quot; aria-hidden=&quot;true&quot; focusable=&quot;false xmlns=&quot; http:=&quot;&quot; www.w3.org=&quot;&quot; svg&quot;=&quot;&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;var(--icon-fill, var(--post-bg))&quot; stroke=&quot;var(--icon-stroke, var(--rainbow--teal))&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;[ h-full w-full ]&quot;&gt;&lt;polygon points=&quot;7.86 2 16.14 2 22 7.86 22 16.14 16.14 22 7.86 22 2 16.14 2 7.86 7.86 2&quot;&gt;&lt;/polygon&gt;&lt;line x1=&quot;12&quot; y1=&quot;8&quot; x2=&quot;12&quot; y2=&quot;12&quot;&gt;&lt;/line&gt;&lt;line x1=&quot;12&quot; y1=&quot;16&quot; x2=&quot;12.01&quot; y2=&quot;16&quot;&gt;&lt;/line&gt;&lt;/svg&gt;
  &lt;/div&gt;
  &lt;div class=&quot;c-aside__content flow&quot;&gt;&lt;strong id=&quot;f7483a78-99fe-454e-b414-4752b3c6ba3b&quot; class=&quot;c-aside__title [  block font-heading leading-tight no-underline uppercase tracking-wide text-sm ]&quot;&gt;Please don&#39;t rush!&lt;/strong&gt;&lt;div class=&quot;flow&quot;&gt;&lt;p&gt;I can&#39;t stress this enough. Look up topics as you need to while working on challenges. If one challenge takes a day but the next takes a week, that&#39;s OK!&lt;/p&gt;
&lt;p&gt;&lt;mark&gt;The most valuable part of Frontend Mentor is getting feedback and refactoring your solutions&lt;/mark&gt;. Have a look at others&#39; solutions. Learn from their feedback as well as seeking out your own. And spend time improving your solutions later as you learn more.&lt;/p&gt;
&lt;p&gt;You will likely need to refactor your solutions many times to make them as good as they can be.&lt;/p&gt;
&lt;p&gt;Learning is &lt;strong&gt;not about speed&lt;/strong&gt;, particularly at the beginning. It&#39;s about getting the foundations right and learning &lt;strong&gt;good code standards&lt;/strong&gt;.&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;/aside&gt;
&lt;hr /&gt;
&lt;h3 id=&quot;1-qr-code-card&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/newbie-fm-challenge-order/#1-qr-code-card&quot;&gt;&lt;span&gt;1. &lt;a href=&quot;https://www.frontendmentor.io/challenges/qr-code-component-iux_sIO_H&quot;&gt;QR Code Card&lt;/a&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;div style=&quot;max-width: 388px&quot;&gt;
&lt;figure class=&quot;[ flex flex-col  ]&quot;&gt;&lt;picture&gt;&lt;source type=&quot;image/webp&quot; srcset=&quot;https://fedmentor.dev/posts/newbie-fm-challenge-order/qr-code-800w.webp 800w, https://fedmentor.dev/posts/newbie-fm-challenge-order/qr-code-1200w.webp 1200w&quot; sizes=&quot;(min-width: 40rem) 50vw, 100vw&quot; /&gt;&lt;source type=&quot;image/jpeg&quot; srcset=&quot;https://fedmentor.dev/posts/newbie-fm-challenge-order/qr-code-800w.jpeg 800w, https://fedmentor.dev/posts/newbie-fm-challenge-order/qr-code-1200w.jpeg 1200w&quot; sizes=&quot;(min-width: 40rem) 50vw, 100vw&quot; /&gt;&lt;img alt=&quot;QR Code Challenge: A single card with a white background, QR code image, title and sentence&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; src=&quot;https://fedmentor.dev/posts/newbie-fm-challenge-order/qr-code-800w.jpeg&quot; width=&quot;1200&quot; height=&quot;1228&quot; /&gt;&lt;/picture&gt;&lt;/figure&gt;
&lt;/div&gt;
&lt;p&gt;It looks super simple, but gives you a chance to practice:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;how to use the style guide&lt;/li&gt;
&lt;li&gt;landmarks and semantic HTML&lt;/li&gt;
&lt;li&gt;how to link Google fonts&lt;/li&gt;
&lt;li&gt;using a modern CSS reset&lt;/li&gt;
&lt;li&gt;how to centre a component in the viewport with flex/grid&lt;/li&gt;
&lt;li&gt;writing good image alt descriptions&lt;/li&gt;
&lt;/ul&gt;
&lt;hr /&gt;
&lt;h3 id=&quot;2-product-preview-card-or-order-summary-component&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/newbie-fm-challenge-order/#2-product-preview-card-or-order-summary-component&quot;&gt;&lt;span&gt;2. &lt;a href=&quot;https://www.frontendmentor.io/challenges/product-preview-card-component-GO7UmttRfa&quot;&gt;Product preview card&lt;/a&gt; or &lt;a href=&quot;https://www.frontendmentor.io/challenges/order-summary-component-QlPmajDUj&quot;&gt;Order summary component&lt;/a&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;div class=&quot;c-img-grid  [ grid gap-1 ]&quot; style=&quot;margin-block-end: var(--flow-space)&quot;&gt;
&lt;div&gt;
&lt;figure class=&quot;[ flex flex-col  ]&quot;&gt;&lt;picture&gt;&lt;source type=&quot;image/webp&quot; srcset=&quot;https://fedmentor.dev/posts/newbie-fm-challenge-order/2-product-preview-800w.webp 800w, https://fedmentor.dev/posts/newbie-fm-challenge-order/2-product-preview-1200w.webp 1200w&quot; sizes=&quot;(min-width: 40rem) 50vw, 100vw&quot; /&gt;&lt;source type=&quot;image/jpeg&quot; srcset=&quot;https://fedmentor.dev/posts/newbie-fm-challenge-order/2-product-preview-800w.jpeg 800w, https://fedmentor.dev/posts/newbie-fm-challenge-order/2-product-preview-1200w.jpeg 1200w&quot; sizes=&quot;(min-width: 40rem) 50vw, 100vw&quot; /&gt;&lt;img alt=&quot;Product Preview Challenge: A single card in horizontal arrangement with an image of perfume on one side and product details including category, product name, prices and add to cart button on the other&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; src=&quot;https://fedmentor.dev/posts/newbie-fm-challenge-order/2-product-preview-800w.jpeg&quot; width=&quot;1200&quot; height=&quot;1228&quot; /&gt;&lt;/picture&gt;&lt;/figure&gt;
&lt;/div&gt;&lt;div&gt;
&lt;figure class=&quot;[ flex flex-col  ]&quot;&gt;&lt;picture&gt;&lt;source type=&quot;image/webp&quot; srcset=&quot;https://fedmentor.dev/posts/newbie-fm-challenge-order/3-order-summary-800w.webp 800w, https://fedmentor.dev/posts/newbie-fm-challenge-order/3-order-summary-1200w.webp 1200w&quot; sizes=&quot;(min-width: 40rem) 50vw, 100vw&quot; /&gt;&lt;source type=&quot;image/jpeg&quot; srcset=&quot;https://fedmentor.dev/posts/newbie-fm-challenge-order/3-order-summary-800w.jpeg 800w, https://fedmentor.dev/posts/newbie-fm-challenge-order/3-order-summary-1200w.jpeg 1200w&quot; sizes=&quot;(min-width: 40rem) 50vw, 100vw&quot; /&gt;&lt;img alt=&quot;Order Summary Challenge: A single card with an illustration at the top, heaing, inner pricing box with option to change from annual pricing, a proceed button and a cancel CTA&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; src=&quot;https://fedmentor.dev/posts/newbie-fm-challenge-order/3-order-summary-800w.jpeg&quot; width=&quot;1200&quot; height=&quot;1228&quot; /&gt;&lt;/picture&gt;&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;These will build on the above but with an extra focus on:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;image sizing with object-fit&lt;/li&gt;
&lt;li&gt;buttons vs anchors&lt;/li&gt;
&lt;li&gt;flexbox (and possibly CSS grid)&lt;/li&gt;
&lt;li&gt;heading order&lt;/li&gt;
&lt;li&gt;mobile-first styling&lt;/li&gt;
&lt;li&gt;responsive images using the picture element &lt;br /&gt;&lt;em&gt;(in the product preview card)&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;how to add extra info for screen reader users &lt;br /&gt;&lt;em&gt;(in the product preview card)&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;abbr class=&quot;[ no-underline undefined ]&quot; title=&quot;idea lightbulb emoji&quot;&gt;💡&lt;/abbr&gt; &lt;em&gt;You may like to look at &lt;a href=&quot;https://fedmentor.dev/posts/html-plan-product-preview/&quot;&gt;my post about planning out your HTML&lt;/a&gt; at this point!&lt;/em&gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;h3 id=&quot;3-stats-preview-card&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/newbie-fm-challenge-order/#3-stats-preview-card&quot;&gt;&lt;span&gt;3. &lt;a href=&quot;https://www.frontendmentor.io/challenges/stats-preview-card-component-8JqbgoU62&quot;&gt;Stats preview card&lt;/a&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;div&gt;
&lt;figure class=&quot;[ flex flex-col  ]&quot;&gt;&lt;picture&gt;&lt;source type=&quot;image/webp&quot; srcset=&quot;https://fedmentor.dev/posts/newbie-fm-challenge-order/4-stats-preview-card-800w.webp 800w, https://fedmentor.dev/posts/newbie-fm-challenge-order/4-stats-preview-card-1200w.webp 1200w&quot; sizes=&quot;(min-width: 20em) 50vw&quot; /&gt;&lt;source type=&quot;image/jpeg&quot; srcset=&quot;https://fedmentor.dev/posts/newbie-fm-challenge-order/4-stats-preview-card-800w.jpeg 800w, https://fedmentor.dev/posts/newbie-fm-challenge-order/4-stats-preview-card-1200w.jpeg 1200w&quot; sizes=&quot;(min-width: 20em) 50vw&quot; /&gt;&lt;img alt=&quot;Stats preview card component challenge: A dark background with a dark-colored horizontal card in desktop view. There is a title with words highlighted in purple, a paragraph and 3 statistics on one side, and an photo of office workers with a purple-tinted overlay on the other&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; src=&quot;https://fedmentor.dev/posts/newbie-fm-challenge-order/4-stats-preview-card-800w.jpeg&quot; width=&quot;1200&quot; height=&quot;676&quot; /&gt;&lt;/picture&gt;&lt;/figure&gt;
&lt;/div&gt;
&lt;p&gt;Now you&#39;ll practice more:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;CSS grid and Flexbox&lt;/li&gt;
&lt;li&gt;list styling (and how to keep them accessible)&lt;/li&gt;
&lt;li&gt;blend modes on images&lt;/li&gt;
&lt;/ul&gt;
&lt;hr /&gt;
&lt;h3 id=&quot;4-the-3-column-preview-card&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/newbie-fm-challenge-order/#4-the-3-column-preview-card&quot;&gt;&lt;span&gt;4. The &lt;a href=&quot;https://www.frontendmentor.io/challenges/3column-preview-card-component-pH92eAR2-&quot;&gt;3-column preview card&lt;/a&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;div&gt;
&lt;figure class=&quot;[ flex flex-col  ]&quot;&gt;&lt;picture&gt;&lt;source type=&quot;image/webp&quot; srcset=&quot;https://fedmentor.dev/posts/newbie-fm-challenge-order/5-3-column-800w.webp 800w, https://fedmentor.dev/posts/newbie-fm-challenge-order/5-3-column-1200w.webp 1200w&quot; sizes=&quot;(min-width: 20em) 50vw&quot; /&gt;&lt;source type=&quot;image/jpeg&quot; srcset=&quot;https://fedmentor.dev/posts/newbie-fm-challenge-order/5-3-column-800w.jpeg 800w, https://fedmentor.dev/posts/newbie-fm-challenge-order/5-3-column-1200w.jpeg 1200w&quot; sizes=&quot;(min-width: 20em) 50vw&quot; /&gt;&lt;img alt=&quot;3-column preview card component challenge: Three columns in a card, each with a different coloured background, an icon, a heading, paragraph and button-styled CTA link&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; src=&quot;https://fedmentor.dev/posts/newbie-fm-challenge-order/5-3-column-800w.jpeg&quot; width=&quot;1200&quot; height=&quot;666&quot; /&gt;&lt;/picture&gt;&lt;/figure&gt;
&lt;/div&gt;
&lt;p&gt;This builds on the previous skills:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;CSS Grid and/or Flexbox&lt;/li&gt;
&lt;li&gt;headings and semantic HTML&lt;/li&gt;
&lt;li&gt;decorative images&lt;/li&gt;
&lt;li&gt;hover and focus-visible styles&lt;/li&gt;
&lt;li&gt;more practice with mobile-first responsiveness&lt;/li&gt;
&lt;/ul&gt;
&lt;hr /&gt;
&lt;h3 id=&quot;5-single-price-grid-or-huddle-landing-page&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/newbie-fm-challenge-order/#5-single-price-grid-or-huddle-landing-page&quot;&gt;&lt;span&gt;5. &lt;a href=&quot;https://www.frontendmentor.io/challenges/single-price-grid-component-5ce41129d0ff452fec5abbbc&quot;&gt;Single price grid&lt;/a&gt; &lt;em&gt;or&lt;/em&gt; &lt;a href=&quot;https://www.frontendmentor.io/challenges/huddle-landing-page-with-a-single-introductory-section-B_2Wvxgi0&quot;&gt;Huddle landing page&lt;/a&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;div class=&quot;c-img-grid  [ grid gap-1 ]&quot; style=&quot;margin-block-end: var(--flow-space)&quot;&gt;
&lt;div&gt;
&lt;figure class=&quot;[ flex flex-col  ]&quot;&gt;&lt;picture&gt;&lt;source type=&quot;image/webp&quot; srcset=&quot;https://fedmentor.dev/posts/newbie-fm-challenge-order/6-single-price-grid-700w.webp 700w&quot; sizes=&quot;(min-width: 40rem), 100vw&quot; /&gt;&lt;img alt=&quot;Single price grid component Challenge: A grid of text content. One row at the top has a white background, main title and paragraphs. Under this there are two columns, in the grid, each with a different shade of teal background and white text. The first column includes pricing information and a CTA link to sign up; and the second column includes a list of benefits&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; src=&quot;https://fedmentor.dev/posts/newbie-fm-challenge-order/6-single-price-grid-700w.jpeg&quot; width=&quot;700&quot; height=&quot;513&quot; /&gt;&lt;/picture&gt;&lt;/figure&gt;
&lt;/div&gt;&lt;div&gt;
&lt;figure class=&quot;[ flex flex-col  ]&quot;&gt;&lt;picture&gt;&lt;source type=&quot;image/webp&quot; srcset=&quot;https://fedmentor.dev/posts/newbie-fm-challenge-order/6-huddle-landing-700w.webp 700w&quot; sizes=&quot;(min-width: 40rem), 100vw&quot; /&gt;&lt;img alt=&quot;Huddle landing page with a single introductory section Challenge: A landing page with purple patterned background shown in desktop orientation. There is a logo at the top, main section with large image next to a heading, paragraph and CTA link; and in the bottom corner of the page are 3 social media icons&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; src=&quot;https://fedmentor.dev/posts/newbie-fm-challenge-order/6-huddle-landing-700w.jpeg&quot; width=&quot;700&quot; height=&quot;513&quot; /&gt;&lt;/picture&gt;&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Whether or not you&#39;ve used it before, this is &lt;strong&gt;time to use CSS grid!&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;You&#39;ll also practice:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;landmarks and semantic HTML structure&lt;/li&gt;
&lt;li&gt;SVG hover styles &lt;br /&gt;&lt;em&gt;(in the Huddle landing page)&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;Heading order &lt;br /&gt;&lt;em&gt;(in the Single price grid component)&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;abbr class=&quot;[ no-underline undefined ]&quot; title=&quot;Important emoji&quot;&gt;⚠️&lt;/abbr&gt; Note, the single price grid component design has particularly poor colour contrast, making it inaccessible. Feel free to adjust the colours if you wish!&lt;/p&gt;
&lt;hr /&gt;
&lt;h3 id=&quot;6-the-4-card-feature-and-social-proof-section&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/newbie-fm-challenge-order/#6-the-4-card-feature-and-social-proof-section&quot;&gt;&lt;span&gt;6. The &lt;a href=&quot;https://www.frontendmentor.io/challenges/four-card-feature-section-weK1eFYK&quot;&gt;4 card feature&lt;/a&gt; &lt;em&gt;and&lt;/em&gt; &lt;a href=&quot;https://www.frontendmentor.io/challenges/social-proof-section-6e0qTv_bA&quot;&gt;Social Proof section&lt;/a&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;div class=&quot;c-img-grid  [ grid gap-1 ]&quot; style=&quot;margin-block-end: var(--flow-space)&quot;&gt;
&lt;div&gt;
&lt;figure class=&quot;[ flex flex-col  ]&quot;&gt;&lt;picture&gt;&lt;source type=&quot;image/webp&quot; srcset=&quot;https://fedmentor.dev/posts/newbie-fm-challenge-order/7-4-card-feature-700w.webp 700w&quot; sizes=&quot;(min-width: 40rem) 50vw, 100vw&quot; /&gt;&lt;img alt=&quot;4 card feature section Challenge: Desktop design for the challenge with a centre-aligned heading and intro paragraph, followed by 4 cards in an unusual &#39;plus style&#39; layout where the corner areas of the grid are empty.&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; src=&quot;https://fedmentor.dev/posts/newbie-fm-challenge-order/7-4-card-feature-700w.jpeg&quot; width=&quot;700&quot; height=&quot;513&quot; /&gt;&lt;/picture&gt;&lt;/figure&gt;
&lt;/div&gt;&lt;div&gt;
&lt;figure class=&quot;[ flex flex-col  ]&quot;&gt;&lt;picture&gt;&lt;source type=&quot;image/webp&quot; srcset=&quot;https://fedmentor.dev/posts/newbie-fm-challenge-order/7-social-proof-700w.webp 700w&quot; sizes=&quot;(min-width: 40rem) 50vw, 100vw&quot; /&gt;&lt;img alt=&quot;Social Proof section Challenge: A desktop design with intro section, reviews and testimonials all with staggered arrangements&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; src=&quot;https://fedmentor.dev/posts/newbie-fm-challenge-order/7-social-proof-700w.jpeg&quot; width=&quot;700&quot; height=&quot;513&quot; /&gt;&lt;/picture&gt;&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;These are more complex CSS grid challenges.&lt;/p&gt;
&lt;p&gt;I recommend trying out grid-template areas if you&#39;ve not done so already, and plan out your grid on paper if it helps.&lt;/p&gt;
&lt;p&gt;You&#39;ll also gain more experience with:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;using alignment methods like directional auto or negative margins, text alignment, transforms, flex properties or CSS grid properties&lt;/li&gt;
&lt;li&gt;max-width in ch or rem&lt;/li&gt;
&lt;li&gt;pseudo-elements or borders&lt;/li&gt;
&lt;li&gt;visually hidden headings &lt;br /&gt;&lt;em&gt;(in the social proof section)&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Honestly, doing both of these challenges is likely &lt;strong&gt;very beneficial&lt;/strong&gt;!&lt;/p&gt;
&lt;hr /&gt;
&lt;h3 id=&quot;7-ping-single-column-or-base-apparel-coming-soon-page&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/newbie-fm-challenge-order/#7-ping-single-column-or-base-apparel-coming-soon-page&quot;&gt;&lt;span&gt;7. &lt;a href=&quot;https://www.frontendmentor.io/challenges/ping-single-column-coming-soon-page-5cadd051fec04111f7b848da&quot;&gt;Ping single column&lt;/a&gt; &lt;em&gt;or&lt;/em&gt; &lt;a href=&quot;https://www.frontendmentor.io/challenges/base-apparel-coming-soon-page-5d46b47f8db8a7063f9331a0&quot;&gt;Base Apparel coming soon page&lt;/a&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;div class=&quot;c-img-grid  [ grid gap-1 ]&quot; style=&quot;margin-block-end: var(--flow-space)&quot;&gt;
&lt;div&gt;
&lt;figure class=&quot;[ flex flex-col  ]&quot;&gt;&lt;picture&gt;&lt;source type=&quot;image/webp&quot; srcset=&quot;https://fedmentor.dev/posts/newbie-fm-challenge-order/8-ping-700w.webp 700w&quot; sizes=&quot;(min-width: 40rem) 50vw, 100vw&quot; /&gt;&lt;img alt=&quot;Ping single column coming soon page Challenge: Desktop design for a simple email sign up landing page, with logo, title, single field form, image and 3 social icons&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; src=&quot;https://fedmentor.dev/posts/newbie-fm-challenge-order/8-ping-700w.jpeg&quot; width=&quot;700&quot; height=&quot;513&quot; /&gt;&lt;/picture&gt;&lt;/figure&gt;
&lt;/div&gt;&lt;div&gt;
&lt;figure class=&quot;[ flex flex-col  ]&quot;&gt;&lt;picture&gt;&lt;source type=&quot;image/webp&quot; srcset=&quot;https://fedmentor.dev/posts/newbie-fm-challenge-order/8-base-apparel-700w.webp 700w&quot; sizes=&quot;(min-width: 40rem) 50vw, 100vw&quot; /&gt;&lt;img alt=&quot;Base Apparel coming soon page Challenge: A desktop design for a landing page with full height image on one side, logo and intro text with single field email sign up form on the other side&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; src=&quot;https://fedmentor.dev/posts/newbie-fm-challenge-order/8-base-apparel-700w.jpeg&quot; width=&quot;700&quot; height=&quot;513&quot; /&gt;&lt;/picture&gt;&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;It&#39;s JavaScript time! If you haven&#39;t studied any JS at all yet, pause here and try to learn some basics.&lt;/p&gt;
&lt;p&gt;It&#39;s also worth reading MDN&#39;s excellent docs or tutorials on HTML form validation, as that&#39;s what these challenges focus on.&lt;/p&gt;
&lt;p&gt;You&#39;ll also have the opportunity to learn:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;more flex/grid&lt;/li&gt;
&lt;li&gt;accessible form HTML markup&lt;/li&gt;
&lt;li&gt;how to programmatically link errors and inputs&lt;/li&gt;
&lt;li&gt;aria-live attributes&lt;/li&gt;
&lt;/ul&gt;
&lt;hr /&gt;
&lt;h3 id=&quot;8-intro-with-sign-up-form&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/newbie-fm-challenge-order/#8-intro-with-sign-up-form&quot;&gt;&lt;span&gt;8. &lt;a href=&quot;https://www.frontendmentor.io/challenges/intro-component-with-signup-form-5cf91bd49edda32581d28fd1&quot;&gt;Intro with sign up form&lt;/a&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;div&gt;
&lt;figure class=&quot;[ flex flex-col  ]&quot;&gt;&lt;picture&gt;&lt;source type=&quot;image/webp&quot; srcset=&quot;https://fedmentor.dev/posts/newbie-fm-challenge-order/9-intro-sign-up-700w.webp 700w&quot; sizes=&quot;(min-width: 20em) 50vw&quot; /&gt;&lt;img alt=&quot;Intro component with sign up form challenge: A landing page with bright coral patterned background and a two-column layout with an intro section on one side and a multi-field sign up form on the other&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; src=&quot;https://fedmentor.dev/posts/newbie-fm-challenge-order/9-intro-sign-up-700w.jpeg&quot; width=&quot;700&quot; height=&quot;513&quot; /&gt;&lt;/picture&gt;&lt;/figure&gt;
&lt;/div&gt;
&lt;p&gt;You will need lots of form validation practice. This is a huge part of a front end developer&#39;s job, so get familiar with forms as much as you can!&lt;/p&gt;
&lt;p&gt;Again, this isn&#39;t the most accessible design because (a) it&#39;s missing visible form labels and (b) has poor colour contrast. Feel free to adjust it to make it properly accessible, or ignore those two issues and focus all your energy on emulating the design and validating that form in an accessible way.&lt;/p&gt;
&lt;p&gt;You&#39;ll also be able to stretch skills like:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;semantically meaningful HTML (as always)&lt;/li&gt;
&lt;li&gt;lean JavaScript (it should be as minimal as possible)&lt;/li&gt;
&lt;li&gt;separation of styling and script concerns&lt;/li&gt;
&lt;li&gt;accessible error announcement&lt;/li&gt;
&lt;li&gt;aria-describedby attributes&lt;/li&gt;
&lt;li&gt;positioning and styling based on dynamic errors&lt;/li&gt;
&lt;li&gt;background images&lt;/li&gt;
&lt;li&gt;more complex CSS selectors&lt;/li&gt;
&lt;/ul&gt;
&lt;hr /&gt;
&lt;h3 id=&quot;9-results-summary-component&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/newbie-fm-challenge-order/#9-results-summary-component&quot;&gt;&lt;span&gt;9. &lt;a href=&quot;https://www.frontendmentor.io/challenges/results-summary-component-CE_K6s0maV&quot;&gt;Results Summary Component&lt;/a&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;div&gt;
&lt;figure class=&quot;[ flex flex-col  ]&quot;&gt;&lt;picture&gt;&lt;source type=&quot;image/webp&quot; srcset=&quot;https://fedmentor.dev/posts/newbie-fm-challenge-order/10-results-summary-700w.webp 700w&quot; sizes=&quot;(min-width: 20em) 50vw&quot; /&gt;&lt;img alt=&quot;Results Summary Component challenge: A results summary component centred on the screen, with dark purple background section giving overall results, then a white bakground section with a breakdown of individual results and &#39;continue&#39; CTA. Each item has an icon, title and score our of 100.&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; src=&quot;https://fedmentor.dev/posts/newbie-fm-challenge-order/10-results-summary-700w.jpeg&quot; width=&quot;700&quot; height=&quot;513&quot; /&gt;&lt;/picture&gt;&lt;/figure&gt;
&lt;/div&gt;
&lt;p&gt;A lovely little challenge that introduces a separate data file, like those you&#39;ll work with day-to-day in front end work.&lt;/p&gt;
&lt;p&gt;This challenge adds opportunities to learn:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;how to power HTML content from data&lt;/li&gt;
&lt;li&gt;custom properties and/or colour modifiers in CSS&lt;/li&gt;
&lt;li&gt;some challenging pre-planning to get the HTML structure right&lt;/li&gt;
&lt;/ul&gt;
&lt;hr /&gt;
&lt;h3 id=&quot;10-interactive-rating-card&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/newbie-fm-challenge-order/#10-interactive-rating-card&quot;&gt;&lt;span&gt;10. &lt;a href=&quot;https://www.frontendmentor.io/challenges/interactive-rating-component-koxpeBUmI&quot;&gt;Interactive rating card&lt;/a&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;div&gt;
&lt;figure class=&quot;[ flex flex-col  ]&quot;&gt;&lt;picture&gt;&lt;source type=&quot;image/webp&quot; srcset=&quot;https://fedmentor.dev/posts/newbie-fm-challenge-order/11-interactive-rating-700w.webp 700w&quot; sizes=&quot;(min-width: 20em) 50vw&quot; /&gt;&lt;img alt=&quot;Interactive rating component challenge: A small feedback form with a dark design. All the card contains is short text, numbers in circles 1-5, and a submit button&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; src=&quot;https://fedmentor.dev/posts/newbie-fm-challenge-order/11-interactive-rating-700w.jpeg&quot; width=&quot;700&quot; height=&quot;513&quot; /&gt;&lt;/picture&gt;&lt;/figure&gt;
&lt;/div&gt;
&lt;p&gt;I love this challenge but it&#39;s amazing how few people plan their HTML correctly on this one.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Hint&lt;/strong&gt;: It&#39;s a form! Look up which form elements would be most appropriate for those circles.  Another hint: They&#39;re &lt;em&gt;not&lt;/em&gt; buttons! &lt;abbr class=&quot;[ no-underline undefined ]&quot; title=&quot;wink emoji&quot;&gt;😉&lt;/abbr&gt;&lt;/p&gt;
&lt;p&gt;Here you&#39;ll learn:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;more about working with form data&lt;/li&gt;
&lt;li&gt;submit events&lt;/li&gt;
&lt;li&gt;announcing content changes to the accessibility API&lt;/li&gt;
&lt;li&gt;accessibly styling previously unused form elements &lt;em&gt;(This can be a bit tricky! &lt;a href=&quot;https://moderncss.dev/&quot;&gt;ModernCSS.dev&lt;/a&gt; has some great posts that should help)&lt;/em&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;hr /&gt;
&lt;h3 id=&quot;11-nft-preview-card&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/newbie-fm-challenge-order/#11-nft-preview-card&quot;&gt;&lt;span&gt;11. &lt;a href=&quot;https://www.frontendmentor.io/challenges/nft-preview-card-component-SbdUL_w0U&quot;&gt;NFT preview card&lt;/a&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;div&gt;
&lt;figure class=&quot;[ flex flex-col  ]&quot;&gt;&lt;picture&gt;&lt;source type=&quot;image/webp&quot; srcset=&quot;https://fedmentor.dev/posts/newbie-fm-challenge-order/12-nft-card-700w.webp 700w&quot; sizes=&quot;(min-width: 20em) 50vw&quot; /&gt;&lt;img alt=&quot;NFT preview card challenge: A simple-looking card design with image and text content. This design preview does not show the tricky image hover effect in the challenge, which makes the design more complex than it first looks&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; src=&quot;https://fedmentor.dev/posts/newbie-fm-challenge-order/12-nft-card-700w.jpeg&quot; width=&quot;700&quot; height=&quot;513&quot; /&gt;&lt;/picture&gt;&lt;/figure&gt;
&lt;/div&gt;
&lt;p&gt;This will be a real test of what you&#39;ve learnt so far, especially in terms of meaningful HTML.&lt;/p&gt;
&lt;p&gt;It also is a great opportunity to learn more about:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;pseudo-elements&lt;/li&gt;
&lt;li&gt;fun hover styles&lt;/li&gt;
&lt;li&gt;accessible naming practices for interactive elements&lt;/li&gt;
&lt;/ul&gt;
&lt;hr /&gt;
&lt;h3 id=&quot;12-workit-landing-page-equalizer-landing-page-or-pod-request-access-landing-page&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/newbie-fm-challenge-order/#12-workit-landing-page-equalizer-landing-page-or-pod-request-access-landing-page&quot;&gt;&lt;span&gt;12. &lt;a href=&quot;https://www.frontendmentor.io/challenges/workit-landing-page-2fYnyle5lu&quot;&gt;Workit landing page&lt;/a&gt;, &lt;a href=&quot;https://www.frontendmentor.io/challenges/equalizer-landing-page-7VJ4gp3DE&quot;&gt;Equalizer landing page&lt;/a&gt;, or &lt;a href=&quot;https://www.frontendmentor.io/challenges/pod-request-access-landing-page-eyTmdkLSG&quot;&gt;Pod request access landing page&lt;/a&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;If you have PRO membership and want to practice more CSS and HTML in a bigger project, have a go at one or more of these landing pages.&lt;/p&gt;
&lt;div class=&quot;c-img-grid [ grid pull-out ]&quot; style=&quot;margin-block-end: var(--flow-space); --max: 15rem; --step-3: 0;&quot;&gt;
&lt;div&gt;
&lt;figure class=&quot;[ flex flex-col  ]&quot;&gt;&lt;picture&gt;&lt;source type=&quot;image/webp&quot; srcset=&quot;https://fedmentor.dev/posts/newbie-fm-challenge-order/13-workit-700w.webp 700w&quot; sizes=&quot;(min-width: 40rem) 50vw, 100vw&quot; /&gt;&lt;img alt=&quot;Workit landing page Challenge: Desktop design for a landing page with curved hero section background and slanted feature image&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; src=&quot;https://fedmentor.dev/posts/newbie-fm-challenge-order/13-workit-700w.jpeg&quot; width=&quot;700&quot; height=&quot;513&quot; /&gt;&lt;/picture&gt;&lt;/figure&gt;
&lt;/div&gt;&lt;div&gt;
&lt;figure class=&quot;[ flex flex-col  ]&quot;&gt;&lt;picture&gt;&lt;source type=&quot;image/webp&quot; srcset=&quot;https://fedmentor.dev/posts/newbie-fm-challenge-order/13-equalizer-700w.webp 700w&quot; sizes=&quot;(min-width: 40rem) 50vw, 100vw&quot; /&gt;&lt;img alt=&quot;Equalizer landing page Challenge: A landing page with colourful overlapping patterns, content and images&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; src=&quot;https://fedmentor.dev/posts/newbie-fm-challenge-order/13-equalizer-700w.jpeg&quot; width=&quot;700&quot; height=&quot;513&quot; /&gt;&lt;/picture&gt;&lt;/figure&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;figure class=&quot;[ flex flex-col  ]&quot;&gt;&lt;picture&gt;&lt;source type=&quot;image/webp&quot; srcset=&quot;https://fedmentor.dev/posts/newbie-fm-challenge-order/13-pod-700w.webp 700w&quot; sizes=&quot;(min-width: 40rem) 50vw, 100vw&quot; /&gt;&lt;img alt=&quot;Pod request access landing page Challenge: A dark landing page design with overlapping content and images, decorative motifs and an email sign up form&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; src=&quot;https://fedmentor.dev/posts/newbie-fm-challenge-order/13-pod-700w.jpeg&quot; width=&quot;700&quot; height=&quot;513&quot; /&gt;&lt;/picture&gt;&lt;/figure&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;These are &lt;strong&gt;great portfolio pieces&lt;/strong&gt; and will help weave everything you&#39;ve learned together. Think of it as a chance to stretch yourself on a bigger challenge, testing and embedding those skills!&lt;/p&gt;
&lt;hr /&gt;
&lt;h3 id=&quot;13-news-homepage&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/newbie-fm-challenge-order/#13-news-homepage&quot;&gt;&lt;span&gt;13. &lt;a href=&quot;https://www.frontendmentor.io/challenges/news-homepage-H6SWTa1MFl&quot;&gt;News homepage&lt;/a&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;div&gt;
&lt;figure class=&quot;[ flex flex-col  ]&quot;&gt;&lt;picture&gt;&lt;source type=&quot;image/webp&quot; srcset=&quot;https://fedmentor.dev/posts/newbie-fm-challenge-order/14-news-home-700w.webp 700w&quot; sizes=&quot;(min-width: 20em) 50vw&quot; /&gt;&lt;img alt=&quot;News homepage challenge: A complex full news landing page requiring a grid layout and some visually-hidden headings. There is a header with logo and nav, followed by a main with a large featured news post, highlighed new posts list, and ordered popular posts list&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; src=&quot;https://fedmentor.dev/posts/newbie-fm-challenge-order/14-news-home-700w.jpeg&quot; width=&quot;700&quot; height=&quot;513&quot; /&gt;&lt;/picture&gt;&lt;/figure&gt;
&lt;/div&gt;
&lt;p&gt;This is another great one for CSS grid and testing out your awareness of meaningful HTML structure. It needs careful planning (mobile first), should include visually hidden headings, and has the bonus of a mobile menu toggle.&lt;/p&gt;
&lt;p&gt;&lt;abbr class=&quot;[ no-underline undefined ]&quot; title=&quot;Alert emoji&quot;&gt;⚠️&lt;/abbr&gt; Make sure you get confident with how to code a &#39;disclosure pattern&#39; (like a mobile menu toggle) — It&#39;s something you will need to build countless times in your career and it is &lt;em&gt;easy&lt;/em&gt; to make accessible if you look up how!&lt;/p&gt;
&lt;hr /&gt;
&lt;h3 id=&quot;14-advice-generator-app&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/newbie-fm-challenge-order/#14-advice-generator-app&quot;&gt;&lt;span&gt;14. &lt;a href=&quot;https://www.frontendmentor.io/challenges/advice-generator-app-QdUG-13db&quot;&gt;Advice generator app&lt;/a&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;div&gt;
&lt;figure class=&quot;[ flex flex-col  ]&quot;&gt;&lt;picture&gt;&lt;source type=&quot;image/webp&quot; srcset=&quot;https://fedmentor.dev/posts/newbie-fm-challenge-order/15-advice-700w.webp 700w&quot; sizes=&quot;(min-width: 20em) 50vw&quot; /&gt;&lt;img alt=&quot;Advice generator app challenge: A dark design with a simple quote in the center that gets regenerated from an API on click of the dice&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; src=&quot;https://fedmentor.dev/posts/newbie-fm-challenge-order/15-advice-700w.jpeg&quot; width=&quot;700&quot; height=&quot;513&quot; /&gt;&lt;/picture&gt;&lt;/figure&gt;
&lt;/div&gt;
&lt;p&gt;As well as building on existing skills, this lets you practice fetching data from an API. That&#39;s super important in front end development!&lt;/p&gt;
&lt;p&gt;You&#39;ll also need to use:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;the aria-live attribute&lt;/li&gt;
&lt;li&gt;well-structured HTML&lt;/li&gt;
&lt;li&gt;accessible naming&lt;/li&gt;
&lt;/ul&gt;
&lt;hr /&gt;
&lt;h3 id=&quot;15-newsletter-sign-up-form-with-success-message&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/newbie-fm-challenge-order/#15-newsletter-sign-up-form-with-success-message&quot;&gt;&lt;span&gt;15. &lt;a href=&quot;https://www.frontendmentor.io/challenges/newsletter-signup-form-with-success-message-3FC1AZbNrv&quot;&gt;Newsletter sign up form with success message&lt;/a&gt;&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;div&gt;
&lt;figure class=&quot;[ flex flex-col  ]&quot;&gt;&lt;picture&gt;&lt;source type=&quot;image/webp&quot; srcset=&quot;https://fedmentor.dev/posts/newbie-fm-challenge-order/16-newsletter-700w.webp 700w&quot; sizes=&quot;(min-width: 20em) 50vw&quot; /&gt;&lt;img alt=&quot;Newsletter sign up form with success message challenge: A simple looking component with intro, benefits list and sign up form alongside an illustration. The real challenge comes from making this challenge accessible&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; src=&quot;https://fedmentor.dev/posts/newbie-fm-challenge-order/16-newsletter-700w.jpeg&quot; width=&quot;700&quot; height=&quot;513&quot; /&gt;&lt;/picture&gt;&lt;/figure&gt;
&lt;/div&gt;
&lt;p&gt;This one brings together some form validation and data use, styling challenges and content change announcements for assistive tech. A lovely little challenge!&lt;/p&gt;
&lt;hr /&gt;
&lt;h2 id=&quot;next-steps-months-later&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/newbie-fm-challenge-order/#next-steps-months-later&quot;&gt;&lt;span&gt;Next Steps (months later)&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;In case you haven&#39;t noticed, the list has moved on to junior-level challenges! These are more complex, in terms of layout, interactivity or accessibility. Choose any junior challenge that looks like it will stretch you in the specific area &lt;em&gt;you&lt;/em&gt; want to practice most. Hopefully, you&#39;ll be able to identify a good one for yourself from now.&lt;/p&gt;
&lt;p&gt;If I could recommend any &lt;em&gt;next&lt;/em&gt; step, beyond even these, it would be to attempt something with a theme toggle (or even add one to a challenge you&#39;ve already done!)&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Good luck, and have fun!&lt;/strong&gt;&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Product Preview Card</title>
		<link href="https://fedmentor.dev/posts/html-plan-product-preview/"/>
		<updated>2023-05-05T00:00:00Z</updated>
		<id>https://fedmentor.dev/posts/html-plan-product-preview/</id>
		<content type="html">&lt;h2 id=&quot;series-intro&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/html-plan-product-preview/#series-intro&quot;&gt;&lt;span&gt;Series Intro&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;I have been mentoring junior developers for years. In that time,  one issue comes up again and again. &lt;strong&gt;Courses for aspiring developers teach almost nothing about the importance of HTML structure!&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;So it&#39;s not your fault if you struggle with this! Bootcamps and tutorials skip over HTML like it&#39;s unimportant. But this process of translating designs into appropriate and meaningful HTML is the most important skill of all for developers who want to build accessibly.&lt;/p&gt;
&lt;p&gt;HTML is like the foundations of a building. If you get that wrong, issues are inevitable.&lt;/p&gt;
&lt;p&gt;That&#39;s why I&#39;m starting this series of posts. Each post will go step-by-step through the content of a Frontend Mentor design and write the HTML. I&#39;m not saying my way is the &lt;em&gt;only&lt;/em&gt; way to do a challenge. The goal is to help you build up your own &lt;strong&gt;&#39;semantic senses&#39;&lt;/strong&gt;. We&#39;ll learn the &lt;em&gt;thinking process&lt;/em&gt; behind choosing elements together. Over time I hope you&#39;ll find it easier to write appropriate HTML, even if it differs a bit from mine.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;I hope you find this helpful!&lt;/strong&gt;&lt;/p&gt;
&lt;hr /&gt;
&lt;h2 id=&quot;the-design&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/html-plan-product-preview/#the-design&quot;&gt;&lt;span&gt;The design&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;This post is going to look at a common design pattern: The &lt;a href=&quot;https://www.frontendmentor.io/challenges/product-preview-card-component-GO7UmttRfa&quot;&gt;Product Preview Card Component Challenge&lt;/a&gt;.&lt;/p&gt;
&lt;div class=&quot;c-img-grid c-img-grid--1-4 [ grid gap-1 pull-out ]&quot;&gt;
&lt;figure class=&quot;[ flex flex-col  ]&quot;&gt;&lt;picture&gt;&lt;source type=&quot;image/webp&quot; srcset=&quot;https://fedmentor.dev/posts/html-plan-product-preview/ppc-small-375w.webp 375w&quot; sizes=&quot;(min-width: 26rem) 70vw, 100vw&quot; /&gt;&lt;img alt=&quot;Mobile design: A vertcially stacked card with an image of a perfume bottle at the top, then a white background with ribbon text saying &#39;perfume&#39;, a title, paragraph and button&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; src=&quot;https://fedmentor.dev/posts/html-plan-product-preview/ppc-small-375w.jpeg&quot; width=&quot;375&quot; height=&quot;667&quot; /&gt;&lt;/picture&gt;&lt;figcaption class=&quot;[ grow text-center font-bold ]&quot;&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Caption: &lt;/span&gt;Small screen design&lt;/figcaption&gt;&lt;/figure&gt;
&lt;figure class=&quot;[ flex flex-col  ]&quot;&gt;&lt;picture&gt;&lt;source type=&quot;image/webp&quot; srcset=&quot;https://fedmentor.dev/posts/html-plan-product-preview/ppc-large-800w.webp 800w, https://fedmentor.dev/posts/html-plan-product-preview/ppc-large-1200w.webp 1200w&quot; sizes=&quot;(min-width: 26rem) 70vw, 100vw&quot; /&gt;&lt;source type=&quot;image/jpeg&quot; srcset=&quot;https://fedmentor.dev/posts/html-plan-product-preview/ppc-large-800w.jpeg 800w, https://fedmentor.dev/posts/html-plan-product-preview/ppc-large-1200w.jpeg 1200w&quot; sizes=&quot;(min-width: 26rem) 70vw, 100vw&quot; /&gt;&lt;img alt=&quot;Large screen design: A horizontally stacked card with an image of a perfume bottle on the side, then a white background with ribbon text saying &#39;perfume&#39;, a title, paragraph and button&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; src=&quot;https://fedmentor.dev/posts/html-plan-product-preview/ppc-large-800w.jpeg&quot; width=&quot;1200&quot; height=&quot;666&quot; /&gt;&lt;/picture&gt;&lt;figcaption class=&quot;[ grow text-center font-bold ]&quot;&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Caption: &lt;/span&gt;Large screen design&lt;/figcaption&gt;&lt;/figure&gt;
&lt;/div&gt;
&lt;p&gt;It&#39;s rare we should ever need to duplicate HTML, meaning it will be the same for all screen sizes.For the rest of this post, I&#39;ll be annotating the &lt;em&gt;mobile/small screen&lt;/em&gt; design in images. Just be aware that the notes apply everywhere, because there would only be ONE set of HTML.&lt;/p&gt;
&lt;p&gt;Also note that in card examples, I&#39;ll be adding &lt;strong&gt;BEM&lt;/strong&gt;-style classes &lt;em&gt;(Read &lt;a href=&quot;https://css-tricks.com/bem-101/&quot;&gt;&#39;BEM 101&#39; on CSS Tricks&lt;/a&gt; if you&#39;re curious)&lt;/em&gt;. You don&#39;t have to do this and I don&#39;t always do this. But it should make it easier for you to see at a glance which bit of content each element relates to.&lt;/p&gt;
&lt;h2 id=&quot;landmarks&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/html-plan-product-preview/#landmarks&quot;&gt;&lt;span&gt;Landmarks&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Landmarks are elements are: &lt;code&gt;header&lt;/code&gt;, &lt;code&gt;main&lt;/code&gt;, &lt;code&gt;aside&lt;/code&gt; and &lt;code&gt;footer&lt;/code&gt;. All page content should sit within landmarks.&lt;/p&gt;
&lt;div class=&quot;no-print&quot;&gt;
  &lt;details class=&quot;c-details&quot;&gt;
    &lt;summary class=&quot;c-details__summary [ relative bg-bar ]&quot; id=&quot;article-section&quot;&gt;
      &lt;strong class=&quot;c-details__title [ font-base text-body h4 ]&quot;&gt;What about Article and Section?&lt;/strong&gt;
    &lt;/summary&gt;
    &lt;div class=&quot;c-details__content [ flow bg-body text-body ]&quot;&gt;&lt;p&gt;You may also be aware of &lt;code&gt;article&lt;/code&gt; and &lt;code&gt;section&lt;/code&gt;, which are often referred to as &amp;quot;landmarks&amp;quot;. But they are a bit different, and not page-level landmarks in my opinion.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;These almost always sit inside the &lt;code&gt;main&lt;/code&gt; landmark&lt;/li&gt;
&lt;li&gt;For the accessibility API to recognise them as landmarks, they need to have &lt;strong&gt;an accessible name&lt;/strong&gt;. That means having a heading and using &lt;code&gt;aria-labelledby&lt;/code&gt; or using &lt;code&gt;aria-label&lt;/code&gt;. Without that, they are treated just like &lt;code&gt;div&lt;/code&gt;s.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Section in particular, is often misunderstood! I&#39;ll post about these elements another time. For now, I prefer to exclude them when thinking about the &#39;top level&#39; landmarks on a page.&lt;/p&gt;
&lt;/div&gt;
  &lt;/details&gt;
&lt;/div&gt;
&lt;div class=&quot;c-details print-only&quot;&gt;
  &lt;h4&gt;What about Article and Section?&lt;/h4&gt;
  &lt;div class=&quot;c-details__content flow&quot;&gt;&lt;p&gt;You may also be aware of &lt;code&gt;article&lt;/code&gt; and &lt;code&gt;section&lt;/code&gt;, which are often referred to as &amp;quot;landmarks&amp;quot;. But they are a bit different, and not page-level landmarks in my opinion.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;These almost always sit inside the &lt;code&gt;main&lt;/code&gt; landmark&lt;/li&gt;
&lt;li&gt;For the accessibility API to recognise them as landmarks, they need to have &lt;strong&gt;an accessible name&lt;/strong&gt;. That means having a heading and using &lt;code&gt;aria-labelledby&lt;/code&gt; or using &lt;code&gt;aria-label&lt;/code&gt;. Without that, they are treated just like &lt;code&gt;div&lt;/code&gt;s.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Section in particular, is often misunderstood! I&#39;ll post about these elements another time. For now, I prefer to exclude them when thinking about the &#39;top level&#39; landmarks on a page.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;This is a &lt;strong&gt;single component challenge&lt;/strong&gt;, so we only need a &lt;code&gt;main&lt;/code&gt; landmark to wrap the design. You may also need a &lt;code&gt;footer&lt;/code&gt; landmark below this for attribution back to the FrontEnd Mentor site. &lt;em&gt;(Attribution is not shown on the design above, but the content is provided when you download the starter files.)&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;abbr class=&quot;[ no-underline undefined ]&quot; title=&quot;unknown emoji&quot;&gt;👉🏼&lt;/abbr&gt; General rule: Every webpage should at least have a &lt;code&gt;main&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id=&quot;the-card&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/html-plan-product-preview/#the-card&quot;&gt;&lt;span&gt;The Card&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;This is a chunk of related content. As such, it would be completely valid to make the card a &lt;code&gt;section&lt;/code&gt; or &lt;code&gt;article&lt;/code&gt; if you wanted to. But, I think that&#39;s &lt;strong&gt;unnecessary&lt;/strong&gt; / optional for this specific card component.&lt;/p&gt;
&lt;p&gt;Let&#39;s think about how this component would be used on a real site... I envisage a scenario where there would be loads of these cards on one page. In fact, that&#39;s very likely for this kind of content.&lt;/p&gt;
&lt;p&gt;Cards like this are often displayed in a grid or row of several. The HTML for &lt;em&gt;that&lt;/em&gt; is usually a list, so that screen readers can announce how many product cards there are. For example:&lt;/p&gt;
&lt;pre class=&quot;language-html&quot; tabindex=&quot;0&quot; data-language=&quot;html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;ul&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;product-card-grid&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;product-card-grid__item&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- Product Card goes here --&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;product-card-grid__item&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- Product Card goes here --&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;product-card-grid__item&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- Product Card goes here --&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;li&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;product-card-grid__item&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- Product Card goes here --&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;li&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;ul&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Personally, I think that using a labelled &lt;code&gt;article&lt;/code&gt; (or &lt;code&gt;section&lt;/code&gt;) inside each of these list items creates a load of extra &#39;semantic  noise&#39; and seems unnecessary. The headings inside each card already give the content plenty of  meaningful structure.&lt;/p&gt;
&lt;p&gt;Hence, I&#39;ll make the component a plain old div!&lt;/p&gt;
&lt;pre class=&quot;language-html&quot; tabindex=&quot;0&quot; data-language=&quot;html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;c-product-card&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- Content here --&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;no-print&quot;&gt;
  &lt;details class=&quot;c-details&quot;&gt;
    &lt;summary class=&quot;c-details__summary [ relative bg-bar ]&quot;&gt;
      &lt;strong class=&quot;c-details__title [ font-base text-body h4 ]&quot;&gt;When is a section or article better?&lt;/strong&gt;
    &lt;/summary&gt;
    &lt;div class=&quot;c-details__content [ flow bg-body text-body ]&quot;&gt;&lt;p&gt;This needs it&#39;s own blog post really, but in short: Only use a labelled section or article for a card like this if it has multiple controls within it, and the card may repeat multiple times on a page.&lt;/p&gt;
&lt;p&gt;For example, if this product card had&lt;/p&gt;
&lt;/div&gt;
  &lt;/details&gt;
&lt;/div&gt;
&lt;div class=&quot;c-details print-only&quot;&gt;
  &lt;h4&gt;When is a section or article better?&lt;/h4&gt;
  &lt;div class=&quot;c-details__content flow&quot;&gt;&lt;p&gt;This needs it&#39;s own blog post really, but in short: Only use a labelled section or article for a card like this if it has multiple controls within it, and the card may repeat multiple times on a page.&lt;/p&gt;
&lt;p&gt;For example, if this product card had&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;If you&#39;d still rather use &lt;code&gt;article&lt;/code&gt; or &lt;code&gt;section&lt;/code&gt;, the HTML would need to look like this, with an accessible name for that section to be recognised in the accessibility tree.&lt;/p&gt;
&lt;pre class=&quot;language-html&quot; tabindex=&quot;0&quot; data-language=&quot;html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;section&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;c-product-card&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token attr-name&quot;&gt;aria-labelledby&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;cardTitle-087633-282652-2267757862-67262&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- Content here --&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;section&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;aside class=&quot;c-aside c-aside--info [ relative text-body ]&quot; aria-labelledby=&quot;7498dce0-8188-4d69-bee6-fe92a33dc78e&quot;&gt;
  &lt;div class=&quot;c-aside__icon [ grid place-content-center ]&quot;&gt;
    &lt;svg aria-hidden=&quot;true&quot; focusable=&quot;false&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;var(--icon-fill, var(--post-bg))&quot; stroke=&quot;var(--icon-stroke, var(--rainbow--teal))&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;[ h-full w-full ]&quot;&gt;&lt;circle cx=&quot;12&quot; cy=&quot;12&quot; r=&quot;10&quot;&gt;&lt;/circle&gt;&lt;line x1=&quot;12&quot; y1=&quot;16&quot; x2=&quot;12&quot; y2=&quot;12&quot;&gt;&lt;/line&gt;&lt;line x1=&quot;12&quot; y1=&quot;8&quot; x2=&quot;12.01&quot; y2=&quot;8&quot;&gt;&lt;/line&gt;&lt;/svg&gt;
  &lt;/div&gt;
  &lt;div class=&quot;c-aside__content flow&quot;&gt;&lt;strong id=&quot;7498dce0-8188-4d69-bee6-fe92a33dc78e&quot; class=&quot;c-aside__title [  block font-heading leading-tight no-underline uppercase tracking-wide text-sm ]&quot;&gt;Unique ID warning&lt;/strong&gt;&lt;div class=&quot;flow&quot;&gt;&lt;p&gt;Note, the &lt;code&gt;aria-labelledby&lt;/code&gt; in this last example would have to point to the &lt;code&gt;ID&lt;/code&gt; of the card title. This can be more complex than it looks! It&#39;s essential for the ID to be unique on every &lt;em&gt;instance&lt;/em&gt; of the card, which can be tricky to do depending on your tech set up.&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;/aside&gt;
&lt;p&gt;&lt;em&gt;Inside&lt;/em&gt; the card we need to set up two containers, one for the image part and one for the text part. Here&#39;s where my HTML markup ends up so far:&lt;/p&gt;
&lt;pre class=&quot;language-html&quot; tabindex=&quot;0&quot; data-language=&quot;html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;main&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- Card could be a labelled article/section if you prefer --&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;c-product-card&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;c-product-card__img-half&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;c-product-card__text-half&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;main&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;h2 id=&quot;product-image&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/html-plan-product-preview/#product-image&quot;&gt;&lt;span&gt;Product Image&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;You can see in the design and starter files, this component has different images for small and large screens.&lt;/p&gt;
&lt;div class=&quot;c-img-grid [ grid gap-1 pull-out ]&quot;&gt;
&lt;figure class=&quot;[ flex flex-col  ]&quot;&gt;&lt;picture&gt;&lt;source type=&quot;image/webp&quot; srcset=&quot;https://fedmentor.dev/posts/html-plan-product-preview/image-product-mobile-686w.webp 686w&quot; sizes=&quot;(min-width: 26rem) 70vw, 100vw&quot; /&gt;&lt;img alt=&quot;Perfume bottle in the center of a small landscape-orientation picture&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; src=&quot;https://fedmentor.dev/posts/html-plan-product-preview/image-product-mobile-686w.jpeg&quot; width=&quot;686&quot; height=&quot;480&quot; /&gt;&lt;/picture&gt;&lt;figcaption class=&quot;[ grow text-center font-bold ]&quot;&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Caption: &lt;/span&gt;Small screen product image&lt;/figcaption&gt;&lt;/figure&gt;
&lt;figure class=&quot;[ flex flex-col  ]&quot;&gt;&lt;picture&gt;&lt;source type=&quot;image/webp&quot; srcset=&quot;https://fedmentor.dev/posts/html-plan-product-preview/image-product-desktop-600w.webp 600w&quot; sizes=&quot;(min-width: 26rem) 70vw, 100vw&quot; /&gt;&lt;img alt=&quot;Perfume bottle in the center of a larger portrait-orientation picture&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; src=&quot;https://fedmentor.dev/posts/html-plan-product-preview/image-product-desktop-600w.jpeg&quot; width=&quot;600&quot; height=&quot;900&quot; /&gt;&lt;/picture&gt;&lt;figcaption class=&quot;[ grow text-center font-bold ]&quot;&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Caption: &lt;/span&gt;Larger sceen product image&lt;/figcaption&gt;&lt;/figure&gt;
&lt;/div&gt;
&lt;p&gt;&lt;abbr class=&quot;[ no-underline undefined ]&quot; title=&quot;unknown emoji&quot;&gt;🤔&lt;/abbr&gt; You may be tempted to use &lt;strong&gt;background images&lt;/strong&gt; here, but that&#39;s a bad idea because:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;This is a &lt;em&gt;meaningful&lt;/em&gt; image. Product images should always have a proper description in the alt attribute.&lt;/li&gt;
&lt;li&gt;Background images are usually less performant. They involve a call to the server for the CSS, then another call to fetch the image.&lt;/li&gt;
&lt;li&gt;Background images create a worse user experience, because the user&#39;s device will download &lt;em&gt;all&lt;/em&gt; of them, even if some are hidden (i.e. irrelevant for their screen size).&lt;/li&gt;
&lt;li&gt;You&#39;ll have to write extra CSS to show/hide each image.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;abbr class=&quot;[ no-underline undefined ]&quot; title=&quot;unknown emoji&quot;&gt;🤔&lt;/abbr&gt; Or, you may consider using &lt;strong&gt;two image elements&lt;/strong&gt;, with classes  on each to show/hide them in a CSS media query.  That&#39;s a bad idea too.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;It&#39;s bad for performance. Much like background images, the browser will download &lt;em&gt;both&lt;/em&gt; images no matter what size screen you are using to view the site.&lt;/li&gt;
&lt;li&gt;You&#39;ll have to write extra CSS to show/hide each image.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;abbr class=&quot;[ no-underline undefined ]&quot; title=&quot;unknown emoji&quot;&gt;🤔&lt;/abbr&gt; So what is the solution...?&lt;/p&gt;
&lt;p&gt;&lt;mark&gt;This is the perfect time to &lt;strong&gt;use the &lt;code&gt;&amp;lt;picture&amp;gt;&lt;/code&gt; element!&lt;/strong&gt;&lt;/mark&gt;&lt;/p&gt;
&lt;p&gt;Check out the &lt;a href=&quot;https://developer.mozilla.org/en-US/docs/Web/HTML/Element/picture&quot;&gt;picture element on MDN&lt;/a&gt; if you&#39;re not already familiar with it. It is one of my favourite elements and is great for performance. &lt;em&gt;(Yes, I have favourite elements!)&lt;/em&gt; Only the image you need for your screen size/resolution gets downloaded. And this happens all through pure HTML. So simple.&lt;/p&gt;
&lt;div class=&quot;no-print&quot;&gt;
  &lt;details class=&quot;c-details&quot;&gt;
    &lt;summary class=&quot;c-details__summary [ relative bg-bar ]&quot;&gt;
      &lt;strong class=&quot;c-details__title [ font-base text-body h4 ]&quot;&gt;Notes on the picture element&lt;/strong&gt;
    &lt;/summary&gt;
    &lt;div class=&quot;c-details__content [ flow bg-body text-body ]&quot;&gt;&lt;p&gt;Just as we should style mobile first, I recommend using the picture element &#39;mobile first&#39; too.&lt;/p&gt;
&lt;p&gt;In other words, &lt;strong&gt;put the image for the smallest screen the src in the &lt;code&gt;img&lt;/code&gt; element&lt;/strong&gt;. Then put images for larger screens in the &lt;abbr title=&quot;source-set&quot;&gt;srcset&lt;/abbr&gt; of the &lt;code&gt;source&lt;/code&gt; element(s).&lt;/p&gt;
&lt;p&gt;Also note, if you ever need more than one &lt;code&gt;source&lt;/code&gt; element inside a picture, they will need to be in the &lt;strong&gt;correct order&lt;/strong&gt;. For example:&lt;/p&gt;
&lt;pre class=&quot;language-html&quot; tabindex=&quot;0&quot; data-language=&quot;html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;picture&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- largest image --&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;source&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;srcset&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;/media/images/decorative-image-3.jpg&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token attr-name&quot;&gt;media&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;(min-width: 60rem)&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- medium image --&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;source&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;srcset&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;/media/images/decorative-image-2.jpg&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token attr-name&quot;&gt;media&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;(min-width: 40rem)&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- smallest image (default) --&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;img&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;/media/images/decorative-image-1.jpg&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;alt&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;picture&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
  &lt;/details&gt;
&lt;/div&gt;
&lt;div class=&quot;c-details print-only&quot;&gt;
  &lt;h4&gt;Notes on the picture element&lt;/h4&gt;
  &lt;div class=&quot;c-details__content flow&quot;&gt;&lt;p&gt;Just as we should style mobile first, I recommend using the picture element &#39;mobile first&#39; too.&lt;/p&gt;
&lt;p&gt;In other words, &lt;strong&gt;put the image for the smallest screen the src in the &lt;code&gt;img&lt;/code&gt; element&lt;/strong&gt;. Then put images for larger screens in the &lt;abbr title=&quot;source-set&quot;&gt;srcset&lt;/abbr&gt; of the &lt;code&gt;source&lt;/code&gt; element(s).&lt;/p&gt;
&lt;p&gt;Also note, if you ever need more than one &lt;code&gt;source&lt;/code&gt; element inside a picture, they will need to be in the &lt;strong&gt;correct order&lt;/strong&gt;. For example:&lt;/p&gt;
&lt;pre class=&quot;language-html&quot; tabindex=&quot;0&quot; data-language=&quot;html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;picture&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- largest image --&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;source&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;srcset&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;/media/images/decorative-image-3.jpg&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token attr-name&quot;&gt;media&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;(min-width: 60rem)&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- medium image --&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;source&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;srcset&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;/media/images/decorative-image-2.jpg&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;      &lt;span class=&quot;token attr-name&quot;&gt;media&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;(min-width: 40rem)&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- smallest image (default) --&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;img&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;/media/images/decorative-image-1.jpg&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;alt&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;picture&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;So now our HTML should look like something like this &lt;em&gt;(&lt;code&gt;...&lt;/code&gt; denotes where content needs adding)&lt;/em&gt;:&lt;/p&gt;
&lt;pre class=&quot;language-html&quot; tabindex=&quot;0&quot; data-language=&quot;html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;main&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;c-product-card&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;c-product-card__img-half&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;picture&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;        &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;source&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;srcset&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;...&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;media&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;...&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;        &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;img&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;          &lt;span class=&quot;token attr-name&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;...&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;          &lt;span class=&quot;token attr-name&quot;&gt;alt&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;...&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;          &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;c-product-card__img&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;/&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;picture&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;c-product-card__text-half&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;main&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;aside class=&quot;c-aside c-aside--alert [ relative text-body ]&quot; aria-labelledby=&quot;4bf95a4b-3c7b-4bd9-9aca-88efc79747ba&quot;&gt;
  &lt;div class=&quot;c-aside__icon [ grid place-content-center ]&quot;&gt;
    &lt;svg 2000=&quot;&quot; aria-hidden=&quot;true&quot; focusable=&quot;false xmlns=&quot; http:=&quot;&quot; www.w3.org=&quot;&quot; svg&quot;=&quot;&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;var(--icon-fill, var(--post-bg))&quot; stroke=&quot;var(--icon-stroke, var(--rainbow--teal))&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;[ h-full w-full ]&quot;&gt;&lt;polygon points=&quot;7.86 2 16.14 2 22 7.86 22 16.14 16.14 22 7.86 22 2 16.14 2 7.86 7.86 2&quot;&gt;&lt;/polygon&gt;&lt;line x1=&quot;12&quot; y1=&quot;8&quot; x2=&quot;12&quot; y2=&quot;12&quot;&gt;&lt;/line&gt;&lt;line x1=&quot;12&quot; y1=&quot;16&quot; x2=&quot;12.01&quot; y2=&quot;16&quot;&gt;&lt;/line&gt;&lt;/svg&gt;
  &lt;/div&gt;
  &lt;div class=&quot;c-aside__content flow&quot;&gt;&lt;strong id=&quot;4bf95a4b-3c7b-4bd9-9aca-88efc79747ba&quot; class=&quot;c-aside__title [  block font-heading leading-tight no-underline uppercase tracking-wide text-sm ]&quot;&gt;Don&#39;t forget the alt!&lt;/strong&gt;&lt;div class=&quot;flow&quot;&gt;&lt;p&gt;This image is &lt;strong&gt;important content&lt;/strong&gt; so must have a proper alt description. It should communicate the same &lt;em&gt;value&lt;/em&gt; as the image does to those who can see it.&lt;/p&gt;
&lt;p&gt;For product images on e-commerce sites, that usually means communicating the key product features that are being shown off by the image.&lt;/p&gt;
&lt;p&gt;For more on how and when to write &lt;code&gt;alt&lt;/code&gt; on images, check out &lt;strong&gt;Craig Abbott&lt;/strong&gt;&#39;s excellent blog post &lt;a href=&quot;https://www.craigabbott.co.uk/blog/how-to-write-good-alt-text-for-screen-readers/&quot;&gt;How to write good alt text for screen readers&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;/aside&gt;
&lt;h2 id=&quot;card-title&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/html-plan-product-preview/#card-title&quot;&gt;&lt;span&gt;Card Title&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;figure class=&quot;[ flex flex-col  ]&quot;&gt;&lt;picture&gt;&lt;source type=&quot;image/webp&quot; srcset=&quot;https://fedmentor.dev/posts/html-plan-product-preview/title-323w.webp 323w&quot; sizes=&quot;(min-width: 20em) 50vw&quot; /&gt;&lt;img alt=&quot;The ribbon text that says &#39;perfume&#39; in capitals, followed by larger title text that says the name of the perfume&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; src=&quot;https://fedmentor.dev/posts/html-plan-product-preview/title-323w.jpeg&quot; width=&quot;323&quot; height=&quot;115&quot; /&gt;&lt;/picture&gt;&lt;/figure&gt;
&lt;p&gt;Which do you think is the main title of the card?&lt;/p&gt;
&lt;p&gt;The word &amp;quot;Perfume&amp;quot; is in a small, pale font with uppercase text and increased letter-spacing. This is usually called &lt;strong&gt;&amp;quot;Ribbon text&amp;quot;&lt;/strong&gt; in the design world.&lt;/p&gt;
&lt;p&gt;This doesn&#39;t make sense as a heading. Headings should always go in a sequential order  &lt;em&gt;(I&#39;ll write more about that separately)&lt;/em&gt;. That means this little category would need to have a &lt;em&gt;higher&lt;/em&gt; (i.e. more important) heading level than the product name below it.&lt;/p&gt;
&lt;p&gt;Also, imagine a  load of these product cards on a page. It wouldn&#39;t make sense to have repeating categories for content structure:&lt;/p&gt;
&lt;pre class=&quot;language-html&quot; tabindex=&quot;0&quot; data-language=&quot;html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;h2: &quot;Perfume&quot;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;h2: &quot;Perfume&quot;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;h2: &quot;Perfume&quot;...&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;mark&gt;The product name is bigger, bolder, darker and makes much more sense as a unique heading!&lt;/mark&gt;&lt;/p&gt;
&lt;p&gt;Some may argue that in this case it would be better to keep them  both as headings. Or place them together in one heading, using spans to  style each line. Or change the DOM order so screen readers announce &amp;quot;Perfume&amp;quot; &lt;em&gt;after&lt;/em&gt; the heading.&lt;/p&gt;
&lt;p&gt;None of that is necessary. The ribbon text is fine as a &lt;strong&gt;paragraph&lt;/strong&gt; and the product name a &lt;strong&gt;heading&lt;/strong&gt;.&lt;/p&gt;
&lt;div class=&quot;no-print&quot;&gt;
  &lt;details class=&quot;c-details&quot;&gt;
    &lt;summary class=&quot;c-details__summary [ relative bg-bar ]&quot;&gt;
      &lt;strong class=&quot;c-details__title [ font-base text-body h4 ]&quot;&gt;What heading level to choose?&lt;/strong&gt;
    &lt;/summary&gt;
    &lt;div class=&quot;c-details__content [ flow bg-body text-body ]&quot;&gt;&lt;p&gt;If this  was a real project, we would have more context for this design. We would  know the surrounding page content and have a better idea of where this component sits within the content hierarchy. &lt;em&gt;That&lt;/em&gt; would guide what heading level we choose.&lt;/p&gt;
&lt;p&gt;But we don&#39;t have that in this case. All we have is a basic design. My default is to opt for the &lt;strong&gt;highest heading level&lt;/strong&gt; you think this component &lt;em&gt;could&lt;/em&gt; have.&lt;/p&gt;
&lt;p&gt;There&#39;s always going to be a &lt;code&gt;h1&lt;/code&gt; on the page. So I&#39;d give this card a &lt;code&gt;h2&lt;/code&gt; for now. I can always change it to a &lt;code&gt;h3&lt;/code&gt; later if needed.&lt;/p&gt;
&lt;p&gt;See related post: &lt;a href=&quot;https://fedmentor.dev/posts/heading-order/&quot;&gt;Why heading order matters in HTML&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
  &lt;/details&gt;
&lt;/div&gt;
&lt;div class=&quot;c-details print-only&quot;&gt;
  &lt;h4&gt;What heading level to choose?&lt;/h4&gt;
  &lt;div class=&quot;c-details__content flow&quot;&gt;&lt;p&gt;If this  was a real project, we would have more context for this design. We would  know the surrounding page content and have a better idea of where this component sits within the content hierarchy. &lt;em&gt;That&lt;/em&gt; would guide what heading level we choose.&lt;/p&gt;
&lt;p&gt;But we don&#39;t have that in this case. All we have is a basic design. My default is to opt for the &lt;strong&gt;highest heading level&lt;/strong&gt; you think this component &lt;em&gt;could&lt;/em&gt; have.&lt;/p&gt;
&lt;p&gt;There&#39;s always going to be a &lt;code&gt;h1&lt;/code&gt; on the page. So I&#39;d give this card a &lt;code&gt;h2&lt;/code&gt; for now. I can always change it to a &lt;code&gt;h3&lt;/code&gt; later if needed.&lt;/p&gt;
&lt;p&gt;See related post: &lt;a href=&quot;https://fedmentor.dev/posts/heading-order/&quot;&gt;Why heading order matters in HTML&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Here&#39;s where the markup is so far:&lt;/p&gt;
&lt;pre class=&quot;language-html&quot; tabindex=&quot;0&quot; data-language=&quot;html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;main&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;c-product-card&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;c-product-card__img-half&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;picture&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;...&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;picture&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;c-product-card__text-half&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;p&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;c-product-card__ribbon ribbon-text&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Perfume&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;p&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;h2&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;c-product-card__title&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Gabrielle Essencce Eau De Parfum&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;h2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;main&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;aside class=&quot;c-aside c-aside--alert [ relative text-body ]&quot; aria-labelledby=&quot;471b7869-a273-4c61-a620-dfaa7f25c7e4&quot;&gt;
  &lt;div class=&quot;c-aside__icon [ grid place-content-center ]&quot;&gt;
    &lt;svg 2000=&quot;&quot; aria-hidden=&quot;true&quot; focusable=&quot;false xmlns=&quot; http:=&quot;&quot; www.w3.org=&quot;&quot; svg&quot;=&quot;&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;var(--icon-fill, var(--post-bg))&quot; stroke=&quot;var(--icon-stroke, var(--rainbow--teal))&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;[ h-full w-full ]&quot;&gt;&lt;polygon points=&quot;7.86 2 16.14 2 22 7.86 22 16.14 16.14 22 7.86 22 2 16.14 2 7.86 7.86 2&quot;&gt;&lt;/polygon&gt;&lt;line x1=&quot;12&quot; y1=&quot;8&quot; x2=&quot;12&quot; y2=&quot;12&quot;&gt;&lt;/line&gt;&lt;line x1=&quot;12&quot; y1=&quot;16&quot; x2=&quot;12.01&quot; y2=&quot;16&quot;&gt;&lt;/line&gt;&lt;/svg&gt;
  &lt;/div&gt;
  &lt;div class=&quot;c-aside__content flow&quot;&gt;&lt;strong id=&quot;471b7869-a273-4c61-a620-dfaa7f25c7e4&quot; class=&quot;c-aside__title [  block font-heading leading-tight no-underline uppercase tracking-wide text-sm ]&quot;&gt;Capitalisation&lt;/strong&gt;&lt;div class=&quot;flow&quot;&gt;&lt;p&gt;&lt;strong&gt;Note how I have &lt;em&gt;not&lt;/em&gt; capitalised the ribbon text in the HTML.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;When you need to do this, always use CSS to transform the text to uppercase: &lt;code&gt;text-transform: uppercase&lt;/code&gt;. This is because&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;The design may change later. You don&#39;t want to have to manually change this text at the content layer!&lt;/li&gt;
&lt;li&gt;Capitals are harder to read. If users change their font settings, or even block the CSS you want to make sure the content remains readable.&lt;/li&gt;
&lt;li&gt;In all likelihood in real sites, you won&#39;t be hard-coding content anyway. Content is often stored elsewhere.&lt;/li&gt;
&lt;li&gt;I&#39;ve heard that some screen readers will read out capitalised HTML letter-by-letter, as if it is an acronym. I&#39;ve not experienced this myself on VoiceOver and cannot find the source of that information! But I figure it&#39;s better to follow the advice, just in case.&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;/aside&gt;
&lt;p&gt;It may bother you that this ribbon text — which does look sort of &#39;titley&#39; — is only a paragraph. There is one more thing you &lt;em&gt;could&lt;/em&gt; do to make it stand out when looking at the code... add a &lt;code&gt;hgroup&lt;/code&gt; wrapper:&lt;/p&gt;
&lt;pre class=&quot;language-html&quot; tabindex=&quot;0&quot; data-language=&quot;html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;c-product-card__text-half&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;hgroup&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;c-product-card__title-group&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;p&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;c-product-card__ribbon ribbon-text&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Perfume&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;p&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;h2&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;c-product-card__title&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Gabrielle Essencce Eau De Parfum&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;h2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;hgroup&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;abbr class=&quot;[ no-underline undefined ]&quot; title=&quot;Warning emoji&quot;&gt;⚠️&lt;/abbr&gt; However, having a &lt;code&gt;hgroup&lt;/code&gt; in the HTML &lt;strong&gt;doesn&#39;t improve the  accessibility of this in any way&lt;/strong&gt;. This is the perfect use case for the element. It&#39;s what it exists to do, and it does group the titles together nicely when reading the code.&lt;/p&gt;
&lt;p&gt;BUT, it &lt;strong&gt;makes the styling more difficult&lt;/strong&gt;. If you wanted to add consistent vertical spacing between the card&#39;s direct children with &lt;code&gt;margin-top&lt;/code&gt; (or  &lt;code&gt;gap&lt;/code&gt; with CSS grid or flexbox), adding in that extra wrapper means you have to re-apply or repeat that styling within it.&lt;/p&gt;
&lt;p&gt;So, it may make the code nicer to read, but it brings no benefit to end users and could make the styling more complex. With all that in mind, it&#39;s up to you if you want to use it.&lt;/p&gt;
&lt;aside class=&quot;c-aside c-aside--update [ relative text-body ]&quot; aria-labelledby=&quot;3c774b0b-2f07-4556-9d0d-5971e751afae&quot;&gt;
  &lt;div class=&quot;c-aside__icon [ grid place-content-center ]&quot;&gt;
    &lt;svg aria-hidden=&quot;true&quot; focusable=&quot;false&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;var(--icon-fill, var(--post-bg))&quot; stroke=&quot;var(--icon-stroke, var(--rainbow--teal))&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;[ h-full w-full ]&quot;&gt;&lt;polygon points=&quot;12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2&quot;&gt;&lt;/polygon&gt;&lt;/svg&gt;
  &lt;/div&gt;
  &lt;div class=&quot;c-aside__content flow&quot;&gt;&lt;strong id=&quot;3c774b0b-2f07-4556-9d0d-5971e751afae&quot; class=&quot;c-aside__title [  block font-heading leading-tight no-underline uppercase tracking-wide text-sm ]&quot;&gt;Update: Jan. 2025&lt;/strong&gt;&lt;div class=&quot;flow&quot;&gt;&lt;p&gt;I used to include the &lt;code&gt;hgroup&lt;/code&gt; in the HTML code of this post, but have since decided to remove it. There really is no benefit I can find except a developer &lt;em&gt;wanting&lt;/em&gt; to group these two elements.&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;/aside&gt;
&lt;h2 id=&quot;product-description&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/html-plan-product-preview/#product-description&quot;&gt;&lt;span&gt;Product description&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;This is a paragraph. No discussion needed!&lt;/p&gt;
&lt;p&gt;Try to avoid ever placing text in &lt;code&gt;div&lt;/code&gt;s or &lt;code&gt;span&lt;/code&gt;s alone, as they are meaningless elements only intended for layout / styling purposes. Use a paragraph and it means screen reader users can easily read paragraph-by-paragraph if they want to (instead of line-by-line or heading-by-heading etc).&lt;/p&gt;
&lt;h2 id=&quot;prices&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/html-plan-product-preview/#prices&quot;&gt;&lt;span&gt;Prices&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;There&#39;s another little accessibility challenge in this, because the design includes &lt;em&gt;two&lt;/em&gt; prices. One is large and bold. The other is small and has a line through it, like it&#39;s crossed out.&lt;/p&gt;
&lt;p&gt;Think about what happens if you can&#39;t &lt;em&gt;see&lt;/em&gt; that though... Screen reader software would read out &lt;em&gt;both&lt;/em&gt; prices! Pretty confusing, don&#39;t you think?&lt;/p&gt;
&lt;p&gt;The good news is there is some HTML designed for this situation. The bad news is we still have to do some extra work to make sure screen reader users know which is the old price.&lt;/p&gt;
&lt;p&gt;Here&#39;s my initial HTML for the price:&lt;/p&gt;
&lt;pre class=&quot;language-html&quot; tabindex=&quot;0&quot; data-language=&quot;html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;p&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;c-product-card__prices&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;$149.99&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- The &amp;lt;del&gt; element could also be a good choice instead of &amp;lt;s&gt; --&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;s&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;$169.99&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;s&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;p&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;As you can see, I&#39;ve opted for the &lt;code&gt;&amp;lt;s&amp;gt;&lt;/code&gt; element to wrap the old price. That means &amp;quot;strike-through&amp;quot;, which describes the style in the design. You could use the &lt;code&gt;&amp;lt;del&amp;gt;&lt;/code&gt; element instead, which means &amp;quot;deletion&amp;quot;. That makes sense too as the old price has kind of been &#39;deleted&#39;.&lt;/p&gt;
&lt;p&gt;To make sure that screen reader users know which is the old price, you can tackle it in two ways:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;In the HTML via &lt;code&gt;span&lt;/code&gt; with a class (commonly known as &lt;code&gt;sr-only&lt;/code&gt; or &lt;code&gt;visually-hidden&lt;/code&gt;) to accessibly hide some label text .&lt;/li&gt;
&lt;li&gt;In the CSS with a a pseudo element &lt;em&gt;and&lt;/em&gt; the same CSS snippet to accessibly hide the label&lt;/li&gt;
&lt;/ol&gt;
&lt;aside class=&quot;c-aside c-aside--alert [ relative text-body ]&quot; aria-labelledby=&quot;6c57b8fe-7c01-47b2-9319-032e54a63d00&quot;&gt;
  &lt;div class=&quot;c-aside__icon [ grid place-content-center ]&quot;&gt;
    &lt;svg 2000=&quot;&quot; aria-hidden=&quot;true&quot; focusable=&quot;false xmlns=&quot; http:=&quot;&quot; www.w3.org=&quot;&quot; svg&quot;=&quot;&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;var(--icon-fill, var(--post-bg))&quot; stroke=&quot;var(--icon-stroke, var(--rainbow--teal))&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;[ h-full w-full ]&quot;&gt;&lt;polygon points=&quot;7.86 2 16.14 2 22 7.86 22 16.14 16.14 22 7.86 22 2 16.14 2 7.86 7.86 2&quot;&gt;&lt;/polygon&gt;&lt;line x1=&quot;12&quot; y1=&quot;8&quot; x2=&quot;12&quot; y2=&quot;12&quot;&gt;&lt;/line&gt;&lt;line x1=&quot;12&quot; y1=&quot;16&quot; x2=&quot;12.01&quot; y2=&quot;16&quot;&gt;&lt;/line&gt;&lt;/svg&gt;
  &lt;/div&gt;
  &lt;div class=&quot;c-aside__content flow&quot;&gt;&lt;strong id=&quot;6c57b8fe-7c01-47b2-9319-032e54a63d00&quot; class=&quot;c-aside__title [  block font-heading leading-tight no-underline uppercase tracking-wide text-sm ]&quot;&gt;sr-only / Visually-hidden&lt;/strong&gt;&lt;div class=&quot;flow&quot;&gt;&lt;p&gt;It&#39;s worth learning the different ways to &lt;strong&gt;accessibly&lt;/strong&gt; hide content if you aren&#39;t comfortable with this already. In almost every project you&#39;ll need to hide content visually while leaving it exposed to screen readers at some point.&lt;/p&gt;
&lt;p&gt;&lt;a href=&quot;https://www.scottohara.me/blog/2017/04/14/inclusively-hidden.html#hiding-content-visually&quot;&gt;Scott O&#39;Hara&#39;s Inclusively Hidden article&lt;/a&gt; clearly explains how to do this. And the full article covers even more.&lt;/p&gt;
&lt;p&gt;Worth a read &lt;abbr class=&quot;[ no-underline undefined ]&quot; title=&quot;unknown emoji&quot;&gt;😉&lt;/abbr&gt;&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;/aside&gt;
&lt;p&gt;Number 1 (the HTML-only approach) is simpler for a one-off component, but may not be so reusable. By that, I just mean you&#39;d have to remember to add screen reader-only text in a span anywhere else you may include strike-through text. It looks like this:&lt;/p&gt;
&lt;pre class=&quot;language-html&quot; tabindex=&quot;0&quot; data-language=&quot;html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;s&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;span&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;visually-hidden&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Old price: &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;$169.99&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;s&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;That&#39;s fine to use! In fact, it&#39;s &lt;strong&gt;my recommended approach&lt;/strong&gt; for this component.&lt;/p&gt;
&lt;p&gt;However, I want to let you know about an alternative technique (number 2) which can be used for all strike-through text on a site or in isolation for one component. This &amp;quot;CSS pseudo content technique&amp;quot; can be a useful tool to know about even if we don&#39;t end up using it for this component. It means that any time you use strike-through text &lt;s&gt;like this&lt;/s&gt; the beginning and end of the strike-through will be announced by &lt;em&gt;most&lt;/em&gt; screen readers. You can do the same for deletion (&lt;code&gt;del&lt;/code&gt;) or highlighted (&lt;code&gt;mark&lt;/code&gt;) text.&lt;/p&gt;
&lt;p&gt;To implement, you&#39;d use CSS (scss) like this:&lt;/p&gt;
&lt;pre class=&quot;language-scss&quot; tabindex=&quot;0&quot; data-language=&quot;scss&quot;&gt;&lt;code class=&quot;language-scss&quot;&gt;&lt;span class=&quot;token selector&quot;&gt;mark,&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;del,&lt;/span&gt;&lt;br /&gt;s &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token property&quot;&gt;position&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; relative&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br /&gt;  &lt;span class=&quot;token selector&quot;&gt;&lt;span class=&quot;token parent important&quot;&gt;&amp;amp;&lt;/span&gt;::before,&lt;br /&gt;  &lt;span class=&quot;token parent important&quot;&gt;&amp;amp;&lt;/span&gt;::after &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token comment&quot;&gt;// Includes the accessible visually-hidden CSS snippet:&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token keyword&quot;&gt;@extend&lt;/span&gt; .visually-hidden&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token selector&quot;&gt;s::before &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token property&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39; strike-through start &#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token selector&quot;&gt;s::after &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token property&quot;&gt;content&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39; strike-through end &#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;For more detail on this pseudo-content technique, take a look at &lt;a href=&quot;https://adrianroselli.com/2017/12/tweaking-text-level-styles.html&quot;&gt;Adrian Roselli&#39;s 2017 article on tweaking text level styles&lt;/a&gt;.&lt;/p&gt;
&lt;aside class=&quot;c-aside c-aside--update [ relative text-body ]&quot; aria-labelledby=&quot;9ce54bcd-7228-41fd-a721-c491cbabbf13&quot;&gt;
  &lt;div class=&quot;c-aside__icon [ grid place-content-center ]&quot;&gt;
    &lt;svg aria-hidden=&quot;true&quot; focusable=&quot;false&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;var(--icon-fill, var(--post-bg))&quot; stroke=&quot;var(--icon-stroke, var(--rainbow--teal))&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;[ h-full w-full ]&quot;&gt;&lt;polygon points=&quot;12 2 15.09 8.26 22 9.27 17 14.14 18.18 21.02 12 17.77 5.82 21.02 7 14.14 2 9.27 8.91 8.26 12 2&quot;&gt;&lt;/polygon&gt;&lt;/svg&gt;
  &lt;/div&gt;
  &lt;div class=&quot;c-aside__content flow&quot;&gt;&lt;strong id=&quot;9ce54bcd-7228-41fd-a721-c491cbabbf13&quot; class=&quot;c-aside__title [  block font-heading leading-tight no-underline uppercase tracking-wide text-sm ]&quot;&gt;Update 2: Jan. 2025&lt;/strong&gt;&lt;div class=&quot;flow&quot;&gt;&lt;p&gt;I am torn about whether to mention this second technique any more to be honest. It&#39;s good to know that &lt;code&gt;content&lt;/code&gt; inside a pseudo element will usually be announced by screen readers. But assistive technologies and browsers (user agents) have released a lot of improvements in recent years. That&#39;s great, I love to see updates! But it means that, as of January 2025 when I last checked, support seems patchy or inconsistent.&lt;/p&gt;
&lt;p&gt;VoiceOver and Talkback still don&#39;t announce strike-through text, so adding some pseudo content could be useful. However, NVDA and JAWS (on Windows) both announce this style by default now, so adding the pseudo content can lead to confusing &lt;em&gt;over-announcements&lt;/em&gt; for people using those screen readers.&lt;/p&gt;
&lt;p&gt;This is a classic trade-off where a technique &lt;strong&gt;helps some and harms others&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;For this pricing card component I now recommend you leave this out and use the HTML-only approach instead as it&#39;s clearer for everyone.&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;/aside&gt;
&lt;p&gt;With all that done, my HTML will now look like this:&lt;/p&gt;
&lt;pre class=&quot;language-html&quot; tabindex=&quot;0&quot; data-language=&quot;html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;main&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;c-product-card&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;c-product-card__img-half&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;picture&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;...&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;picture&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;c-product-card__text-half&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;p&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;c-product-card__ribbon ribbon-text&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;...&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;p&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;h2&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;c-product-card__title&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;...&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;h2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;p&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;c-product-card__desc&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;...&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;p&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;p&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;c-product-card__prices&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;        &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;span&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;c-product-card__price&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;$149.99&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;        &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;s&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;span&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;visually-hidden&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Old price: &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;$169.99&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;s&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;p&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;main&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;em&gt;Note I&#39;m using a span to wrap the current price purely for positioning and styling reasons. I would set the pricing paragraph to display &lt;code&gt;flex&lt;/code&gt; and include &lt;code&gt;flex-wrap: wrap&lt;/code&gt; just in case it ever needs to flow over two lines, like on a small screen with enlarged text sizing.&lt;/em&gt;&lt;/p&gt;
&lt;h2 id=&quot;call-to-action-cta&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/html-plan-product-preview/#call-to-action-cta&quot;&gt;&lt;span&gt;Call-to-action (CTA)&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;A common question in front end developmemt is when to use an anchor link (&lt;code&gt;a href=&lt;/code&gt;) and when to use a &lt;code&gt;button&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Clicking &#39;Add to cart&#39; &lt;strong&gt;performs an &lt;em&gt;action&lt;/em&gt;&lt;/strong&gt;. It is unlikely to navigate the user anywhere, so it makes sense to &lt;mark&gt;use a button here&lt;/mark&gt;.&lt;/p&gt;
&lt;p&gt;Inside the button there is a little icon as well as the text. That text label in this button already says what clicking it will do. That means we know the icon is &lt;em&gt;decorative&lt;/em&gt; and won&#39;t need an &lt;code&gt;alt&lt;/code&gt; description. For decorative images, you must leave the alt intentionally blank. &lt;em&gt;(It&#39;s counterintuitive, I know!)&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Here&#39;s what we end up with:&lt;/p&gt;
&lt;pre class=&quot;language-html&quot; tabindex=&quot;0&quot; data-language=&quot;html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;button&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;c-product-card__btn btn btn--primary&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;img&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;...&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;alt&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Add to cart&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;no-print&quot;&gt;
  &lt;details class=&quot;c-details&quot;&gt;
    &lt;summary class=&quot;c-details__summary [ relative bg-bar ]&quot;&gt;
      &lt;strong class=&quot;c-details__title [ font-base text-body h4 ]&quot;&gt;Why wrap words in a span?&lt;/strong&gt;
    &lt;/summary&gt;
    &lt;div class=&quot;c-details__content [ flow bg-body text-body ]&quot;&gt;&lt;p&gt;The only reason I&#39;ve wrapped that text in a span is because I know it will help me position it using flexbox!&lt;/p&gt;
&lt;pre class=&quot;language-scss&quot; tabindex=&quot;0&quot; data-language=&quot;scss&quot;&gt;&lt;code class=&quot;language-scss&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token selector&quot;&gt;.c-product-card__btn &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token property&quot;&gt;display&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; flex&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token property&quot;&gt;flex-wrap&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; wrap&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token property&quot;&gt;align-items&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; center&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token property&quot;&gt;gap&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 1ch&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// 1ch = the width of an 0 character&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;When you&#39;re first starting out, you may leave out elements like this until you come to do the styling. That&#39;s often when I&#39;ll add extra spans or divs, as they are meaningless elements. They only exist to assist with layout/styling, and don&#39;t add any semantic meaning.&lt;/p&gt;
&lt;/div&gt;
  &lt;/details&gt;
&lt;/div&gt;
&lt;div class=&quot;c-details print-only&quot;&gt;
  &lt;h4&gt;Why wrap words in a span?&lt;/h4&gt;
  &lt;div class=&quot;c-details__content flow&quot;&gt;&lt;p&gt;The only reason I&#39;ve wrapped that text in a span is because I know it will help me position it using flexbox!&lt;/p&gt;
&lt;pre class=&quot;language-scss&quot; tabindex=&quot;0&quot; data-language=&quot;scss&quot;&gt;&lt;code class=&quot;language-scss&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token selector&quot;&gt;.c-product-card__btn &lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token property&quot;&gt;display&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; flex&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token property&quot;&gt;flex-wrap&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; wrap&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token property&quot;&gt;align-items&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; center&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token property&quot;&gt;gap&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 1ch&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt; &lt;span class=&quot;token comment&quot;&gt;// 1ch = the width of an 0 character&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;When you&#39;re first starting out, you may leave out elements like this until you come to do the styling. That&#39;s often when I&#39;ll add extra spans or divs, as they are meaningless elements. They only exist to assist with layout/styling, and don&#39;t add any semantic meaning.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;no-print&quot;&gt;
  &lt;details class=&quot;c-details&quot;&gt;
    &lt;summary class=&quot;c-details__summary [ relative bg-bar ]&quot;&gt;
      &lt;strong class=&quot;c-details__title [ font-base text-body h4 ]&quot;&gt;Repeating CTAs can be a problem!&lt;/strong&gt;
    &lt;/summary&gt;
    &lt;div class=&quot;c-details__content [ flow bg-body text-body ]&quot;&gt;&lt;p&gt;If there was a page full of these product cards, you&#39;d have a situation where there are multiple &amp;quot;add to cart&amp;quot; buttons on the page. Imagine being confronted with a button menu like this:&lt;/p&gt;
&lt;pre class=&quot;language-html&quot; tabindex=&quot;0&quot; data-language=&quot;html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;Add to cart&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;Add to cart&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;Add to cart&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;Add to cart&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;That could get pretty confusing to screen reader users. &lt;em&gt;(And to those using screen magnification or zoom etc)&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;The best solution is to &lt;strong&gt;avoid repeating CTA labels in designs altogether!&lt;/strong&gt; Designers and content editors are becoming more disability-aware and hopefully will stop repeating links like this in future. But we can help a bit via our code right now...&lt;/p&gt;
&lt;p&gt;Including some screen-reader only text with the product name in the button is an easy fix for this:&lt;/p&gt;
&lt;pre class=&quot;language-html&quot; tabindex=&quot;0&quot; data-language=&quot;html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;button&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;c-product-card__btn btn btn--primary&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;img&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;...&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;alt&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Add to cart&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;span&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;visually-hidden&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;- Gabrielle Essence Eau De Parfum&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Alternatively, using &lt;code&gt;aria-describedby&lt;/code&gt; or &lt;code&gt;aria-labelledby&lt;/code&gt; on CTAs with repeating labels can help screen reader users! This can make &lt;code&gt;&amp;quot;Add to cart&amp;quot;&lt;/code&gt; become something like: &lt;code&gt;&amp;quot;Add to cart - Gabrielle Essencce Eau De Parfum&amp;quot;&lt;/code&gt;. Note, &lt;code&gt;aria-describedby&lt;/code&gt; wouldn&#39;t change the accessible name for screen readers when viewing the list of all links on a page though, descriptions are only announced on focus.&lt;/p&gt;
&lt;p&gt;I&#39;ll do a deeper dive on this technique another time. But feel free to do your own research and start using it now!&lt;/p&gt;
&lt;/div&gt;
  &lt;/details&gt;
&lt;/div&gt;
&lt;div class=&quot;c-details print-only&quot;&gt;
  &lt;h4&gt;Repeating CTAs can be a problem!&lt;/h4&gt;
  &lt;div class=&quot;c-details__content flow&quot;&gt;&lt;p&gt;If there was a page full of these product cards, you&#39;d have a situation where there are multiple &amp;quot;add to cart&amp;quot; buttons on the page. Imagine being confronted with a button menu like this:&lt;/p&gt;
&lt;pre class=&quot;language-html&quot; tabindex=&quot;0&quot; data-language=&quot;html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;Add to cart&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;Add to cart&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;Add to cart&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;Add to cart&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;That could get pretty confusing to screen reader users. &lt;em&gt;(And to those using screen magnification or zoom etc)&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;The best solution is to &lt;strong&gt;avoid repeating CTA labels in designs altogether!&lt;/strong&gt; Designers and content editors are becoming more disability-aware and hopefully will stop repeating links like this in future. But we can help a bit via our code right now...&lt;/p&gt;
&lt;p&gt;Including some screen-reader only text with the product name in the button is an easy fix for this:&lt;/p&gt;
&lt;pre class=&quot;language-html&quot; tabindex=&quot;0&quot; data-language=&quot;html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;button&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;c-product-card__btn btn btn--primary&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;img&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;...&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;alt&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Add to cart&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;span&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;visually-hidden&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;- Gabrielle Essence Eau De Parfum&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Alternatively, using &lt;code&gt;aria-describedby&lt;/code&gt; or &lt;code&gt;aria-labelledby&lt;/code&gt; on CTAs with repeating labels can help screen reader users! This can make &lt;code&gt;&amp;quot;Add to cart&amp;quot;&lt;/code&gt; become something like: &lt;code&gt;&amp;quot;Add to cart - Gabrielle Essencce Eau De Parfum&amp;quot;&lt;/code&gt;. Note, &lt;code&gt;aria-describedby&lt;/code&gt; wouldn&#39;t change the accessible name for screen readers when viewing the list of all links on a page though, descriptions are only announced on focus.&lt;/p&gt;
&lt;p&gt;I&#39;ll do a deeper dive on this technique another time. But feel free to do your own research and start using it now!&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;h2 id=&quot;summing-up&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/html-plan-product-preview/#summing-up&quot;&gt;&lt;span&gt;Summing up&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;I hope this has helped you understand my process for working out the right semantics for a design.&lt;/p&gt;
&lt;p&gt;As we&#39;ve learnt, there are occasional little &#39;accessibility extras&#39; we need to add in to our HTML. But these are pretty rare! It&#39;s OK if you don&#39;t understand all of them yet. As long as you are trying to choose appropriate elements and building your accessibility &lt;em&gt;awareness&lt;/em&gt; you are on the right track!&lt;/p&gt;
&lt;p&gt;My end HTML looks like this (most class names and content removed):&lt;/p&gt;
&lt;pre class=&quot;language-html&quot; tabindex=&quot;0&quot; data-language=&quot;html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;main&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- Product Card --&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;c-product-card&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- Image half of the card--&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;c-product-card__image-half&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;      &lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- images --&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;picture&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;        &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;source&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;...&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;        &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;img&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;...&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;alt&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;...&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;picture&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- Text half of the card--&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;div&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;c-product-card__text-half&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;      &lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- Optionally include hgroup to wrap ribbon text &amp;amp; heading --&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;      &lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- Ribbon Text --&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;p&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;...&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;p&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;      &lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- Product name --&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;h2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;...&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;h2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;      &lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- Product Description --&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;p&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;        ...&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;p&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;      &lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- Prices --&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;p&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;        &lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- Current Price --&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;        &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;...&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;        &lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- Old Price --&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;        &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;s&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;span&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;visually-hidden&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Old price: &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;...&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;s&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;p&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;      &lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- CTA --&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;button&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;        &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;img&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;src&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;...&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;alt&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;        &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;...&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;span&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;        &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;span&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;visually-hidden&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;- [product name]&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;s&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;      &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;    &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;main&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;It&#39;s fine if yours looks a little different! As long as it&#39;s properly thought through.&lt;/p&gt;
&lt;h3 id=&quot;check-it-with-no-styles&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/html-plan-product-preview/#check-it-with-no-styles&quot;&gt;&lt;span&gt;Check it with no styles!&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The true test of whether you&#39;ve chosen appropriate HTML is to view your content without &lt;em&gt;any&lt;/em&gt; styling at all. It should be super clear and understandable.&lt;/p&gt;
&lt;p&gt;This is how my style-free HTML gets rendered:&lt;/p&gt;
&lt;figure class=&quot;[ flex flex-col  ]&quot;&gt;&lt;picture&gt;&lt;source type=&quot;image/webp&quot; srcset=&quot;https://fedmentor.dev/posts/html-plan-product-preview/final-html-653w.webp 653w&quot; sizes=&quot;(min-width: 40rem) 25vw, 100vw&quot; /&gt;&lt;img alt=&quot;The unstyled HTML with appropriate elements: An image, paragraph, heading, paragraph, two prices, one with a line through, a button&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; src=&quot;https://fedmentor.dev/posts/html-plan-product-preview/final-html-653w.jpeg&quot; width=&quot;653&quot; height=&quot;589&quot; /&gt;&lt;/picture&gt;&lt;figcaption class=&quot;[ grow text-center font-bold ]&quot;&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Caption: &lt;/span&gt;My final HTML&lt;/figcaption&gt;&lt;/figure&gt;
&lt;p&gt;And the final tests for whether it is &lt;em&gt;accessible&lt;/em&gt; involve screen reader, keyboard and even voice testing if you want to. &lt;em&gt;(Including testing these once this component is placed in its real context on a site!)&lt;/em&gt;&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Why you shouldn&#39;t use pixels for font-size</title>
		<link href="https://fedmentor.dev/posts/font-size-px/"/>
		<updated>2023-05-02T00:00:00Z</updated>
		<id>https://fedmentor.dev/posts/font-size-px/</id>
		<content type="html">&lt;aside class=&quot;c-aside c-aside--info [ relative text-body ]&quot; aria-labelledby=&quot;eb2d8a44-bb7e-43d4-8a60-fbb5b18aba99&quot;&gt;
  &lt;div class=&quot;c-aside__icon [ grid place-content-center ]&quot;&gt;
    &lt;svg aria-hidden=&quot;true&quot; focusable=&quot;false&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;var(--icon-fill, var(--post-bg))&quot; stroke=&quot;var(--icon-stroke, var(--rainbow--teal))&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;[ h-full w-full ]&quot;&gt;&lt;circle cx=&quot;12&quot; cy=&quot;12&quot; r=&quot;10&quot;&gt;&lt;/circle&gt;&lt;line x1=&quot;12&quot; y1=&quot;16&quot; x2=&quot;12&quot; y2=&quot;12&quot;&gt;&lt;/line&gt;&lt;line x1=&quot;12&quot; y1=&quot;8&quot; x2=&quot;12.01&quot; y2=&quot;8&quot;&gt;&lt;/line&gt;&lt;/svg&gt;
  &lt;/div&gt;
  &lt;div class=&quot;c-aside__content flow&quot;&gt;&lt;strong id=&quot;eb2d8a44-bb7e-43d4-8a60-fbb5b18aba99&quot; class=&quot;c-aside__title [  block font-heading leading-tight no-underline uppercase tracking-wide text-sm ]&quot;&gt;Post updated for clarity 2024&lt;/strong&gt;&lt;div class=&quot;flow&quot;&gt;&lt;p&gt;I want to make clear, this is an opinionated post &lt;strong&gt;because I am directly and regularly affected&lt;/strong&gt; by this issue!&lt;/p&gt;
&lt;p&gt;People like me who need to be able to enlarge text in their device settings shouldn&#39;t have to constantly zoom in on web pages when developers like us could just use a better unit in CSS in the first place.&lt;/p&gt;
&lt;p&gt;Small changes in your code can make a big difference.&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;/aside&gt;
&lt;h2 id=&quot;which-properties-are-affected&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/font-size-px/#which-properties-are-affected&quot;&gt;&lt;span&gt;Which properties are affected?&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;All of these properties should never &lt;em&gt;ever&lt;/em&gt; be declared in pixels.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;code&gt;font-size&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;line-height&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;letter-spacing&lt;/code&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Even if your style guide or design file gives you these sizes in pixels (or pts), we &lt;strong&gt;must&lt;/strong&gt; translate those values into more appropriate units when implementing in code.&lt;/p&gt;
&lt;h2 id=&quot;why-does-it-matter&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/font-size-px/#why-does-it-matter&quot;&gt;&lt;span&gt;Why does it matter?&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;A lot more people than you may think change their base text size, usually making it larger. This can be done at an operating system level or at a browser level.&lt;/p&gt;
&lt;p&gt;Text-only zoom is actually the &lt;em&gt;default&lt;/em&gt; on my iPhone. Safari has a plus and minus control right there in the browser address bar to make it easy for people to change their text size.&lt;/p&gt;
&lt;p&gt;As browsers and devices make settings searchable and more user-friendly, the number of people tweaking font settings will only increase. &lt;em&gt;(I once walked in on my mum holding a magnifying glass up to her computer screen because she didn&#39;t know she could change the text size!&lt;/em&gt; &lt;abbr class=&quot;[ no-underline undefined ]&quot; title=&quot;ha-ha emoji&quot;&gt;🤭&lt;/abbr&gt; &lt;em&gt;Thankfully, those days are long behind her...)&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;mark&gt;If you&#39;ve used pixels to define &lt;em&gt;any&lt;/em&gt; of the above style properties, &lt;strong&gt;they will not fully respect the user&#39;s text size preferences&lt;/strong&gt;!&lt;/mark&gt;&lt;/p&gt;
&lt;p&gt;At best this means text content becomes too small for some people to read comfortably &lt;em&gt;(bring out that magnifying glass or pinch and zoom!)&lt;/em&gt;. At worst, it means letters or lines will overlap each other, making the text totally unreadable! &lt;abbr class=&quot;[ no-underline undefined ]&quot; title=&quot;scream-face emoji&quot;&gt;😱&lt;/abbr&gt;&lt;/p&gt;
&lt;figure class=&quot;[ flex flex-col  ]&quot;&gt;&lt;picture&gt;&lt;source type=&quot;image/webp&quot; srcset=&quot;https://fedmentor.dev/posts/font-size-px/line-height-error-568w.webp 568w&quot; sizes=&quot;(min-width: 30em) 50vw, 100vw&quot; /&gt;&lt;img alt=&quot;Unreadable scrambled text. Devtools on the side shows that font-size is 1rem but line height is 19 pixels &quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; src=&quot;https://fedmentor.dev/posts/font-size-px/line-height-error-568w.jpeg&quot; width=&quot;568&quot; height=&quot;91&quot; /&gt;&lt;/picture&gt;&lt;figcaption class=&quot;[ grow text-center font-bold ]&quot;&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Caption: &lt;/span&gt;Font-size in rem, line-height in px&lt;/figcaption&gt;&lt;/figure&gt;
&lt;p&gt;The &lt;em&gt;good&lt;/em&gt; news is, if we DO use appropriate units, everything will scale beautifully for ALL users, no matter what changes they make in their settings. And these are easy changes to make!&lt;/p&gt;
&lt;h2 id=&quot;see-text-size-changes-in-action&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/font-size-px/#see-text-size-changes-in-action&quot;&gt;&lt;span&gt;See text size changes in action&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;It&#39;s worth familiarising yourself with how to change font settings in the browser so you can test your solutions more thoroughly.&lt;/p&gt;
&lt;h3 id=&quot;firefox-font-settings&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/font-size-px/#firefox-font-settings&quot;&gt;&lt;span&gt;Firefox font settings&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;div class=&quot;c-img-grid  [ grid gap-1 pull-out ]&quot;&gt;
&lt;figure class=&quot;[ flex flex-col  ]&quot;&gt;&lt;picture&gt;&lt;source type=&quot;image/webp&quot; srcset=&quot;https://fedmentor.dev/posts/font-size-px/ff-font-size-800w.webp 800w&quot; sizes=&quot;(min-width: 40rem) 75vw, 100vw&quot; /&gt;&lt;img alt=&quot;Firefox settings - Font size options&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; src=&quot;https://fedmentor.dev/posts/font-size-px/ff-font-size-800w.jpeg&quot; width=&quot;800&quot; height=&quot;461&quot; /&gt;&lt;/picture&gt;&lt;figcaption class=&quot;[ grow text-center font-bold ]&quot;&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Caption: &lt;/span&gt;Firefox font size settings&lt;/figcaption&gt;&lt;/figure&gt;
&lt;figure class=&quot;[ flex flex-col  ]&quot;&gt;&lt;picture&gt;&lt;source type=&quot;image/webp&quot; srcset=&quot;https://fedmentor.dev/posts/font-size-px/ff-advanced-fonts-638w.webp 638w&quot; sizes=&quot;(min-width: 40rem) 25vw, 100vw&quot; /&gt;&lt;img alt=&quot;Firefox settings - advanced font options&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; src=&quot;https://fedmentor.dev/posts/font-size-px/ff-advanced-fonts-638w.jpeg&quot; width=&quot;638&quot; height=&quot;504&quot; /&gt;&lt;/picture&gt;&lt;figcaption class=&quot;[ grow text-center font-bold ]&quot;&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Caption: &lt;/span&gt;Firefox advanced font settings&lt;/figcaption&gt;&lt;/figure&gt;
&lt;/div&gt;
&lt;h3 id=&quot;chrome-font-settings&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/font-size-px/#chrome-font-settings&quot;&gt;&lt;span&gt;Chrome font settings&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;div class=&quot;c-img-grid  [ grid gap-1 pull-out ]&quot;&gt;
&lt;figure class=&quot;[ flex flex-col  ]&quot;&gt;&lt;picture&gt;&lt;source type=&quot;image/webp&quot; srcset=&quot;https://fedmentor.dev/posts/font-size-px/chrome-font-size-800w.webp 800w&quot; sizes=&quot;(min-width: 40rem) 75vw, 100vw&quot; /&gt;&lt;img alt=&quot;Chrome settings - Font size&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; src=&quot;https://fedmentor.dev/posts/font-size-px/chrome-font-size-800w.jpeg&quot; width=&quot;800&quot; height=&quot;578&quot; /&gt;&lt;/picture&gt;&lt;figcaption class=&quot;[ grow text-center font-bold ]&quot;&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Caption: &lt;/span&gt;Chrome font size settings&lt;/figcaption&gt;&lt;/figure&gt;
&lt;figure class=&quot;[ flex flex-col  ]&quot;&gt;&lt;picture&gt;&lt;source type=&quot;image/webp&quot; srcset=&quot;https://fedmentor.dev/posts/font-size-px/chrome-customise-fonts-800w.webp 800w&quot; sizes=&quot;(min-width: 40rem) 25vw, 100vw&quot; /&gt;&lt;img alt=&quot;Chrome settings - customize fonts&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; src=&quot;https://fedmentor.dev/posts/font-size-px/chrome-customise-fonts-800w.jpeg&quot; width=&quot;800&quot; height=&quot;490&quot; /&gt;&lt;/picture&gt;&lt;figcaption class=&quot;[ grow text-center font-bold ]&quot;&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Caption: &lt;/span&gt;Chrome advanced font settings&lt;/figcaption&gt;&lt;/figure&gt;
&lt;/div&gt;
&lt;h3 id=&quot;iphone&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/font-size-px/#iphone&quot;&gt;&lt;span&gt;iPhone&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Use the &#39;plus&#39; or &#39;minus&#39; controls in the Safari browser bar. If you&#39;re using Chrome, open up the settings next to the browser bar and choose &#39;adjust text size&#39;. Then use the &#39;plus&#39; and &#39;minus&#39; controls that appear at the top of the screen.&lt;/p&gt;
&lt;h3 id=&quot;other-user-agents&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/font-size-px/#other-user-agents&quot;&gt;&lt;span&gt;Other user agents&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;There will definitely be similar settings to change text size within your operating system and on mobile devices. But I&#39;ll leave you to figure out those settings on your own. Go explore!&lt;/p&gt;
&lt;h2 id=&quot;what-units-should-i-use&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/font-size-px/#what-units-should-i-use&quot;&gt;&lt;span&gt;What units &lt;em&gt;should&lt;/em&gt; I use?&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;h3 id=&quot;font-size&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/font-size-px/#font-size&quot;&gt;&lt;span&gt;Font-size&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Generally, you won&#39;t go wrong using &lt;code&gt;rem&lt;/code&gt;!&lt;/p&gt;
&lt;p&gt;If your style guide of design file (e.g. Figma / Sketch / Photoshop) provides font size in pixels, you&#39;ll need to convert it to rem. Usually the first place to apply this is on the &lt;code&gt;body&lt;/code&gt; element (try to avoid setting any direct styles on &lt;code&gt;html&lt;/code&gt; or &lt;code&gt;:root&lt;/code&gt;).&lt;/p&gt;
&lt;p&gt;There are loads of ways to make this easier, and I&#39;ve already outlined these methods in another post: &lt;a href=&quot;https://fedmentor.dev/posts/rem-html-font-size-hack/&quot;&gt;Should I change the default HTML font-size to 62.5%?&lt;/a&gt;. Essentially you will need to divide whatever pixel value you want by &lt;strong&gt;16&lt;/strong&gt; to get the rem equivalent for use in your CSS.&lt;/p&gt;
&lt;p&gt;I would never recommend setting font size in &lt;code&gt;em&lt;/code&gt; &lt;em&gt;unless&lt;/em&gt; you have some specific use case where you need an element&#39;s font size to scale with it&#39;s parent. The only case I can think of where this &lt;em&gt;may&lt;/em&gt; be useful is when using an icon font for symbols.&lt;/p&gt;
&lt;aside class=&quot;c-aside c-aside--alert [ relative text-body ]&quot; aria-labelledby=&quot;68c5da1d-4087-40b5-9721-3c515391fb9c&quot;&gt;
  &lt;div class=&quot;c-aside__icon [ grid place-content-center ]&quot;&gt;
    &lt;svg 2000=&quot;&quot; aria-hidden=&quot;true&quot; focusable=&quot;false xmlns=&quot; http:=&quot;&quot; www.w3.org=&quot;&quot; svg&quot;=&quot;&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;var(--icon-fill, var(--post-bg))&quot; stroke=&quot;var(--icon-stroke, var(--rainbow--teal))&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;[ h-full w-full ]&quot;&gt;&lt;polygon points=&quot;7.86 2 16.14 2 22 7.86 22 16.14 16.14 22 7.86 22 2 16.14 2 7.86 7.86 2&quot;&gt;&lt;/polygon&gt;&lt;line x1=&quot;12&quot; y1=&quot;8&quot; x2=&quot;12&quot; y2=&quot;12&quot;&gt;&lt;/line&gt;&lt;line x1=&quot;12&quot; y1=&quot;16&quot; x2=&quot;12.01&quot; y2=&quot;16&quot;&gt;&lt;/line&gt;&lt;/svg&gt;
  &lt;/div&gt;
  &lt;div class=&quot;c-aside__content flow&quot;&gt;&lt;strong id=&quot;68c5da1d-4087-40b5-9721-3c515391fb9c&quot; class=&quot;c-aside__title [  block font-heading leading-tight no-underline uppercase tracking-wide text-sm ]&quot;&gt;Note on Viewport units&lt;/strong&gt;&lt;div class=&quot;flow&quot;&gt;&lt;p&gt;&lt;strong&gt;Never use viewport units for font-size either!&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;For the same reasons as outlined above, using viewport units for font-size takes away all control from people accessing your site. Their preferences will no longer be honoured.&lt;/p&gt;
&lt;p&gt;You &lt;em&gt;can&lt;/em&gt; try using viewport units inside &lt;code&gt;clamp()&lt;/code&gt; functions as I have done in places on this site. But these still need converting into rems, and I cannot yet guarantee they are fully accessible. For example: &lt;code&gt;clamp(1rem, calc(1rem + 0.4vw), 1.5rem);&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;abbr class=&quot;[ no-underline undefined ]&quot; title=&quot;Idea emoji&quot;&gt;💡&lt;/abbr&gt; &lt;em&gt;The &lt;a href=&quot;https://utopia.fyi/&quot;&gt;Utopia site&lt;/a&gt; is great at generating these types of clamp properties for you!&lt;/em&gt;&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;/aside&gt;
&lt;p&gt;I&#39;ll also add that it&#39;s a &lt;strong&gt;bad idea to mess with font size on the &lt;code&gt;html&lt;/code&gt; or &lt;code&gt;:root&lt;/code&gt; selectors&lt;/strong&gt;. Leave that for the browser to apply the user&#39;s text size. The only exception might be when you&#39;re targeting really large screens, setting a font size in percentage can make &lt;em&gt;everything&lt;/em&gt; in your layout scale &lt;em&gt;up&lt;/em&gt;. E.g. &lt;code&gt;html { font-size: 125%; }&lt;/code&gt; inside a media query targeting very large screens.&lt;/p&gt;
&lt;h3 id=&quot;line-height&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/font-size-px/#line-height&quot;&gt;&lt;span&gt;Line-height&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Usually line-height is written as a &lt;em&gt;unitless&lt;/em&gt; value, like &lt;code&gt;1.5&lt;/code&gt;. You may also see it written as a percentage, like &lt;code&gt;150%&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Which you choose is down to personal preference&lt;/strong&gt;. I usually use the unitless approach, because I find it easier to read and because it&#39;s shorter, making the teeniest tiniest difference to performance.&lt;/p&gt;
&lt;p&gt;If your design file gives you a line height value in pixels, you can calculate the unitless or percentage value simply by dividing that value by the font-size. For example, if line-height in Figma/Sketch is 24px, and font-size is 16px: &lt;code&gt;24 / 16 = 1.5&lt;/code&gt;. That&#39;s your line-height! (Or 150%).&lt;/p&gt;
&lt;h3 id=&quot;letter-spacing&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/font-size-px/#letter-spacing&quot;&gt;&lt;span&gt;Letter-spacing&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;I recommend using &lt;code&gt;em&lt;/code&gt; for letter spacing so it always scales with the text where it is used. You could also use rem or %.&lt;/p&gt;
&lt;p&gt;These are all valid, but in this case, the em unit definitely makes the most sense &lt;em&gt;to me&lt;/em&gt;. Letter spacing is one of those properties that you &lt;em&gt;always&lt;/em&gt; want to scale with the font where it&#39;s used, and that is exactly what em does!&lt;/p&gt;
&lt;h2 id=&quot;summing-up&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/font-size-px/#summing-up&quot;&gt;&lt;span&gt;Summing up...&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;NEVER use pixels or viewport units for text properties. (Please, I beg you!)&lt;/li&gt;
&lt;li&gt;Get familar with the text-size settings in various browsers, operating systems or devices. Play with the settings and see how it break some sites. Hopefully this will help you appreciate the importance of choosing responsive units!&lt;/li&gt;
&lt;li&gt;Test your solutions like this, resizing the viewport and using browser emulation &lt;strong&gt;with an enlarged default text size&lt;/strong&gt;. Refactor where necessary!&lt;/li&gt;
&lt;li&gt;Font-size? &lt;span&gt;&lt;span role=&quot;presentation&quot; aria-hidden=&quot;true&quot; class=&quot;text-link&quot;&gt;→&lt;/span&gt; Use &lt;strong&gt;rem&lt;/strong&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;Line-height? &lt;span role=&quot;presentation&quot; aria-hidden=&quot;true&quot; class=&quot;text-link&quot;&gt;→&lt;/span&gt; Keep it &lt;strong&gt;unitless&lt;/strong&gt; (or use %)&lt;/li&gt;
&lt;li&gt;Letter-spacing? &lt;span role=&quot;presentation&quot; aria-hidden=&quot;true&quot; class=&quot;text-link&quot;&gt;→&lt;/span&gt; Use &lt;strong&gt;em&lt;/strong&gt; (or use rem or %)&lt;/li&gt;
&lt;/ul&gt;
&lt;aside class=&quot;c-aside c-aside--info [ relative text-body ]&quot; aria-labelledby=&quot;af2e4518-a624-4ca6-850e-023230cd5149&quot;&gt;
  &lt;div class=&quot;c-aside__icon [ grid place-content-center ]&quot;&gt;
    &lt;svg aria-hidden=&quot;true&quot; focusable=&quot;false&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;var(--icon-fill, var(--post-bg))&quot; stroke=&quot;var(--icon-stroke, var(--rainbow--teal))&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;[ h-full w-full ]&quot;&gt;&lt;circle cx=&quot;12&quot; cy=&quot;12&quot; r=&quot;10&quot;&gt;&lt;/circle&gt;&lt;line x1=&quot;12&quot; y1=&quot;16&quot; x2=&quot;12&quot; y2=&quot;12&quot;&gt;&lt;/line&gt;&lt;line x1=&quot;12&quot; y1=&quot;8&quot; x2=&quot;12.01&quot; y2=&quot;8&quot;&gt;&lt;/line&gt;&lt;/svg&gt;
  &lt;/div&gt;
  &lt;div class=&quot;c-aside__content flow&quot;&gt;&lt;strong id=&quot;af2e4518-a624-4ca6-850e-023230cd5149&quot; class=&quot;c-aside__title [  block font-heading leading-tight no-underline uppercase tracking-wide text-sm ]&quot;&gt;Related posts&lt;/strong&gt;&lt;div class=&quot;flow&quot;&gt;&lt;ol&gt;
&lt;li&gt;&lt;a href=&quot;https://fedmentor.dev/posts/rem-html-font-size-hack/&quot;&gt;Should I change the default HTML font-size to 62.5%?&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://fedmentor.dev/posts/responsive-meaning/&quot;&gt;What does it mean to &amp;quot;make a site responsive&amp;quot;?&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;/aside&gt;
</content>
	</entry>
	
	<entry>
		<title>How to &quot;make a site responsive&quot; and use media queries well</title>
		<link href="https://fedmentor.dev/posts/responsive-meaning/"/>
		<updated>2023-04-30T00:00:00Z</updated>
		<id>https://fedmentor.dev/posts/responsive-meaning/</id>
		<content type="html">&lt;h2 id=&quot;defining-responsive&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/responsive-meaning/#defining-responsive&quot;&gt;&lt;span&gt;Defining &amp;quot;responsive&amp;quot;&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;All websites need to be responsive. &lt;em&gt;(So do all Frontend Mentor challenges, even the single component ones!)&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Put simply, &lt;strong&gt;a responsive site or component is one that looks OK and functions well on all screen sizes from 320px wide and above &lt;em&gt;without&lt;/em&gt; requiring horizontal (inline axis) scroll&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;&amp;quot;Making a site responsive&amp;quot; does &lt;em&gt;not&lt;/em&gt; mean that every site / component needs a media query (MQ). Nor does it mean that building the &#39;mobile&#39; version of a design.&lt;/p&gt;
&lt;p&gt;I hear a lot of junior developers say things like &lt;em&gt;&amp;quot;I need to make it more responsive&amp;quot;&lt;/em&gt; or &lt;em&gt;&amp;quot;I&#39;ve not done the responsiveness yet&amp;quot;&lt;/em&gt;. Usually this means &lt;em&gt;&amp;quot;It only works on my laptop screen so far, but I&#39;ll fix that next&amp;quot;&lt;/em&gt;.&lt;/p&gt;
&lt;p&gt;That&#39;s not what responsiveness means!&lt;/p&gt;
&lt;p&gt;Responsiveness means a site responds (adapts) when viewed on different devices, zoomed in or when a user changes settings like default text size.&lt;/p&gt;
&lt;aside class=&quot;c-aside c-aside--alert [ relative text-body ]&quot; aria-labelledby=&quot;f7799434-5313-4259-9d75-6539d4100678&quot;&gt;
  &lt;div class=&quot;c-aside__icon [ grid place-content-center ]&quot;&gt;
    &lt;svg 2000=&quot;&quot; aria-hidden=&quot;true&quot; focusable=&quot;false xmlns=&quot; http:=&quot;&quot; www.w3.org=&quot;&quot; svg&quot;=&quot;&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;var(--icon-fill, var(--post-bg))&quot; stroke=&quot;var(--icon-stroke, var(--rainbow--teal))&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;[ h-full w-full ]&quot;&gt;&lt;polygon points=&quot;7.86 2 16.14 2 22 7.86 22 16.14 16.14 22 7.86 22 2 16.14 2 7.86 7.86 2&quot;&gt;&lt;/polygon&gt;&lt;line x1=&quot;12&quot; y1=&quot;8&quot; x2=&quot;12&quot; y2=&quot;12&quot;&gt;&lt;/line&gt;&lt;line x1=&quot;12&quot; y1=&quot;16&quot; x2=&quot;12.01&quot; y2=&quot;16&quot;&gt;&lt;/line&gt;&lt;/svg&gt;
  &lt;/div&gt;
  &lt;div class=&quot;c-aside__content flow&quot;&gt;&lt;strong id=&quot;f7799434-5313-4259-9d75-6539d4100678&quot; class=&quot;c-aside__title [  block font-heading leading-tight no-underline uppercase tracking-wide text-sm ]&quot;&gt;important!&lt;/strong&gt;&lt;div class=&quot;flow&quot;&gt;&lt;h2 id=&quot;why-320px-wide-and-above&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/responsive-meaning/#why-320px-wide-and-above&quot;&gt;&lt;span&gt;Why 320px wide and above?&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;320px wide emulates iPhone 12 mini, iPhone 5, Xperia Compact etc and is an accessibility requirement for all sites under &lt;a href=&quot;https://www.w3.org/TR/WCAG21/#reflow&quot;&gt;WCAG Success Criterion 1.4.10 (level AA)&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The criterion states that &amp;quot;content can be presented without loss of information or functionality, and without requiring scrolling in two dimensions&amp;quot;. This is all about &lt;strong&gt;Reflow&lt;/strong&gt; and making sure content is &lt;strong&gt;Perceivable&lt;/strong&gt; to all users, no matter what their device, text size or zoom level may be.&lt;/p&gt;
&lt;p&gt;In other words, our solutions need to &lt;strong&gt;allow users to zoom in or change their text size without suddenly having to scroll in two directions&lt;/strong&gt; to see the content. _(It therefore closely relates to &lt;a href=&quot;https://www.w3.org/TR/WCAG21/#resize-text&quot;&gt;WCAG Success Criterion 1.4.4 Resize Text&lt;/a&gt; too!)&lt;/p&gt;
&lt;p&gt;This is super important. As this person with low-vision states:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;“It&#39;s nearly impossible to read text if I have to scroll right and left to read each line. It&#39;s disorienting and I lose my place. It makes it hard to understand what I&#39;m reading.”&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;If you read the WCAG criteria and still don&#39;t understand what it&#39;s talking about (don&#39;t worry, these things &lt;em&gt;are&lt;/em&gt; hard to understand!), I recommend checking out:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;&lt;a href=&quot;https://www.w3.org/WAI/WCAG21/Understanding/reflow.html&quot;&gt;Understanding SC 1.4.10&lt;/a&gt; for lots of detail&lt;/li&gt;
&lt;li&gt;or &lt;a href=&quot;https://dequeuniversity.com/resources/wcag2.1/1.4.10-reflow&quot;&gt;Deque&#39;s Reflow Explainer&lt;/a&gt; for a light-touch summary&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;abbr class=&quot;[ no-underline undefined ]&quot; title=&quot;Alert emoji&quot;&gt;⚠️&lt;/abbr&gt; &lt;strong&gt;All you really need to remember though is to test your sites and components on small screens and with enlarged text!&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Of course you can make adjustments for even smaller screens if you wish! You can even specifically target screens like smart watches. But that is not a beginner topic and not necessary for most cases.&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;/aside&gt;
&lt;h2 id=&quot;when-to-add-a-media-query&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/responsive-meaning/#when-to-add-a-media-query&quot;&gt;&lt;span&gt;When to add a media query&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;As I&#39;ve previously said, you won&#39;t always need a media query for every component, or even every website. HTML is naturally responsive, and some designs will work on (pretty much) all screens.&lt;/p&gt;
&lt;p&gt;No media query is needed on the first Frontend Mentor challenge — &lt;a href=&quot;https://www.frontendmentor.io/challenges/qr-code-component-iux_sIO_H&quot;&gt;QR Code Card&lt;/a&gt; — for example:&lt;/p&gt;
&lt;figure class=&quot;[ flex flex-col  ]&quot;&gt;&lt;picture&gt;&lt;source type=&quot;image/webp&quot; srcset=&quot;https://fedmentor.dev/posts/responsive-meaning/qr-code-design-800w.webp 800w, https://fedmentor.dev/posts/responsive-meaning/qr-code-design-1200w.webp 1200w&quot; sizes=&quot;(min-width: 40rem) 50vw, 100vw&quot; /&gt;&lt;source type=&quot;image/jpeg&quot; srcset=&quot;https://fedmentor.dev/posts/responsive-meaning/qr-code-design-800w.jpeg 800w, https://fedmentor.dev/posts/responsive-meaning/qr-code-design-1200w.jpeg 1200w&quot; sizes=&quot;(min-width: 40rem) 50vw, 100vw&quot; /&gt;&lt;img alt=&quot;The QR Code Card design showing a white card on a pale blue background. Inside this simple card is an image, a short title and a paragraph&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; src=&quot;https://fedmentor.dev/posts/responsive-meaning/qr-code-design-800w.jpeg&quot; width=&quot;1200&quot; height=&quot;666&quot; /&gt;&lt;/picture&gt;&lt;figcaption class=&quot;[ grow text-center font-bold ]&quot;&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Caption: &lt;/span&gt;The QR Code challenge design&lt;/figcaption&gt;&lt;/figure&gt;
&lt;p&gt;In this specific challenge there are no changes to the design on any screen sizes, so no need for any media query. Hooray!&lt;/p&gt;
&lt;p&gt;Nor is a media query needed on simple blog sites, like this &lt;a href=&quot;https://eleventy-base-blog.netlify.app/&quot;&gt;Eleventy Base Blog demo&lt;/a&gt;.&lt;/p&gt;
&lt;figure class=&quot;[ flex flex-col  ]&quot;&gt;&lt;picture&gt;&lt;source type=&quot;image/webp&quot; srcset=&quot;https://fedmentor.dev/posts/responsive-meaning/eleventy-base-blog-800w.webp 800w&quot; sizes=&quot;(min-width: 40rem) 50vw, 100vw&quot; /&gt;&lt;img alt=&quot;A screenshot of the Eleventy base blog with a site name and 3 nav links in the header, and a box with some text followed by a heading and 3 bullet points in the main body of the page&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; src=&quot;https://fedmentor.dev/posts/responsive-meaning/eleventy-base-blog-800w.jpeg&quot; width=&quot;800&quot; height=&quot;549&quot; /&gt;&lt;/picture&gt;&lt;figcaption class=&quot;[ grow text-center font-bold ]&quot;&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Caption: &lt;/span&gt;Eleventy Base Blog home page&lt;/figcaption&gt;&lt;/figure&gt;
&lt;p&gt;That&#39;s a boring example I know, but the important thing is it WORKS! It is functionally sound and has a simple design focused on content. We don&#39;t need to complicate the build with unnecessary media queries.&lt;/p&gt;
&lt;p&gt;Even sites like &lt;a href=&quot;https://andy-bell.co.uk/&quot;&gt;Andy Bell&#39;s personal site&lt;/a&gt; or his super interesting &lt;a href=&quot;https://set.studio/&quot;&gt;Set Studio&lt;/a&gt; site design don&#39;t have many media queries at all!&lt;/p&gt;
&lt;div class=&quot;c-img-grid c-img-grid--1-4 [ grid gap-1 pull-out ]&quot;&gt;
&lt;figure class=&quot;[ flex flex-col  ]&quot;&gt;&lt;picture&gt;&lt;source type=&quot;image/webp&quot; srcset=&quot;https://fedmentor.dev/posts/responsive-meaning/set-studio-mobile-387w.webp 387w&quot; sizes=&quot;(min-width: 40rem) 75vw, 100vw&quot; /&gt;&lt;img alt=&quot;Mobile view of a bold and colourful agency site with bright neon accent text and subtle shapes and textures at the screen edges&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; src=&quot;https://fedmentor.dev/posts/responsive-meaning/set-studio-mobile-387w.jpeg&quot; width=&quot;387&quot; height=&quot;823&quot; /&gt;&lt;/picture&gt;&lt;figcaption class=&quot;[ grow text-center font-bold ]&quot;&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Caption: &lt;/span&gt;Set.Studio on iPhone 12&lt;/figcaption&gt;&lt;/figure&gt;
&lt;figure class=&quot;[ flex flex-col  ]&quot;&gt;&lt;picture&gt;&lt;source type=&quot;image/webp&quot; srcset=&quot;https://fedmentor.dev/posts/responsive-meaning/set-studio-desktop-800w.webp 800w, https://fedmentor.dev/posts/responsive-meaning/set-studio-desktop-1200w.webp 1200w&quot; sizes=&quot;(min-width: 40rem) 25vw, 100vw&quot; /&gt;&lt;source type=&quot;image/jpeg&quot; srcset=&quot;https://fedmentor.dev/posts/responsive-meaning/set-studio-desktop-800w.jpeg 800w, https://fedmentor.dev/posts/responsive-meaning/set-studio-desktop-1200w.jpeg 1200w&quot; sizes=&quot;(min-width: 40rem) 25vw, 100vw&quot; /&gt;&lt;img alt=&quot;Large screen view of a bold and colourful agency site with bright neon accent text and loads of shapes and textures in the background&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; src=&quot;https://fedmentor.dev/posts/responsive-meaning/set-studio-desktop-800w.jpeg&quot; width=&quot;1200&quot; height=&quot;669&quot; /&gt;&lt;/picture&gt;&lt;figcaption class=&quot;[ grow text-center font-bold ]&quot;&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Caption: &lt;/span&gt;Set.Studio on a large screen&lt;/figcaption&gt;&lt;/figure&gt;
&lt;/div&gt;
&lt;h3 class=&quot;text-link&quot;&gt;A lovely media-query free example&lt;/h3&gt;
&lt;p&gt;If you&#39;ve never watched &lt;a href=&quot;https://youtube.com/watch?v=5uhIiI9Ld5M&quot;&gt;Andy&#39;s excellent talk &amp;quot;Be the browser’s mentor, not its micromanager&amp;quot;&lt;/a&gt; and had a look at the accompanying website &lt;a href=&quot;https://buildexcellentwebsit.es/&quot;&gt;Build Excellent Websites&lt;/a&gt; &lt;strong&gt;bookmark those links right now&lt;/strong&gt; and be sure to watch after reading this post.&lt;/p&gt;
&lt;div class=&quot;c-img-grid c-img-grid--1-4 [ grid gap-1 pull-out ]&quot;&gt;
&lt;figure class=&quot;[ flex flex-col  ]&quot;&gt;&lt;picture&gt;&lt;source type=&quot;image/webp&quot; srcset=&quot;https://fedmentor.dev/posts/responsive-meaning/excellent-websites-mobile-405w.webp 405w&quot; sizes=&quot;(min-width: 40rem) 25vw, 100vw&quot; /&gt;&lt;img alt=&quot;A small-screen screenshot of the &#39;Build Excellent websites&#39; demo site&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; src=&quot;https://fedmentor.dev/posts/responsive-meaning/excellent-websites-mobile-405w.jpeg&quot; width=&quot;405&quot; height=&quot;1063&quot; /&gt;&lt;/picture&gt;&lt;figcaption class=&quot;[ grow text-center font-bold ]&quot;&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Caption: &lt;/span&gt;Mobile view&lt;/figcaption&gt;&lt;/figure&gt;
&lt;figure class=&quot;[ flex flex-col  ]&quot;&gt;&lt;picture&gt;&lt;source type=&quot;image/webp&quot; srcset=&quot;https://fedmentor.dev/posts/responsive-meaning/excellent-websites-desktop-800w.webp 800w, https://fedmentor.dev/posts/responsive-meaning/excellent-websites-desktop-1200w.webp 1200w&quot; sizes=&quot;(min-width: 40rem) 75vw, 100vw&quot; /&gt;&lt;source type=&quot;image/jpeg&quot; srcset=&quot;https://fedmentor.dev/posts/responsive-meaning/excellent-websites-desktop-800w.jpeg 800w, https://fedmentor.dev/posts/responsive-meaning/excellent-websites-desktop-1200w.jpeg 1200w&quot; sizes=&quot;(min-width: 40rem) 75vw, 100vw&quot; /&gt;&lt;img alt=&quot;A large-screen screenshot of the &#39;Build Excellent websites&#39; demo site&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; src=&quot;https://fedmentor.dev/posts/responsive-meaning/excellent-websites-desktop-800w.jpeg&quot; width=&quot;1200&quot; height=&quot;696&quot; /&gt;&lt;/picture&gt;&lt;figcaption class=&quot;[ grow text-center font-bold ]&quot;&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Caption: &lt;/span&gt;Desktop view&lt;/figcaption&gt;&lt;/figure&gt;
&lt;/div&gt;
&lt;p&gt;This talk and demo site is absolute &lt;strong&gt;gold&lt;/strong&gt;. You don&#39;t need to master all of the techniques he covers straight away, I&#39;m simply sharing here to demonstrate what&#39;s possible without media queries.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Isn&#39;t it beautiful?&lt;/strong&gt; &lt;span role=&quot;presentation&quot; aria-hidden=&quot;true&quot;&gt;🤩&lt;/span&gt;&lt;/p&gt;
&lt;h2 id=&quot;media-queries-are-a-good-thing&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/responsive-meaning/#media-queries-are-a-good-thing&quot;&gt;&lt;span&gt;Media queries are a good thing&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Wait, aren&#39;t I contradicting myself now?! Didn&#39;t I just show you a load of examples &lt;em&gt;without&lt;/em&gt; (or with hardly any) media queries?&lt;/p&gt;
&lt;p&gt;Yes. I did. Sorry if that&#39;s confused you.&lt;/p&gt;
&lt;p&gt;Let me be clear: I am &lt;em&gt;not&lt;/em&gt; advocating &lt;em&gt;against&lt;/em&gt; media queries or saying you should avoid them. Media queries are not obsolete!&lt;/p&gt;
&lt;p&gt;It&#39;s GREAT to become aware of all the modern fluid layout techniques at our disposal in modern CSS, try out intrinsic sizing approaches and learn from CSS wizards like &lt;a href=&quot;https://andy-bell.co.uk/about/&quot;&gt;Andy Bell&lt;/a&gt;, &lt;a href=&quot;https://thinkdobecreate.com/&quot;&gt;Steph Eckles&lt;/a&gt;, and &lt;a href=&quot;https://www.kevinpowell.co/&quot;&gt;Kevin Powell&lt;/a&gt; (or many more!).&lt;/p&gt;
&lt;p&gt;Media queries are &lt;strong&gt;one of many valuable tools&lt;/strong&gt; at our disposal, but you need to know how to use them well, and they are not &lt;em&gt;all&lt;/em&gt; you need to know when it comes to responsive styling.&lt;/p&gt;
&lt;h2 id=&quot;how-to-best-approach-responsive-styling&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/responsive-meaning/#how-to-best-approach-responsive-styling&quot;&gt;&lt;span&gt;How to best approach responsive styling&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;As a more general answer to your questions around when and how to add breakpoints:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Do all html before anything. Make sure the right meaningful elements are chosen for the content&lt;/li&gt;
&lt;li&gt;Style the mobile design first. Shrink your viewport down, zoom and/or use device emulation view. I like to keep devtools &lt;strong&gt;open on the side&lt;/strong&gt; of my screen to make this easier.&lt;/li&gt;
&lt;li&gt;For FrontEnd mentor challenges — where the mobile static design that&#39;s provided is 375px wide — get everything looking right &lt;strong&gt;at that width first&lt;/strong&gt;. &lt;br /&gt;Then shrink the viewport width to 320px wide and check there&#39;s still no horizontal (inline) overflow and everything works. &lt;br /&gt;&lt;span role=&quot;presentation&quot; aria-hidden=&quot;true&quot;&gt;💡&lt;/span&gt; &lt;strong&gt;A top tip is to prefer max-width over width&lt;/strong&gt; for your components! Also try to avoid fixed units when using flex or grid layouts, opting for % or fr units instead.&lt;/li&gt;
&lt;li&gt;Only once you are happy with the mobile view should you start to enlarge the viewport. Depending on design, and what layout changes are needed, add a breakpoint (min-width media query) at the point where there is &lt;strong&gt;room for the layout to change&lt;/strong&gt;. Make sure you note down the media query essentials below!&lt;/li&gt;
&lt;/ol&gt;
&lt;h2 id=&quot;media-query-essentials&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/responsive-meaning/#media-query-essentials&quot;&gt;&lt;span&gt;Media query essentials&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Media queries should be written in rem/em, not px&lt;/li&gt;
&lt;li&gt;Prefer min-width media queries, so you work mobile first&lt;/li&gt;
&lt;li&gt;You will rarely if ever need to set min and max bounds on a media query. Min-width media queries say &amp;quot;from this size and up, change these properties&amp;quot; - That should be all you ever need.&lt;/li&gt;
&lt;li&gt;Tables are the one exception where I&#39;d lean towards making the desktop design the default styles. That&#39;s because data tables are generally designed to work on larger screens and their default styles will often work well on desktop. You&#39;ll need a lot more overrides for mobile in this case, so it makes sense to switch tactic and use a max-width media query there. Kevin Powell has a good video &lt;a href=&quot;https://youtu.be/czZ1PvNW5hk&quot;&gt;teaching how to build a responsive table&lt;/a&gt;, if that interests you.&lt;/li&gt;
&lt;li&gt;Media query breakpoints would be set up as variables at the start of a project on a real site, so you would select the one closest for your needs: e.g. &amp;quot;medium&amp;quot;, which may have already been set up to equate to 48rem. On personal projects, or FrontEnd Mentor challenges though, you can set up your media queries to be at whatever point &lt;em&gt;you need them to be&lt;/em&gt;. You can still set them up as variables if you want, but only add media queries when the layout &lt;strong&gt;needs&lt;/strong&gt; to change because there is enough space to do so.&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id=&quot;summary&quot; class=&quot;visually-hidden&quot;&gt;Summary&lt;/h2&gt;
&lt;aside class=&quot;c-aside c-aside--info [ relative text-body ]&quot; aria-labelledby=&quot;173fb291-2676-4f5a-b48f-698b71bbed01&quot;&gt;
  &lt;div class=&quot;c-aside__icon [ grid place-content-center ]&quot;&gt;
    &lt;svg aria-hidden=&quot;true&quot; focusable=&quot;false&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;var(--icon-fill, var(--post-bg))&quot; stroke=&quot;var(--icon-stroke, var(--rainbow--teal))&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;[ h-full w-full ]&quot;&gt;&lt;circle cx=&quot;12&quot; cy=&quot;12&quot; r=&quot;10&quot;&gt;&lt;/circle&gt;&lt;line x1=&quot;12&quot; y1=&quot;16&quot; x2=&quot;12&quot; y2=&quot;12&quot;&gt;&lt;/line&gt;&lt;line x1=&quot;12&quot; y1=&quot;8&quot; x2=&quot;12.01&quot; y2=&quot;8&quot;&gt;&lt;/line&gt;&lt;/svg&gt;
  &lt;/div&gt;
  &lt;div class=&quot;c-aside__content flow&quot;&gt;&lt;strong id=&quot;173fb291-2676-4f5a-b48f-698b71bbed01&quot; class=&quot;c-aside__title [  block font-heading leading-tight no-underline uppercase tracking-wide text-sm ]&quot;&gt;Top tips for responsive styles&lt;/strong&gt;&lt;div class=&quot;flow&quot;&gt;&lt;p&gt;What I really want to hammer home in this post is:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Let mobile styles be your default &lt;em&gt;(Data tables are probably the only exception to this!)&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;Test your solutions on small screens, making sure everything works from 320px wide and larger&lt;/li&gt;
&lt;li&gt;Stop saying that responsiveness is something you need to &amp;quot;do&amp;quot; as if it&#39;s a step you build in at the end. As front end developers, we need to consider how our sites/components should adapt &lt;strong&gt;before we write a single line of code&lt;/strong&gt;.&lt;/li&gt;
&lt;li&gt;Get into the habit of using zoom in browser AND changing your default text size&lt;/li&gt;
&lt;li&gt;Check your site on real devices whenever you can, rather than only relying on in-browser emulation&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;If you follow this advice, you&#39;ll start to build much more robust and responsive solutions!&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;/aside&gt;
</content>
	</entry>
	
	<entry>
		<title>Assistive tech familiarisation: Vision impairments</title>
		<link href="https://fedmentor.dev/posts/tech-for-vision-impairments/"/>
		<updated>2023-02-03T00:00:00Z</updated>
		<id>https://fedmentor.dev/posts/tech-for-vision-impairments/</id>
		<content type="html">&lt;aside class=&quot;c-aside c-aside--Alert [ relative text-body ]&quot; aria-labelledby=&quot;1dfe855f-0909-4b11-998d-308635d4bcd7&quot;&gt;
  &lt;div class=&quot;c-aside__icon [ grid place-content-center ]&quot;&gt;
    &lt;svg 2000=&quot;&quot; aria-hidden=&quot;true&quot; focusable=&quot;false xmlns=&quot; http:=&quot;&quot; www.w3.org=&quot;&quot; svg&quot;=&quot;&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;var(--icon-fill, var(--post-bg))&quot; stroke=&quot;var(--icon-stroke, var(--rainbow--teal))&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;[ h-full w-full ]&quot;&gt;&lt;polygon points=&quot;7.86 2 16.14 2 22 7.86 22 16.14 16.14 22 7.86 22 2 16.14 2 7.86 7.86 2&quot;&gt;&lt;/polygon&gt;&lt;line x1=&quot;12&quot; y1=&quot;8&quot; x2=&quot;12&quot; y2=&quot;12&quot;&gt;&lt;/line&gt;&lt;line x1=&quot;12&quot; y1=&quot;16&quot; x2=&quot;12.01&quot; y2=&quot;16&quot;&gt;&lt;/line&gt;&lt;/svg&gt;
  &lt;/div&gt;
  &lt;div class=&quot;c-aside__content flow&quot;&gt;&lt;strong id=&quot;1dfe855f-0909-4b11-998d-308635d4bcd7&quot; class=&quot;c-aside__title [  block font-heading leading-tight no-underline uppercase tracking-wide text-sm ]&quot;&gt;Please note!&lt;/strong&gt;&lt;div class=&quot;flow&quot;&gt;&lt;p&gt;If you are blind, have a disability or have impaired vision and believe I have used offensive or ableist language in this post, please &lt;a href=&quot;mailto:grace@fedmentor.dev?subject=Problem%20in%20Post%204&quot;&gt;let me know&lt;/a&gt;! I am always open to correction and improving awareness in this area.&lt;/p&gt;
&lt;p&gt;Similarly, please correct me if you note any inaccuracies or omissions in this post.&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;/aside&gt;
&lt;h2 id=&quot;what-are-vision-impairments&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/tech-for-vision-impairments/#what-are-vision-impairments&quot;&gt;&lt;span&gt;What are &#39;vision impairments&#39;?&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Disabilities or impairments that affect sight are &lt;strong&gt;extremely common&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Think beyond &#39;blind&#39; — All of us are likely to encounter vision issues as we age, and there are a huge variety of conditions that may affect sight and cause someone to lean on assistive technology.&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Near/Far-sightedness&lt;/li&gt;
&lt;li&gt;Peripheral vision loss / Tunnel vision&lt;/li&gt;
&lt;li&gt;Strain from looking at screens&lt;/li&gt;
&lt;li&gt;Blurred vision (sometimes known as &#39;refractive errors&#39;)&lt;/li&gt;
&lt;li&gt;Age-related degeneration&lt;/li&gt;
&lt;li&gt;Cataract&lt;/li&gt;
&lt;li&gt;Diabetic Retinopathy&lt;/li&gt;
&lt;li&gt;Glaucoma&lt;/li&gt;
&lt;li&gt;Amblyopia (also called “lazy eye”)&lt;/li&gt;
&lt;li&gt;Strabismus (known as cross- or turned-out eyes)&lt;/li&gt;
&lt;li&gt;Blindness (a spectrum)&lt;/li&gt;
&lt;li&gt;Color blindness (in various types)&lt;/li&gt;
&lt;li&gt;Temporary conditions like eye infections&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Plus many more!&lt;/p&gt;
&lt;h3 id=&quot;no-two-impairments-are-the-same&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/tech-for-vision-impairments/#no-two-impairments-are-the-same&quot;&gt;&lt;span&gt;No two impairments are the same&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Remember, even blindness is not an absolute. It is a spectrum. Blind people can usually see something, and which assistive technologies (if any) they choose to use, and in what combination, will vary from person to person.&lt;/p&gt;
&lt;p&gt;With vision issues in particular, those who need them will often be &lt;strong&gt;hybrid users&lt;/strong&gt; of several technologies and approaches. One is rarely used exclusively over another.&lt;/p&gt;
&lt;p&gt;No two people with disabilitis are the same, even if they have the same diagnosis. Humans are complex. We&#39;re a combination of genes, upbringing, experiences, abilities, and circumstances... Just as people cannot be seen in neat simplistic terms, nor can disability.&lt;/p&gt;
&lt;p&gt;Let&#39;s also remember that assistive technology is exactly that. Assistive. You don&#39;t &lt;em&gt;have&lt;/em&gt; to have a disability to use or benefit from it, but some people are reliant on these technologies because &lt;strong&gt;they are the difference between impairment and complete exclusion&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;It&#39;s not physical or cognitive impairments that make someone &amp;quot;disabled&amp;quot;. People &lt;em&gt;become&lt;/em&gt; &amp;quot;disabled&amp;quot; by poorly designed environments that lack the adaptations needed.&lt;/p&gt;
&lt;p&gt;It&#39;s up to us FEDs to improve our awareness and understanding so we don&#39;t create barriers that block people with our code.&lt;/p&gt;
&lt;h3 id=&quot;you-are-not-your-users&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/tech-for-vision-impairments/#you-are-not-your-users&quot;&gt;&lt;span&gt;You are not your users&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Although it&#39;s highly valuable for developers to gain experience using assistive technologies — &lt;strong&gt;nothing can replace real testing by those who genuinely rely on assistive technology every day&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;That&#39;s hard to organise, I know.&lt;/p&gt;
&lt;p&gt;But an important step is welcoming feedback in the first place and being willing to fix issues that are pointed out to you.&lt;/p&gt;
&lt;h2 id=&quot;assistive-tech-time&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/tech-for-vision-impairments/#assistive-tech-time&quot;&gt;&lt;span&gt;Assistive tech time!&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Now let’s look at a few tools available to us.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Familiarity with assistive tech should be empowering to us all, but especially developers, as it will help us test our solutions properly and be more aware of what we’re looking for!&lt;/strong&gt;&lt;/p&gt;
&lt;h3 id=&quot;in-browser-zoom&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/tech-for-vision-impairments/#in-browser-zoom&quot;&gt;&lt;span&gt;In-browser Zoom&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Ctrl + Plus/Minus is a quick shortcut for this in the browser.&lt;/p&gt;
&lt;p&gt;This is also a good way to test the responsiveness of your site as it should adjust into a mobile layout on desktop as you zoom.&lt;/p&gt;
&lt;h3 id=&quot;screen-magnification&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/tech-for-vision-impairments/#screen-magnification&quot;&gt;&lt;span&gt;Screen magnification&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Note, this is different to the zooming you do in the browser!&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I think this one is important to go into some detail on, as so few developers seem to be aware of it. Screen magnification is &lt;em&gt;heavily&lt;/em&gt; used by blind or partially sighted people in particular, so it&#39;s important we know about it.&lt;/p&gt;
&lt;h4&gt;Magnification on a Mac&lt;/h4&gt;
&lt;p&gt;To turn on screen magnification shortcuts on a Mac&lt;br /&gt;
&lt;em&gt;System Preferences &lt;abbr title=&quot;next&quot; class=&quot;text-link&quot;&gt;→&lt;/abbr&gt; Accessibility &lt;abbr title=&quot;next&quot; class=&quot;text-link&quot;&gt;→&lt;/abbr&gt; Zoom&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Then change the settings as you wish (e.g. I have &amp;quot;Use keyboard shortcuts to zoom toggled ON)&lt;/p&gt;
&lt;div class=&quot;c-img-grid [ grid gap-1 pull-out ]&quot;&gt;
&lt;figure class=&quot;[ flex flex-col  ]&quot;&gt;&lt;picture&gt;&lt;source type=&quot;image/webp&quot; srcset=&quot;https://fedmentor.dev/posts/tech-for-vision-impairments/zoom-settings-mac-800w.webp 800w, https://fedmentor.dev/posts/tech-for-vision-impairments/zoom-settings-mac-1200w.webp 1200w&quot; sizes=&quot;(min-width: 26rem) 70vw, 100vw&quot; /&gt;&lt;source type=&quot;image/jpeg&quot; srcset=&quot;https://fedmentor.dev/posts/tech-for-vision-impairments/zoom-settings-mac-800w.jpeg 800w, https://fedmentor.dev/posts/tech-for-vision-impairments/zoom-settings-mac-1200w.jpeg 1200w&quot; sizes=&quot;(min-width: 26rem) 70vw, 100vw&quot; /&gt;&lt;img alt=&quot;A screenshot of the mac zoom settings (OS Ventura)&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; src=&quot;https://fedmentor.dev/posts/tech-for-vision-impairments/zoom-settings-mac-800w.jpeg&quot; width=&quot;1200&quot; height=&quot;942&quot; /&gt;&lt;/picture&gt;&lt;figcaption class=&quot;[ grow text-center font-bold ]&quot;&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Caption: &lt;/span&gt;Zoom settings on a Mac&lt;/figcaption&gt;&lt;/figure&gt;
&lt;figure class=&quot;[ flex flex-col  ]&quot;&gt;&lt;picture&gt;&lt;source type=&quot;image/webp&quot; srcset=&quot;https://fedmentor.dev/posts/tech-for-vision-impairments/zoom-settings-mac-advanced-800w.webp 800w, https://fedmentor.dev/posts/tech-for-vision-impairments/zoom-settings-mac-advanced-1200w.webp 1200w&quot; sizes=&quot;(min-width: 26rem) 70vw, 100vw&quot; /&gt;&lt;source type=&quot;image/jpeg&quot; srcset=&quot;https://fedmentor.dev/posts/tech-for-vision-impairments/zoom-settings-mac-advanced-800w.jpeg 800w, https://fedmentor.dev/posts/tech-for-vision-impairments/zoom-settings-mac-advanced-1200w.jpeg 1200w&quot; sizes=&quot;(min-width: 26rem) 70vw, 100vw&quot; /&gt;&lt;img alt=&quot;A screenshot of the mac zoom advanced settings (OS Ventura)&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; src=&quot;https://fedmentor.dev/posts/tech-for-vision-impairments/zoom-settings-mac-advanced-800w.jpeg&quot; width=&quot;1200&quot; height=&quot;940&quot; /&gt;&lt;/picture&gt;&lt;figcaption class=&quot;[ grow text-center font-bold ]&quot;&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Caption: &lt;/span&gt;Advanced zoom settings on a Mac&lt;/figcaption&gt;&lt;/figure&gt;
&lt;/div&gt;
&lt;p&gt;I actually use this &lt;strong&gt;all the time&lt;/strong&gt; day-to-day! I only use the main screen magnification when testing, but use &#39;Hover text&#39; regularly because I find it helpful to enlarge text as needed.&lt;/p&gt;
&lt;div style=&quot;margin-block: 2em&quot;&gt;
&lt;figure class=&quot;[ flex flex-col  ]&quot;&gt;&lt;picture&gt;&lt;source type=&quot;image/webp&quot; srcset=&quot;https://fedmentor.dev/posts/tech-for-vision-impairments/hover-text-on-mac-800w.webp 800w, https://fedmentor.dev/posts/tech-for-vision-impairments/hover-text-on-mac-1200w.webp 1200w&quot; sizes=&quot;(min-width: 40rem) 50vw, 100vw&quot; /&gt;&lt;source type=&quot;image/jpeg&quot; srcset=&quot;https://fedmentor.dev/posts/tech-for-vision-impairments/hover-text-on-mac-800w.jpeg 800w, https://fedmentor.dev/posts/tech-for-vision-impairments/hover-text-on-mac-1200w.jpeg 1200w&quot; sizes=&quot;(min-width: 40rem) 50vw, 100vw&quot; /&gt;&lt;img alt=&quot;Hover text demo with settings text enlarged that says &#39;Press ⌘ to display a large-text view of the item under the pointer.&#39;&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; src=&quot;https://fedmentor.dev/posts/tech-for-vision-impairments/hover-text-on-mac-800w.jpeg&quot; width=&quot;1200&quot; height=&quot;521&quot; /&gt;&lt;/picture&gt;&lt;figcaption class=&quot;[ grow text-center font-bold ]&quot;&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Caption: &lt;/span&gt;Hover text on Mac OS&lt;/figcaption&gt;&lt;/figure&gt;
&lt;/div&gt;
&lt;p&gt;My active shortcut is holding down &lt;code&gt;⌘&lt;/code&gt; while hovering over the text I want to enlarge.&lt;/p&gt;
&lt;div class=&quot;no-print&quot;&gt;
  &lt;details class=&quot;c-details&quot;&gt;
    &lt;summary class=&quot;c-details__summary [ relative bg-bar ]&quot;&gt;
      &lt;strong class=&quot;c-details__title [ font-base text-body h4 ]&quot;&gt;Windows - Screen Magnification instructions&lt;/strong&gt;
    &lt;/summary&gt;
    &lt;div class=&quot;c-details__content [ flow bg-body text-body ]&quot;&gt;&lt;h4&gt;Windows: Magnification&lt;/h4&gt;
&lt;p&gt;There are slightly different &lt;a href=&quot;https://support.microsoft.com/en-us/windows/use-magnifier-to-make-things-on-the-screen-easier-to-see-414948ba-8b1c-d3bd-8615-0e5e32204198&quot;&gt;steps to follow&lt;/a&gt; on Windows 10 vs. 11.&lt;/p&gt;
&lt;p&gt;To turn on screen magnification on Windows 11:&lt;br /&gt;
&lt;em&gt;Start (windows icon) &lt;abbr title=&quot;next&quot; class=&quot;text-link&quot;&gt;→&lt;/abbr&gt; Settings &lt;abbr title=&quot;next&quot; class=&quot;text-link&quot;&gt;→&lt;/abbr&gt; Accessibility &lt;abbr title=&quot;next&quot; class=&quot;text-link&quot;&gt;→&lt;/abbr&gt; Magnifier&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;There&#39;s also a shortcut:&lt;/strong&gt; Press the &lt;code&gt;Windows logo key&lt;/code&gt; + &lt;code&gt;[+]&lt;/code&gt;. Conversely, to turn off the Magnifier, press the &lt;code&gt;Windows logo key&lt;/code&gt; + &lt;code&gt;[Esc]&lt;/code&gt;.&lt;/p&gt;
&lt;/div&gt;
  &lt;/details&gt;
&lt;/div&gt;
&lt;div class=&quot;c-details print-only&quot;&gt;
  &lt;h4&gt;Windows - Screen Magnification instructions&lt;/h4&gt;
  &lt;div class=&quot;c-details__content flow&quot;&gt;&lt;h4&gt;Windows: Magnification&lt;/h4&gt;
&lt;p&gt;There are slightly different &lt;a href=&quot;https://support.microsoft.com/en-us/windows/use-magnifier-to-make-things-on-the-screen-easier-to-see-414948ba-8b1c-d3bd-8615-0e5e32204198&quot;&gt;steps to follow&lt;/a&gt; on Windows 10 vs. 11.&lt;/p&gt;
&lt;p&gt;To turn on screen magnification on Windows 11:&lt;br /&gt;
&lt;em&gt;Start (windows icon) &lt;abbr title=&quot;next&quot; class=&quot;text-link&quot;&gt;→&lt;/abbr&gt; Settings &lt;abbr title=&quot;next&quot; class=&quot;text-link&quot;&gt;→&lt;/abbr&gt; Accessibility &lt;abbr title=&quot;next&quot; class=&quot;text-link&quot;&gt;→&lt;/abbr&gt; Magnifier&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;There&#39;s also a shortcut:&lt;/strong&gt; Press the &lt;code&gt;Windows logo key&lt;/code&gt; + &lt;code&gt;[+]&lt;/code&gt;. Conversely, to turn off the Magnifier, press the &lt;code&gt;Windows logo key&lt;/code&gt; + &lt;code&gt;[Esc]&lt;/code&gt;.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&quot;changing-browser-text-size&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/tech-for-vision-impairments/#changing-browser-text-size&quot;&gt;&lt;span&gt;Changing browser text size&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;This effectively changes what 1rem equates to in the browser. So if responsive units and layout approaches have been used correctly, the site should respond well.&lt;/p&gt;
&lt;p&gt;&lt;abbr class=&quot;[ no-underline undefined ]&quot; title=&quot;Warning emoji&quot;&gt;⚠️&lt;/abbr&gt; This is what breaks if you set your font-size, letter-spacing, or line-height in pixels! It&#39;s an essential requirement for accessibility compliance:&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;Except for captions and images of text, text can be resized without assistive technology up to 200 percent without loss of content or functionality.&lt;/p&gt;
&lt;p&gt;&lt;span class=&quot;cite&quot;&gt;&lt;a href=&quot;https://www.w3.org/WAI/WCAG21/Understanding/resize-text.html&quot;&gt;WCAG 2.1 Success Criteria 1.4.4 (level AA)&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;It is OK if this leads to horizontal scroll, as long as everything is readable and functionality maintained.&lt;/p&gt;
&lt;div class=&quot;no-print&quot;&gt;
  &lt;details class=&quot;c-details&quot;&gt;
    &lt;summary class=&quot;c-details__summary [ relative bg-bar ]&quot;&gt;
      &lt;strong class=&quot;c-details__title [ font-base text-body h4 ]&quot;&gt;Browser text resize instructions&lt;/strong&gt;
    &lt;/summary&gt;
    &lt;div class=&quot;c-details__content [ flow bg-body text-body ]&quot;&gt;&lt;h4&gt;Chrome: Browser text size&lt;/h4&gt;
&lt;p&gt;&lt;em&gt;Open Settings &lt;abbr title=&quot;next&quot; class=&quot;text-link&quot;&gt;→&lt;/abbr&gt; Search for &lt;code&gt;customise font&lt;/code&gt; &lt;abbr title=&quot;next&quot; class=&quot;text-link&quot;&gt;→&lt;/abbr&gt; Change font size using the controls&lt;/em&gt;&lt;/p&gt;
&lt;h4&gt;Firefox: Browser text size&lt;/h4&gt;
&lt;p&gt;&lt;em&gt;Open Settings &lt;abbr title=&quot;next&quot; class=&quot;text-link&quot;&gt;→&lt;/abbr&gt; Search for &lt;code&gt;font&lt;/code&gt; &lt;abbr title=&quot;next&quot; class=&quot;text-link&quot;&gt;→&lt;/abbr&gt; Change the size&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;It&#39;s worth trying this out in combination with screen magnifigation and/or zoom.&lt;/p&gt;
&lt;/div&gt;
  &lt;/details&gt;
&lt;/div&gt;
&lt;div class=&quot;c-details print-only&quot;&gt;
  &lt;h4&gt;Browser text resize instructions&lt;/h4&gt;
  &lt;div class=&quot;c-details__content flow&quot;&gt;&lt;h4&gt;Chrome: Browser text size&lt;/h4&gt;
&lt;p&gt;&lt;em&gt;Open Settings &lt;abbr title=&quot;next&quot; class=&quot;text-link&quot;&gt;→&lt;/abbr&gt; Search for &lt;code&gt;customise font&lt;/code&gt; &lt;abbr title=&quot;next&quot; class=&quot;text-link&quot;&gt;→&lt;/abbr&gt; Change font size using the controls&lt;/em&gt;&lt;/p&gt;
&lt;h4&gt;Firefox: Browser text size&lt;/h4&gt;
&lt;p&gt;&lt;em&gt;Open Settings &lt;abbr title=&quot;next&quot; class=&quot;text-link&quot;&gt;→&lt;/abbr&gt; Search for &lt;code&gt;font&lt;/code&gt; &lt;abbr title=&quot;next&quot; class=&quot;text-link&quot;&gt;→&lt;/abbr&gt; Change the size&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;It&#39;s worth trying this out in combination with screen magnifigation and/or zoom.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&quot;change-os-text-size&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/tech-for-vision-impairments/#change-os-text-size&quot;&gt;&lt;span&gt;Change OS text size&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;It&#39;s very common to change &lt;abbr title=&quot;Operating System&quot;&gt;OS&lt;/abbr&gt; text size on mobile devices. It&#39;s even more common how many apps then stop working because they&#39;ve not been tested properly!&lt;/p&gt;
&lt;aside class=&quot;c-aside c-aside--info [ relative text-body ]&quot; aria-labelledby=&quot;d69cd87c-995d-4721-bb3f-8a0714224083&quot;&gt;
  &lt;div class=&quot;c-aside__icon [ grid place-content-center ]&quot;&gt;
    &lt;svg aria-hidden=&quot;true&quot; focusable=&quot;false&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;var(--icon-fill, var(--post-bg))&quot; stroke=&quot;var(--icon-stroke, var(--rainbow--teal))&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;[ h-full w-full ]&quot;&gt;&lt;circle cx=&quot;12&quot; cy=&quot;12&quot; r=&quot;10&quot;&gt;&lt;/circle&gt;&lt;line x1=&quot;12&quot; y1=&quot;16&quot; x2=&quot;12&quot; y2=&quot;12&quot;&gt;&lt;/line&gt;&lt;line x1=&quot;12&quot; y1=&quot;8&quot; x2=&quot;12.01&quot; y2=&quot;8&quot;&gt;&lt;/line&gt;&lt;/svg&gt;
  &lt;/div&gt;
  &lt;div class=&quot;c-aside__content flow&quot;&gt;&lt;strong id=&quot;d69cd87c-995d-4721-bb3f-8a0714224083&quot; class=&quot;c-aside__title [  block font-heading leading-tight no-underline uppercase tracking-wide text-sm ]&quot;&gt;A real example from my life&lt;/strong&gt;&lt;div class=&quot;flow&quot;&gt;&lt;p&gt;I had to contact my bank about this once.&lt;/p&gt;
&lt;p&gt;I have my iOS settings very slightly enlarged. As a result, none of the click targets worked in the banking app menu.&lt;/p&gt;
&lt;p&gt;After a lengthy phone call and emails... Their solution was for me to change my text size settings back to the default, open the banking app, try to remember where to click now it&#39;s unreadable, do what I needed to do, and then change my settings back afterwards.&lt;/p&gt;
&lt;p&gt;NOT cool, &amp;lt;&#39;insert name of the bank here&#39;&amp;gt;!&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;/aside&gt;
&lt;div class=&quot;no-print&quot;&gt;
  &lt;details class=&quot;c-details&quot;&gt;
    &lt;summary class=&quot;c-details__summary [ relative bg-bar ]&quot;&gt;
      &lt;strong class=&quot;c-details__title [ font-base text-body h4 ]&quot;&gt;OS text resize instructions&lt;/strong&gt;
    &lt;/summary&gt;
    &lt;div class=&quot;c-details__content [ flow bg-body text-body ]&quot;&gt;&lt;h4&gt;iOS: Device text size&lt;/h4&gt;
&lt;p&gt;&lt;em&gt;Settings &lt;abbr title=&quot;next&quot; class=&quot;text-link&quot;&gt;→&lt;/abbr&gt; Display &amp;amp; Brightness &lt;abbr title=&quot;next&quot; class=&quot;text-link&quot;&gt;→&lt;/abbr&gt; Text Size&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Move the slider to one of the &lt;strong&gt;7 available steps&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;You can also go back to step 3 and adjust Display Zoom to &#39;Larger Text&#39;.&lt;/p&gt;
&lt;h4&gt;Android: Device text size&lt;/h4&gt;
&lt;p&gt;&lt;em&gt;Settings &lt;abbr title=&quot;next&quot; class=&quot;text-link&quot;&gt;→&lt;/abbr&gt; Display &lt;abbr title=&quot;next&quot; class=&quot;text-link&quot;&gt;→&lt;/abbr&gt; Font Size&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Move the slider to one of &lt;strong&gt;4 available steps&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;There&#39;s also a setting called &#39;Display size&#39; which zooms everything on the screen.&lt;/p&gt;
&lt;/div&gt;
  &lt;/details&gt;
&lt;/div&gt;
&lt;div class=&quot;c-details print-only&quot;&gt;
  &lt;h4&gt;OS text resize instructions&lt;/h4&gt;
  &lt;div class=&quot;c-details__content flow&quot;&gt;&lt;h4&gt;iOS: Device text size&lt;/h4&gt;
&lt;p&gt;&lt;em&gt;Settings &lt;abbr title=&quot;next&quot; class=&quot;text-link&quot;&gt;→&lt;/abbr&gt; Display &amp;amp; Brightness &lt;abbr title=&quot;next&quot; class=&quot;text-link&quot;&gt;→&lt;/abbr&gt; Text Size&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Move the slider to one of the &lt;strong&gt;7 available steps&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;You can also go back to step 3 and adjust Display Zoom to &#39;Larger Text&#39;.&lt;/p&gt;
&lt;h4&gt;Android: Device text size&lt;/h4&gt;
&lt;p&gt;&lt;em&gt;Settings &lt;abbr title=&quot;next&quot; class=&quot;text-link&quot;&gt;→&lt;/abbr&gt; Display &lt;abbr title=&quot;next&quot; class=&quot;text-link&quot;&gt;→&lt;/abbr&gt; Font Size&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Move the slider to one of &lt;strong&gt;4 available steps&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;There&#39;s also a setting called &#39;Display size&#39; which zooms everything on the screen.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&quot;color-modes-themes&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/tech-for-vision-impairments/#color-modes-themes&quot;&gt;&lt;span&gt;Color modes: Themes&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;It&#39;s increasingly common for sites and apps to offer dark and light modes. Some also change this automatically based on the time of day.&lt;/p&gt;
&lt;div class=&quot;no-print&quot;&gt;
  &lt;details class=&quot;c-details&quot;&gt;
    &lt;summary class=&quot;c-details__summary [ relative bg-bar ]&quot;&gt;
      &lt;strong class=&quot;c-details__title [ font-base text-body h4 ]&quot;&gt;Theme change instructions&lt;/strong&gt;
    &lt;/summary&gt;
    &lt;div class=&quot;c-details__content [ flow bg-body text-body ]&quot;&gt;&lt;h4&gt;Mac: Themes&lt;/h4&gt;
&lt;p&gt;&lt;em&gt;System settings &lt;abbr title=&quot;next&quot; class=&quot;text-link&quot;&gt;→&lt;/abbr&gt; Appearance &lt;abbr title=&quot;next&quot; class=&quot;text-link&quot;&gt;→&lt;/abbr&gt; Choose a theme&lt;/em&gt;&lt;/p&gt;
&lt;h4&gt;iOS: Themes&lt;/h4&gt;
&lt;p&gt;&lt;em&gt;Settings &lt;abbr title=&quot;next&quot; class=&quot;text-link&quot;&gt;→&lt;/abbr&gt; Display &amp;amp; Brightness &lt;abbr title=&quot;next&quot; class=&quot;text-link&quot;&gt;→&lt;/abbr&gt; Appearance &lt;abbr title=&quot;next&quot; class=&quot;text-link&quot;&gt;→&lt;/abbr&gt; Choose a theme&lt;/em&gt;&lt;/p&gt;
&lt;h4&gt;Windows: Themes&lt;/h4&gt;
&lt;p&gt;&lt;em&gt;Start &lt;abbr title=&quot;next&quot; class=&quot;text-link&quot;&gt;→&lt;/abbr&gt; Settings &lt;abbr title=&quot;next&quot; class=&quot;text-link&quot;&gt;→&lt;/abbr&gt; Personalization &lt;abbr title=&quot;next&quot; class=&quot;text-link&quot;&gt;→&lt;/abbr&gt; Themes &lt;abbr title=&quot;next&quot; class=&quot;text-link&quot;&gt;→&lt;/abbr&gt; &amp;quot;Change theme&amp;quot;&lt;/em&gt;&lt;/p&gt;
&lt;h4&gt;Android: Themes&lt;/h4&gt;
&lt;p&gt;&lt;em&gt;Settings &lt;abbr title=&quot;next&quot; class=&quot;text-link&quot;&gt;→&lt;/abbr&gt; Display Options &lt;abbr title=&quot;next&quot; class=&quot;text-link&quot;&gt;→&lt;/abbr&gt; Themes &lt;abbr title=&quot;next&quot; class=&quot;text-link&quot;&gt;→&lt;/abbr&gt; Choose a theme&lt;/em&gt;&lt;/p&gt;
&lt;h4&gt;Chrome: Themes&lt;/h4&gt;
&lt;p&gt;Chrome follows your system settings, but you can override it specifically for the browser:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://support.google.com/chrome/answer/9275525?hl=en&amp;amp;co=GENIE.Platform%3DAndroid&quot;&gt;on Android&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;On desktop: &lt;a href=&quot;chrome://flags/#enable-force-dark&quot;&gt;chrome://flags/#enable-force-dark&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;Firefox: Themes&lt;/h4&gt;
&lt;p&gt;&lt;em&gt;Settings &lt;abbr title=&quot;next&quot; class=&quot;text-link&quot;&gt;→&lt;/abbr&gt; Search for &#39;theme&#39; &lt;abbr title=&quot;next&quot; class=&quot;text-link&quot;&gt;→&lt;/abbr&gt; Choose a theme under &#39;Website Appearance&#39;&lt;/em&gt;&lt;/p&gt;
&lt;/div&gt;
  &lt;/details&gt;
&lt;/div&gt;
&lt;div class=&quot;c-details print-only&quot;&gt;
  &lt;h4&gt;Theme change instructions&lt;/h4&gt;
  &lt;div class=&quot;c-details__content flow&quot;&gt;&lt;h4&gt;Mac: Themes&lt;/h4&gt;
&lt;p&gt;&lt;em&gt;System settings &lt;abbr title=&quot;next&quot; class=&quot;text-link&quot;&gt;→&lt;/abbr&gt; Appearance &lt;abbr title=&quot;next&quot; class=&quot;text-link&quot;&gt;→&lt;/abbr&gt; Choose a theme&lt;/em&gt;&lt;/p&gt;
&lt;h4&gt;iOS: Themes&lt;/h4&gt;
&lt;p&gt;&lt;em&gt;Settings &lt;abbr title=&quot;next&quot; class=&quot;text-link&quot;&gt;→&lt;/abbr&gt; Display &amp;amp; Brightness &lt;abbr title=&quot;next&quot; class=&quot;text-link&quot;&gt;→&lt;/abbr&gt; Appearance &lt;abbr title=&quot;next&quot; class=&quot;text-link&quot;&gt;→&lt;/abbr&gt; Choose a theme&lt;/em&gt;&lt;/p&gt;
&lt;h4&gt;Windows: Themes&lt;/h4&gt;
&lt;p&gt;&lt;em&gt;Start &lt;abbr title=&quot;next&quot; class=&quot;text-link&quot;&gt;→&lt;/abbr&gt; Settings &lt;abbr title=&quot;next&quot; class=&quot;text-link&quot;&gt;→&lt;/abbr&gt; Personalization &lt;abbr title=&quot;next&quot; class=&quot;text-link&quot;&gt;→&lt;/abbr&gt; Themes &lt;abbr title=&quot;next&quot; class=&quot;text-link&quot;&gt;→&lt;/abbr&gt; &amp;quot;Change theme&amp;quot;&lt;/em&gt;&lt;/p&gt;
&lt;h4&gt;Android: Themes&lt;/h4&gt;
&lt;p&gt;&lt;em&gt;Settings &lt;abbr title=&quot;next&quot; class=&quot;text-link&quot;&gt;→&lt;/abbr&gt; Display Options &lt;abbr title=&quot;next&quot; class=&quot;text-link&quot;&gt;→&lt;/abbr&gt; Themes &lt;abbr title=&quot;next&quot; class=&quot;text-link&quot;&gt;→&lt;/abbr&gt; Choose a theme&lt;/em&gt;&lt;/p&gt;
&lt;h4&gt;Chrome: Themes&lt;/h4&gt;
&lt;p&gt;Chrome follows your system settings, but you can override it specifically for the browser:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://support.google.com/chrome/answer/9275525?hl=en&amp;amp;co=GENIE.Platform%3DAndroid&quot;&gt;on Android&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;On desktop: &lt;a href=&quot;chrome://flags/#enable-force-dark&quot;&gt;chrome://flags/#enable-force-dark&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h4&gt;Firefox: Themes&lt;/h4&gt;
&lt;p&gt;&lt;em&gt;Settings &lt;abbr title=&quot;next&quot; class=&quot;text-link&quot;&gt;→&lt;/abbr&gt; Search for &#39;theme&#39; &lt;abbr title=&quot;next&quot; class=&quot;text-link&quot;&gt;→&lt;/abbr&gt; Choose a theme under &#39;Website Appearance&#39;&lt;/em&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&quot;high-contrast-and-colors&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/tech-for-vision-impairments/#high-contrast-and-colors&quot;&gt;&lt;span&gt;High contrast and colors&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;The contrast and display settings are super useful! There are a lot of them though, so &lt;strong&gt;I encourage you to browse around your machine or device to see what each one does&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Devices like iPhones are particularly good at including descriptions with each control.&lt;/p&gt;
&lt;p&gt;A few examples to try:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&#39;Increase Contrast&#39; or &#39;High Contrast Mode&#39;&lt;/li&gt;
&lt;li&gt;Invert colors&lt;/li&gt;
&lt;li&gt;Filter colors&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;em&gt;(Apple includes options for specific types of color blindness too, I&#39;m not sure about Windows)&lt;/em&gt;&lt;/p&gt;
&lt;h3 id=&quot;keyboard&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/tech-for-vision-impairments/#keyboard&quot;&gt;&lt;span&gt;Keyboard&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;It is essential that a site works for keyboard users, and this affects many more people than those with visual impairments.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Always check your site functions as expected with keyboard&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;You will also need to become aware what keystrokes are expected for different &lt;abbr title=&quot;user interface&quot;&gt;UI&lt;/abbr&gt; patterns. E.g. You would use arrow keys to move between radio inputs, but tab to move between text inputs. This takes time, but is &lt;strong&gt;very easy&lt;/strong&gt; to learn!&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;I encourage you to start practicing using sites with your keyboard ASAP.&lt;/strong&gt;&lt;/p&gt;
&lt;aside class=&quot;c-aside c-aside--info [ relative text-body ]&quot; aria-labelledby=&quot;454c229a-2861-4d2d-bf38-a6772a37dab5&quot;&gt;
  &lt;div class=&quot;c-aside__icon [ grid place-content-center ]&quot;&gt;
    &lt;svg aria-hidden=&quot;true&quot; focusable=&quot;false&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;var(--icon-fill, var(--post-bg))&quot; stroke=&quot;var(--icon-stroke, var(--rainbow--teal))&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;[ h-full w-full ]&quot;&gt;&lt;circle cx=&quot;12&quot; cy=&quot;12&quot; r=&quot;10&quot;&gt;&lt;/circle&gt;&lt;line x1=&quot;12&quot; y1=&quot;16&quot; x2=&quot;12&quot; y2=&quot;12&quot;&gt;&lt;/line&gt;&lt;line x1=&quot;12&quot; y1=&quot;8&quot; x2=&quot;12.01&quot; y2=&quot;8&quot;&gt;&lt;/line&gt;&lt;/svg&gt;
  &lt;/div&gt;
  &lt;div class=&quot;c-aside__content flow&quot;&gt;&lt;strong id=&quot;454c229a-2861-4d2d-bf38-a6772a37dab5&quot; class=&quot;c-aside__title [  block font-heading leading-tight no-underline uppercase tracking-wide text-sm ]&quot;&gt;Quick Note&amp;hellip;&lt;/strong&gt;&lt;div class=&quot;flow&quot;&gt;&lt;p&gt;Note, when using a screen reader, some keyboard actions and focus management can  change! That&#39;s why it&#39;s important to test keyboard interactions with a screen reader turned on too. This is a slightly more advanced topic, and not always an expectation for junior developers.&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;/aside&gt;
&lt;h3 id=&quot;screen-readers-braille-and-voice-control&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/tech-for-vision-impairments/#screen-readers-braille-and-voice-control&quot;&gt;&lt;span&gt;Screen readers, Braille and Voice Control&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;I&#39;m not going to cover these properly now, as this post is already long enough! I&#39;m planning some &lt;a href=&quot;https://fedmentor.dev/upcoming/&quot;&gt;upcoming posts&lt;/a&gt; about these anyway.&lt;/p&gt;
&lt;p&gt;In the meantime, here are some useful resources to get you started:&lt;/p&gt;
&lt;div class=&quot;no-print&quot;&gt;
  &lt;details class=&quot;c-details&quot;&gt;
    &lt;summary class=&quot;c-details__summary [ relative bg-bar ]&quot;&gt;
      &lt;strong class=&quot;c-details__title [ font-base text-body h4 ]&quot;&gt;How to activate voice control&lt;/strong&gt;
    &lt;/summary&gt;
    &lt;div class=&quot;c-details__content [ flow bg-body text-body ]&quot;&gt;&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://support.apple.com/en-gb/HT210417&quot;&gt;Use Voice Control on your iPhone, iPad or iPod touch&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://support.microsoft.com/en-us/windows/use-voice-recognition-in-windows-83ff75bd-63eb-0b6c-18d4-6fae94050571&quot;&gt;Use voice recognition in Windows&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://support.google.com/accessibility/android/answer/6151848?hl=en&quot;&gt;Use voice commands on Android with Google&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
  &lt;/details&gt;
&lt;/div&gt;
&lt;div class=&quot;c-details print-only&quot;&gt;
  &lt;h4&gt;How to activate voice control&lt;/h4&gt;
  &lt;div class=&quot;c-details__content flow&quot;&gt;&lt;ul&gt;
&lt;li&gt;&lt;a href=&quot;https://support.apple.com/en-gb/HT210417&quot;&gt;Use Voice Control on your iPhone, iPad or iPod touch&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://support.microsoft.com/en-us/windows/use-voice-recognition-in-windows-83ff75bd-63eb-0b6c-18d4-6fae94050571&quot;&gt;Use voice recognition in Windows&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://support.google.com/accessibility/android/answer/6151848?hl=en&quot;&gt;Use voice commands on Android with Google&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;no-print&quot;&gt;
  &lt;details class=&quot;c-details&quot;&gt;
    &lt;summary class=&quot;c-details__summary [ relative bg-bar ]&quot;&gt;
      &lt;strong class=&quot;c-details__title [ font-base text-body h4 ]&quot;&gt;Screen reader guides&lt;/strong&gt;
    &lt;/summary&gt;
    &lt;div class=&quot;c-details__content [ flow bg-body text-body ]&quot;&gt;&lt;ul&gt;
&lt;li&gt;[Deque screen reader user guides and key commands](&lt;a href=&quot;https://dequeuniversity.com/screen&quot;&gt;https://dequeuniversity.com/screen&lt;/a&gt; readers/)&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://webaim.org/articles/nvda/&quot;&gt;Using NVDA (windows)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
  &lt;/details&gt;
&lt;/div&gt;
&lt;div class=&quot;c-details print-only&quot;&gt;
  &lt;h4&gt;Screen reader guides&lt;/h4&gt;
  &lt;div class=&quot;c-details__content flow&quot;&gt;&lt;ul&gt;
&lt;li&gt;[Deque screen reader user guides and key commands](&lt;a href=&quot;https://dequeuniversity.com/screen&quot;&gt;https://dequeuniversity.com/screen&lt;/a&gt; readers/)&lt;/li&gt;
&lt;li&gt;&lt;a href=&quot;https://webaim.org/articles/nvda/&quot;&gt;Using NVDA (windows)&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div class=&quot;no-print&quot;&gt;
  &lt;details class=&quot;c-details&quot;&gt;
    &lt;summary class=&quot;c-details__summary [ relative bg-bar ]&quot;&gt;
      &lt;strong class=&quot;c-details__title [ font-base text-body h4 ]&quot;&gt;Videos on how to use Screen readers&lt;/strong&gt;
    &lt;/summary&gt;
    &lt;div class=&quot;c-details__content [ flow bg-body text-body ]&quot;&gt;&lt;h4&gt;NVDA - For Windows:&lt;/h4&gt;
&lt;div class=&quot;c-iframe c-iframe--youtube&quot;&gt;&lt;iframe class=&quot;c-iframe__iframe [ w-full ]&quot; src=&quot;https://www.youtube-nocookie.com/embed/Jao3s_CwdRU&quot; title=&quot;YouTube video player for NVDA - For Windows&quot; frameborder=&quot;0&quot; allowfullscreen=&quot;&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;p class=&quot;print-only&quot;&gt;
    &lt;a href=&quot;https://www.youtu.be/Jao3s_CwdRU&quot;&gt;Youtube video: NVDA - For Windows&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;TalkBack - For Android&lt;/h4&gt;
&lt;div class=&quot;c-iframe c-iframe--youtube&quot;&gt;&lt;iframe class=&quot;c-iframe__iframe [ w-full ]&quot; src=&quot;https://www.youtube-nocookie.com/embed/0Zpzl4EKCco&quot; title=&quot;YouTube video player for TalkBack - For Android&quot; frameborder=&quot;0&quot; allowfullscreen=&quot;&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;p class=&quot;print-only&quot;&gt;
    &lt;a href=&quot;https://www.youtu.be/0Zpzl4EKCco&quot;&gt;Youtube video: TalkBack - For Android&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;Voiceover - For IOS&lt;/h4&gt;
&lt;div class=&quot;c-iframe c-iframe--youtube&quot;&gt;&lt;iframe class=&quot;c-iframe__iframe [ w-full ]&quot; src=&quot;https://www.youtube-nocookie.com/embed/bCHpdjvxBws&quot; title=&quot;YouTube video player for Voiceover - For IOS&quot; frameborder=&quot;0&quot; allowfullscreen=&quot;&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;p class=&quot;print-only&quot;&gt;
    &lt;a href=&quot;https://www.youtu.be/bCHpdjvxBws&quot;&gt;Youtube video: Voiceover - For IOS&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;VoiceOver - For Mac&lt;/h4&gt;
&lt;div class=&quot;c-iframe c-iframe--youtube&quot;&gt;&lt;iframe class=&quot;c-iframe__iframe [ w-full ]&quot; src=&quot;https://www.youtube-nocookie.com/embed/5R-6WvAihms&quot; title=&quot;YouTube video player for VoiceOver - For Mac&quot; frameborder=&quot;0&quot; allowfullscreen=&quot;&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;p class=&quot;print-only&quot;&gt;
    &lt;a href=&quot;https://www.youtu.be/5R-6WvAihms&quot;&gt;Youtube video: VoiceOver - For Mac&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;
  &lt;/details&gt;
&lt;/div&gt;
&lt;div class=&quot;c-details print-only&quot;&gt;
  &lt;h4&gt;Videos on how to use Screen readers&lt;/h4&gt;
  &lt;div class=&quot;c-details__content flow&quot;&gt;&lt;h4&gt;NVDA - For Windows:&lt;/h4&gt;
&lt;div class=&quot;c-iframe c-iframe--youtube&quot;&gt;&lt;iframe class=&quot;c-iframe__iframe [ w-full ]&quot; src=&quot;https://www.youtube-nocookie.com/embed/Jao3s_CwdRU&quot; title=&quot;YouTube video player for NVDA - For Windows&quot; frameborder=&quot;0&quot; allowfullscreen=&quot;&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;p class=&quot;print-only&quot;&gt;
    &lt;a href=&quot;https://www.youtu.be/Jao3s_CwdRU&quot;&gt;Youtube video: NVDA - For Windows&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;TalkBack - For Android&lt;/h4&gt;
&lt;div class=&quot;c-iframe c-iframe--youtube&quot;&gt;&lt;iframe class=&quot;c-iframe__iframe [ w-full ]&quot; src=&quot;https://www.youtube-nocookie.com/embed/0Zpzl4EKCco&quot; title=&quot;YouTube video player for TalkBack - For Android&quot; frameborder=&quot;0&quot; allowfullscreen=&quot;&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;p class=&quot;print-only&quot;&gt;
    &lt;a href=&quot;https://www.youtu.be/0Zpzl4EKCco&quot;&gt;Youtube video: TalkBack - For Android&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;Voiceover - For IOS&lt;/h4&gt;
&lt;div class=&quot;c-iframe c-iframe--youtube&quot;&gt;&lt;iframe class=&quot;c-iframe__iframe [ w-full ]&quot; src=&quot;https://www.youtube-nocookie.com/embed/bCHpdjvxBws&quot; title=&quot;YouTube video player for Voiceover - For IOS&quot; frameborder=&quot;0&quot; allowfullscreen=&quot;&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;p class=&quot;print-only&quot;&gt;
    &lt;a href=&quot;https://www.youtu.be/bCHpdjvxBws&quot;&gt;Youtube video: Voiceover - For IOS&lt;/a&gt;&lt;/p&gt;
&lt;h4&gt;VoiceOver - For Mac&lt;/h4&gt;
&lt;div class=&quot;c-iframe c-iframe--youtube&quot;&gt;&lt;iframe class=&quot;c-iframe__iframe [ w-full ]&quot; src=&quot;https://www.youtube-nocookie.com/embed/5R-6WvAihms&quot; title=&quot;YouTube video player for VoiceOver - For Mac&quot; frameborder=&quot;0&quot; allowfullscreen=&quot;&quot;&gt;&lt;/iframe&gt;&lt;/div&gt;&lt;p class=&quot;print-only&quot;&gt;
    &lt;a href=&quot;https://www.youtu.be/5R-6WvAihms&quot;&gt;Youtube video: VoiceOver - For Mac&lt;/a&gt;&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&quot;hardware&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/tech-for-vision-impairments/#hardware&quot;&gt;&lt;span&gt;Hardware&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;As well as all the device and system settings I&#39;ve listed, there is physical equipment that can help with vision impairments too. For example:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Large screens&lt;/li&gt;
&lt;li&gt;Curved monitors&lt;/li&gt;
&lt;li&gt;Coloured overlay screens&lt;/li&gt;
&lt;li&gt;Glasses&lt;/li&gt;
&lt;li&gt;Magnifying glass&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;em&gt;And probably loads more I&#39;ve not mentioned!&lt;/em&gt;&lt;/p&gt;
&lt;h2 id=&quot;what-to-do-with-this-information&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/tech-for-vision-impairments/#what-to-do-with-this-information&quot;&gt;&lt;span&gt;What to do with this information&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;I’m not suggesting you use all of these settings, tools and techniques daily (unless you have to). But dip in to them!&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;At a minimum, you should be testing zoom to 200%, and ensuring color contrast ratios meet WCAG AA minimum requirements (including focus outlines).&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;abbr class=&quot;[ no-underline undefined ]&quot; title=&quot;unknown emoji&quot;&gt;⭐️&lt;/abbr&gt; &lt;small&gt;&lt;em&gt;Please see the &lt;a href=&quot;https://fedmentor.dev/glossary#wcag&quot;&gt;glossary page&lt;/a&gt; if you&#39;ve not heard of WCAG before!&lt;/em&gt;&lt;/small&gt;&lt;/p&gt;
&lt;div class=&quot;no-print&quot;&gt;
  &lt;details class=&quot;c-details&quot;&gt;
    &lt;summary class=&quot;c-details__summary [ relative bg-bar ]&quot;&gt;
      &lt;strong class=&quot;c-details__title [ font-base text-body h4 ]&quot;&gt;My a11y testing process&lt;/strong&gt;
    &lt;/summary&gt;
    &lt;div class=&quot;c-details__content [ flow bg-body text-body ]&quot;&gt;&lt;p&gt;I do this for everything I build to try and ensure that relevant &lt;a href=&quot;https://www.w3.org/TR/WCAG21/#distinguishable&quot;&gt;WCAG success criteria&lt;/a&gt; are met:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Zoom in/out in the browser to 200%&lt;/li&gt;
&lt;li&gt;Resize the viewport and do the same&lt;/li&gt;
&lt;li&gt;Ensure everything interactive functions as expected with keyboard&lt;/li&gt;
&lt;li&gt;Run an automated accessibility scan (e.g. Axe DevTools, Purple Ally, Accessibility Insights or ARC Toolkit)&lt;/li&gt;
&lt;li&gt;Do a &amp;quot;reflow test&amp;quot; using the Arc Toolkit browser extension&lt;/li&gt;
&lt;li&gt;Open the page on at least one mobile. &lt;br /&gt;I will usually change the font size in my mobile browser &lt;em&gt;and&lt;/em&gt; check both portrait and landscape orientations.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Depending on time, complexity and testing support I&#39;ll test in other ways too, but not all the time.&lt;/p&gt;
&lt;p&gt;Again, you don&#39;t have to do all of this! &lt;strong&gt;Find your own process&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Just make sure everything is readable and functions when things like font size settings or colors are changed. Learning good foundational code practices, especially in HTML and CSS, will help massively with accessibility!&lt;/p&gt;
&lt;/div&gt;
  &lt;/details&gt;
&lt;/div&gt;
&lt;div class=&quot;c-details print-only&quot;&gt;
  &lt;h4&gt;My a11y testing process&lt;/h4&gt;
  &lt;div class=&quot;c-details__content flow&quot;&gt;&lt;p&gt;I do this for everything I build to try and ensure that relevant &lt;a href=&quot;https://www.w3.org/TR/WCAG21/#distinguishable&quot;&gt;WCAG success criteria&lt;/a&gt; are met:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Zoom in/out in the browser to 200%&lt;/li&gt;
&lt;li&gt;Resize the viewport and do the same&lt;/li&gt;
&lt;li&gt;Ensure everything interactive functions as expected with keyboard&lt;/li&gt;
&lt;li&gt;Run an automated accessibility scan (e.g. Axe DevTools, Purple Ally, Accessibility Insights or ARC Toolkit)&lt;/li&gt;
&lt;li&gt;Do a &amp;quot;reflow test&amp;quot; using the Arc Toolkit browser extension&lt;/li&gt;
&lt;li&gt;Open the page on at least one mobile. &lt;br /&gt;I will usually change the font size in my mobile browser &lt;em&gt;and&lt;/em&gt; check both portrait and landscape orientations.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;Depending on time, complexity and testing support I&#39;ll test in other ways too, but not all the time.&lt;/p&gt;
&lt;p&gt;Again, you don&#39;t have to do all of this! &lt;strong&gt;Find your own process&lt;/strong&gt;.&lt;/p&gt;
&lt;p&gt;Just make sure everything is readable and functions when things like font size settings or colors are changed. Learning good foundational code practices, especially in HTML and CSS, will help massively with accessibility!&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;h3 id=&quot;links-to-learn-more&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/tech-for-vision-impairments/#links-to-learn-more&quot;&gt;&lt;span&gt;Links to learn more&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&quot;https://webaim.org/articles/visual/blind&quot; target=&quot;_blank&quot; title=&quot;(opens in a new tab)&quot; rel=&quot;noreferrer noopener&quot;&gt;How blind people use the web&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&quot;https://www.w3.org/TR/WCAG21/#resize-text&quot; target=&quot;_blank&quot; title=&quot;(opens in a new tab)&quot; rel=&quot;noreferrer noopener&quot;&gt;WCAG 1.4.4 Resize Text&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&quot;https://www.w3.org/TR/WCAG21/#contrast-minimum&quot; target=&quot;_blank&quot; title=&quot;(opens in a new tab)&quot; rel=&quot;noreferrer noopener&quot;&gt;WCAG 1.4.3 Contrast Minimum&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&quot;https://dequeuniversity.com/checklists/web/text&quot; target=&quot;_blank&quot; title=&quot;(opens in a new tab)&quot; rel=&quot;noreferrer noopener&quot;&gt;Checklist to meet text Resize, Reflow and Zoom requirements&lt;/a&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;a href=&quot;https://w3c.github.io/low-vision-a11y-tf/requirements.html&quot; target=&quot;_blank&quot; title=&quot;(opens in a new tab)&quot; rel=&quot;noreferrer noopener&quot;&gt;Accessibility Requirements for People with Low Vision&lt;/a&gt;
&lt;br /&gt;&lt;small&gt;&lt;em&gt;(Note: This links to the Editor&#39;s draft 2021)&lt;/em&gt;&lt;/small&gt;&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
</content>
	</entry>
	
	<entry>
		<title>Should I change the default HTML font-size to 62.5%?</title>
		<link href="https://fedmentor.dev/posts/rem-html-font-size-hack/"/>
		<updated>2023-02-02T00:00:00Z</updated>
		<id>https://fedmentor.dev/posts/rem-html-font-size-hack/</id>
		<content type="html">&lt;h2 id=&quot;background-what-and-why&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/rem-html-font-size-hack/#background-what-and-why&quot;&gt;&lt;span&gt;Background: What and why?&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;By default, browsers set the HTML font size to 16px. &lt;strong&gt;That means 1rem (root element font-size) equates to 16px in browsers by default.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Users &lt;em&gt;can&lt;/em&gt; change this default in their browser or &lt;abbr title=&quot;Operating System&quot;&gt;OS&lt;/abbr&gt; settings, so this isn&#39;t strictly true all the time, but we&#39;ll come back to that later. For now, lets focus on &lt;code&gt;1rem === 16px&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;Historically, the rem unit didn&#39;t exist. Its introduction unlocked a whole new world for accessibility (a11y) and for responsive design, because suddenly &lt;strong&gt;font-size could SCALE&lt;/strong&gt; — It could grow and shrink depending on all sorts like zoom and personal preferences. Hallelujah!&lt;/p&gt;
&lt;p&gt;But developers then encountered a problem. They (we) want to build everything to be responsive, right? So we want to use rem units, right? But designs always show everything in pixels &lt;abbr class=&quot;[ no-underline undefined ]&quot; title=&quot;Thinking face emoji&quot;&gt;🤔&lt;/abbr&gt;…&lt;/p&gt;
&lt;p&gt;Were you taught the 16-times table in maths class at school?! Me neither. You can understand why we &lt;abbr title=&quot;Front End Developers&quot;&gt;FEDs&lt;/abbr&gt; did not particularly relish translating pixel-based designs into rem values.&lt;/p&gt;
&lt;blockquote&gt;
&lt;p&gt;I wish 1rem could equal a round number! Like 10. If 1rem was 10px, all my problems would be solved!&lt;/p&gt;
&lt;/blockquote&gt;
&lt;p&gt;That&#39;s when lots of people started recommending this:&lt;/p&gt;
&lt;pre class=&quot;language-css&quot; tabindex=&quot;0&quot; data-language=&quot;css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token selector&quot;&gt;html&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token property&quot;&gt;font-size&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; 62.5%&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Thanks to that small CSS snippet — hereafter referred to as the &lt;mark&gt;rem-font-hack&lt;/mark&gt; — 1rem can now equal 10px. The maths is easy again! A design says 16px? I know that would be 1.6rem.&lt;/p&gt;
&lt;p&gt;Developers are happy again, having made their own lives easier and &lt;strong&gt;unleashing a whole new accessibility nightmare&lt;/strong&gt; for users (and possibly their future selves and colleagues) in the process.&lt;/p&gt;
&lt;aside class=&quot;c-aside c-aside--alert [ relative text-body ]&quot; aria-labelledby=&quot;17594618-b44c-45f3-8d86-960bde8807df&quot;&gt;
  &lt;div class=&quot;c-aside__icon [ grid place-content-center ]&quot;&gt;
    &lt;svg 2000=&quot;&quot; aria-hidden=&quot;true&quot; focusable=&quot;false xmlns=&quot; http:=&quot;&quot; www.w3.org=&quot;&quot; svg&quot;=&quot;&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;var(--icon-fill, var(--post-bg))&quot; stroke=&quot;var(--icon-stroke, var(--rainbow--teal))&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;[ h-full w-full ]&quot;&gt;&lt;polygon points=&quot;7.86 2 16.14 2 22 7.86 22 16.14 16.14 22 7.86 22 2 16.14 2 7.86 7.86 2&quot;&gt;&lt;/polygon&gt;&lt;line x1=&quot;12&quot; y1=&quot;8&quot; x2=&quot;12&quot; y2=&quot;12&quot;&gt;&lt;/line&gt;&lt;line x1=&quot;12&quot; y1=&quot;16&quot; x2=&quot;12.01&quot; y2=&quot;16&quot;&gt;&lt;/line&gt;&lt;/svg&gt;
  &lt;/div&gt;
  &lt;div class=&quot;c-aside__content flow&quot;&gt;&lt;strong id=&quot;17594618-b44c-45f3-8d86-960bde8807df&quot; class=&quot;c-aside__title [  block font-heading leading-tight no-underline uppercase tracking-wide text-sm ]&quot;&gt;Quit thinking in pixels!&lt;/strong&gt;&lt;div class=&quot;flow&quot;&gt;&lt;p&gt;Before going any further, let&#39;s just pause and think - do you really &lt;em&gt;need&lt;/em&gt; to work with a &amp;quot;pixel mindset&amp;quot; at all? In the modern web, &lt;strong&gt;proportions&lt;/strong&gt; and &lt;strong&gt;fluidity&lt;/strong&gt; are much more important than fixed values.&lt;/p&gt;
&lt;p&gt;The most common layouts I build &lt;strong&gt;hardly use any pixel values at all&lt;/strong&gt;. CSS functions like &lt;code&gt;min()&lt;/code&gt;, &lt;code&gt;max()&lt;/code&gt; and &lt;code&gt;clamp()&lt;/code&gt;, or display properties like &lt;code&gt;flex&lt;/code&gt; and &lt;code&gt;grid&lt;/code&gt; open up more opportunities to build responsively. Even the humble % unit can be powerful when used well.&lt;/p&gt;
&lt;p&gt;My point is — often the people who &lt;em&gt;most&lt;/em&gt; want to change the HTML root font size are the same people who aren&#39;t fully utilising everything modern CSS has to offer.&lt;/p&gt;
&lt;p&gt;Not always true, of course. Even after this post, you may still want to use the &lt;strong&gt;rem-font-hack&lt;/strong&gt; and that&#39;s fine. &lt;strong&gt;My hope is simply that you&#39;ll be more aware of the a11y &#39;gotchas&#39; if/when you do&lt;/strong&gt;.&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;/aside&gt;
&lt;h2 id=&quot;benefits-pros&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/rem-html-font-size-hack/#benefits-pros&quot;&gt;&lt;span&gt;Benefits (pros)&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;When 1rem equals 10px, converting pixel units from design files into rems becomes (pretty) easy to do in your head.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;That&#39;s it, the only benefit. And it&#39;s 100% a benefit for &lt;strong&gt;you&lt;/strong&gt;, not for site users.&lt;/p&gt;
&lt;p&gt;You could argue this means it helps you write CSS a teeny bit faster, but as you progress you&#39;ll almost certainly have better options like Scss &lt;em&gt;(Once using tooling that can do the maths for you anyway, then the rem-font-hack may actually SLOW you down!)&lt;/em&gt;&lt;/p&gt;
&lt;h2 id=&quot;negatives-cons&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/rem-html-font-size-hack/#negatives-cons&quot;&gt;&lt;span&gt;Negatives (cons)&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;The negatives affect site users &lt;em&gt;AND&lt;/em&gt; developers.&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Potentially huge accessibility problems for anyone who changes their default font size&lt;/li&gt;
&lt;li&gt;Changing defaults is unexpected, so can confuse other developers (or even yourself in the future)&lt;/li&gt;
&lt;li&gt;Hard to maintain and even harder to remove later on&lt;/li&gt;
&lt;li&gt;Conflicts with third-party code&lt;/li&gt;
&lt;li&gt;Many engineering teams will look negatively on job applicants who use this in their code, because they are aware of the issues it can cause.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;&lt;abbr class=&quot;[ no-underline undefined ]&quot; title=&quot;Warning emoji&quot;&gt;⚠️&lt;/abbr&gt; Some sites go beyond the 62.5% rem-font-hack and resize the root font size to different values at different screen sizes. Some developers probably thought it was a nice easy way to build in responsiveness. I plead with you to &lt;strong&gt;please never do this!&lt;/strong&gt;. You&#39;ll create a nightmare for every developer who works on that site in future, as well as for users.&lt;/p&gt;
&lt;h3 id=&quot;an-a11y-disaster-with-demo&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/rem-html-font-size-hack/#an-a11y-disaster-with-demo&quot;&gt;&lt;span&gt;An A11y disaster (with demo)&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Changing the default font size on a site &lt;em&gt;can&lt;/em&gt; make that site unusable for those with a vision impairment.&lt;/p&gt;
&lt;aside class=&quot;c-aside c-aside--info [ relative text-body ]&quot; aria-labelledby=&quot;07ff52b7-a462-4e04-b30a-c34bcd0ac7c8&quot;&gt;
  &lt;div class=&quot;c-aside__icon [ grid place-content-center ]&quot;&gt;
    &lt;svg aria-hidden=&quot;true&quot; focusable=&quot;false&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;var(--icon-fill, var(--post-bg))&quot; stroke=&quot;var(--icon-stroke, var(--rainbow--teal))&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;[ h-full w-full ]&quot;&gt;&lt;circle cx=&quot;12&quot; cy=&quot;12&quot; r=&quot;10&quot;&gt;&lt;/circle&gt;&lt;line x1=&quot;12&quot; y1=&quot;16&quot; x2=&quot;12&quot; y2=&quot;12&quot;&gt;&lt;/line&gt;&lt;line x1=&quot;12&quot; y1=&quot;8&quot; x2=&quot;12.01&quot; y2=&quot;8&quot;&gt;&lt;/line&gt;&lt;/svg&gt;
  &lt;/div&gt;
  &lt;div class=&quot;c-aside__content flow&quot;&gt;&lt;strong id=&quot;07ff52b7-a462-4e04-b30a-c34bcd0ac7c8&quot; class=&quot;c-aside__title [  block font-heading leading-tight no-underline uppercase tracking-wide text-sm ]&quot;&gt;Who is affected?&lt;/strong&gt;&lt;div class=&quot;flow&quot;&gt;&lt;p&gt;Globally, at least 2.2 billion people have a vision impairment.&lt;/p&gt;
&lt;p&gt;Almost all of us will experience a deterioration in our vision as we age &lt;em&gt;(I notice this already in my 30s!)&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;Metrics have shown that &lt;strong&gt;more than a quarter of users&lt;/strong&gt; increase the default font size on iOS.&lt;/p&gt;
&lt;p&gt;We&#39;re talking BIG numbers here!&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;/aside&gt;
&lt;div class=&quot;no-print&quot;&gt;
  &lt;details class=&quot;c-details&quot;&gt;
    &lt;summary class=&quot;c-details__summary [ relative bg-bar ]&quot;&gt;
      &lt;strong class=&quot;c-details__title [ font-base text-body h4 ]&quot;&gt;How to change font size&lt;/strong&gt;
    &lt;/summary&gt;
    &lt;div class=&quot;c-details__content [ flow bg-body text-body ]&quot;&gt;&lt;p&gt;&lt;strong&gt;In Chrome&lt;/strong&gt;: Open Settings. Search for &lt;code&gt;customise font&lt;/code&gt; and change font-size.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In Firefox&lt;/strong&gt;: Open Settings. Search for &lt;code&gt;font&lt;/code&gt; and change the size.&lt;/p&gt;
&lt;p&gt;Note, those with vision impairments have other techniques available to them such as &lt;strong&gt;screen magnification&lt;/strong&gt; and zoom. It&#39;s worth learning about these too and incorporating them into your testing!&lt;/p&gt;
&lt;/div&gt;
  &lt;/details&gt;
&lt;/div&gt;
&lt;div class=&quot;c-details print-only&quot;&gt;
  &lt;h4&gt;How to change font size&lt;/h4&gt;
  &lt;div class=&quot;c-details__content flow&quot;&gt;&lt;p&gt;&lt;strong&gt;In Chrome&lt;/strong&gt;: Open Settings. Search for &lt;code&gt;customise font&lt;/code&gt; and change font-size.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;In Firefox&lt;/strong&gt;: Open Settings. Search for &lt;code&gt;font&lt;/code&gt; and change the size.&lt;/p&gt;
&lt;p&gt;Note, those with vision impairments have other techniques available to them such as &lt;strong&gt;screen magnification&lt;/strong&gt; and zoom. It&#39;s worth learning about these too and incorporating them into your testing!&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Allow me to show you what happens by changing the default font size on this site and then adding in the rem-font-hack...&lt;/p&gt;
&lt;div class=&quot;c-img-grid [ grid gap-1 pull-out ]&quot;&gt;
&lt;figure class=&quot;[ flex flex-col  ]&quot;&gt;&lt;picture&gt;&lt;source type=&quot;image/webp&quot; srcset=&quot;https://fedmentor.dev/posts/rem-html-font-size-hack/font-size-72-800w.webp 800w, https://fedmentor.dev/posts/rem-html-font-size-hack/font-size-72-1200w.webp 1200w&quot; sizes=&quot;(min-width: 40rem) 50vw, 100vw&quot; /&gt;&lt;source type=&quot;image/jpeg&quot; srcset=&quot;https://fedmentor.dev/posts/rem-html-font-size-hack/font-size-72-800w.jpeg 800w, https://fedmentor.dev/posts/rem-html-font-size-hack/font-size-72-1200w.jpeg 1200w&quot; sizes=&quot;(min-width: 40rem) 50vw, 100vw&quot; /&gt;&lt;img alt=&quot;A screenshot of this site&#39;s About page, but with the default font size changed to 72px. Only one title and 14 words are visible, demonstrating that the font has correctly resized.&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; src=&quot;https://fedmentor.dev/posts/rem-html-font-size-hack/font-size-72-800w.jpeg&quot; width=&quot;1200&quot; height=&quot;642&quot; /&gt;&lt;/picture&gt;&lt;figcaption class=&quot;[ grow text-center font-bold ]&quot;&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Caption: &lt;/span&gt;Default font size changed to 72px&lt;/figcaption&gt;&lt;/figure&gt;
&lt;figure class=&quot;[ flex flex-col  ]&quot;&gt;&lt;picture&gt;&lt;source type=&quot;image/webp&quot; srcset=&quot;https://fedmentor.dev/posts/rem-html-font-size-hack/font-size-72-with-rem-font-hack-800w.webp 800w, https://fedmentor.dev/posts/rem-html-font-size-hack/font-size-72-with-rem-font-hack-1200w.webp 1200w&quot; sizes=&quot;(min-width: 40rem) 50vw, 100vw&quot; /&gt;&lt;source type=&quot;image/jpeg&quot; srcset=&quot;https://fedmentor.dev/posts/rem-html-font-size-hack/font-size-72-with-rem-font-hack-800w.jpeg 800w, https://fedmentor.dev/posts/rem-html-font-size-hack/font-size-72-with-rem-font-hack-1200w.jpeg 1200w&quot; sizes=&quot;(min-width: 40rem) 50vw, 100vw&quot; /&gt;&lt;img alt=&quot;A screenshot of this site&#39;s About page, but with the default font size changed to 72px and the HTML font-size changed to 62.5%. The title and 40 words are visible, showing that the text is now a lot smaller than it should be.&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; src=&quot;https://fedmentor.dev/posts/rem-html-font-size-hack/font-size-72-with-rem-font-hack-800w.jpeg&quot; width=&quot;1200&quot; height=&quot;642&quot; /&gt;&lt;/picture&gt;&lt;figcaption class=&quot;[ grow text-center font-bold ]&quot;&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Caption: &lt;/span&gt;Default font size changed to 72px,&lt;br /&gt;and HTML font-size set to 62.5%&lt;/figcaption&gt;&lt;/figure&gt;
&lt;/div&gt;
&lt;p&gt;Can you see the glaring difference there? You may not think that&#39;s a big deal (I&#39;ve used the biggest font size increase to make it super obvious), but for some people, that&#39;s the difference between inclusion and exclusion.&lt;/p&gt;
&lt;h3 id=&quot;beware-the-body-resize-fix&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/rem-html-font-size-hack/#beware-the-body-resize-fix&quot;&gt;&lt;span&gt;Beware the body resize &amp;quot;fix&amp;quot;&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;You may think you can fix everything by &#39;upscaling&#39; the body font size back to &lt;code&gt;1.6rem&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;That definitely helps. It mitigates a lot of the problems... but not all of them!&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Not all font-sizes inherit. Think of form elements, for example.&lt;/li&gt;
&lt;li&gt;You still keep all of &lt;a href=&quot;https://fedmentor.dev/posts/rem-html-font-size-hack/#negatives-cons&quot;&gt;problems 2-5 listed above&lt;/a&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;aside class=&quot;c-aside c-aside--alert [ relative text-body ]&quot; aria-labelledby=&quot;debe7172-61d1-4cfc-8ebf-3ead0d8aeab8&quot;&gt;
  &lt;div class=&quot;c-aside__icon [ grid place-content-center ]&quot;&gt;
    &lt;svg 2000=&quot;&quot; aria-hidden=&quot;true&quot; focusable=&quot;false xmlns=&quot; http:=&quot;&quot; www.w3.org=&quot;&quot; svg&quot;=&quot;&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;var(--icon-fill, var(--post-bg))&quot; stroke=&quot;var(--icon-stroke, var(--rainbow--teal))&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;[ h-full w-full ]&quot;&gt;&lt;polygon points=&quot;7.86 2 16.14 2 22 7.86 22 16.14 16.14 22 7.86 22 2 16.14 2 7.86 7.86 2&quot;&gt;&lt;/polygon&gt;&lt;line x1=&quot;12&quot; y1=&quot;8&quot; x2=&quot;12&quot; y2=&quot;12&quot;&gt;&lt;/line&gt;&lt;line x1=&quot;12&quot; y1=&quot;16&quot; x2=&quot;12.01&quot; y2=&quot;16&quot;&gt;&lt;/line&gt;&lt;/svg&gt;
  &lt;/div&gt;
  &lt;div class=&quot;c-aside__content flow&quot;&gt;&lt;strong id=&quot;debe7172-61d1-4cfc-8ebf-3ead0d8aeab8&quot; class=&quot;c-aside__title [  block font-heading leading-tight no-underline uppercase tracking-wide text-sm ]&quot;&gt;Existing sites&lt;/strong&gt;&lt;div class=&quot;flow&quot;&gt;&lt;p&gt;One caveat to my advice on this - If an established site is already using the rem-font-hack, &lt;strong&gt;probably don’t remove it&lt;/strong&gt;, unless you&#39;ve been tasked with that job specifically and given adequate time and resources to do so!.&lt;/p&gt;
&lt;p&gt;Removing the rem-font-hack from a big site can be a HUGE job because every single rem value will need adjustment.&lt;/p&gt;
&lt;p&gt;That’s when the 1.6rem body &#39;re-hack&#39; is worth doing (plus overrides for third-party code or non-inheriting elements).&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;/aside&gt;
&lt;h2 id=&quot;alternative-ways-to-work-with-rem&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/rem-html-font-size-hack/#alternative-ways-to-work-with-rem&quot;&gt;&lt;span&gt;Alternative ways to work with REM&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ol&gt;
&lt;li&gt;Of course there is manual math! Do you need an alternative? You can set up variables once at the start of a project and then leave the values alone.&lt;/li&gt;
&lt;li&gt;As I mentioned earlier, modern methods like clamp() min() and max() functions mean everything is less static than it once was. Plus we even have new units now like container units! So you may not need to use rem as much.&lt;/li&gt;
&lt;li&gt;Check out &lt;a href=&quot;https://utopia.fyi/&quot;&gt;Utopia&lt;/a&gt; to generate fluid variables for you&lt;/li&gt;
&lt;li&gt;The surprisingly powerful &lt;code&gt;calc&lt;/code&gt; function can do all you need. For example: &lt;code&gt;calc((32 / 16) * 1rem)&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;My favourite approach&lt;/strong&gt; — Use a scss function! (Just like the one I use on this site)&lt;/li&gt;
&lt;/ol&gt;
&lt;pre class=&quot;language-scss&quot; tabindex=&quot;0&quot; data-language=&quot;scss&quot;&gt;&lt;code class=&quot;language-scss&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;@use&lt;/span&gt; &lt;span class=&quot;token string&quot;&gt;&#39;sass:math&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;/// Converts PX to REM&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;/// @access public&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;/// @param {string} $size - Value to be converted in PX.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;/// @returns {string} - Returns REM string.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;/// @example font-size: rem(24px);&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;/// @returns font-size: 1.5rem;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;@function&lt;/span&gt; &lt;span class=&quot;token function&quot;&gt;rem&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$size&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token property&quot;&gt;&lt;span class=&quot;token variable&quot;&gt;$remSize&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;:&lt;/span&gt; math.&lt;span class=&quot;token function&quot;&gt;div&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token variable&quot;&gt;$size&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;,&lt;/span&gt; 16px&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  &lt;span class=&quot;token keyword&quot;&gt;@return&lt;/span&gt; &lt;span class=&quot;token variable&quot;&gt;#{$remSize}&lt;/span&gt;rem&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Using something like this Sass function makes it &lt;em&gt;extremely&lt;/em&gt; easy to work with rem when you need to.&lt;/p&gt;
&lt;h2 id=&quot;in-conclusion&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/rem-html-font-size-hack/#in-conclusion&quot;&gt;&lt;span&gt;In conclusion&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;&lt;strong&gt;It doesn&#39;t matter what tutorials have taught you, or if you see others using the rem-font-hack. My years of experience have taught me that we should work with system defaults, &lt;em&gt;not&lt;/em&gt; fight against them.&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;I hope you agree of course and break the habit ASAP if you&#39;re using the rem-font-hack in your sites.&lt;/p&gt;
&lt;p&gt;But if I&#39;ve not convinced you, that&#39;s OK too. It&#39;s your choice. Just be aware of all those &lt;a href=&quot;https://fedmentor.dev/posts/rem-html-font-size-hack/#negatives-cons&quot;&gt;negatives&lt;/a&gt;, and make sure you combat them wherever possible.&lt;/p&gt;
&lt;p&gt;My goal here is simply to &lt;strong&gt;make sure you fully consider the implications of every engineering choice you make&lt;/strong&gt;.&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>Improve the format of your JavaScript selectors</title>
		<link href="https://fedmentor.dev/posts/selectors-in-js/"/>
		<updated>2023-02-01T00:00:00Z</updated>
		<id>https://fedmentor.dev/posts/selectors-in-js/</id>
		<content type="html">&lt;p&gt;There are &lt;em&gt;loads&lt;/em&gt; of ways to select elements with JavaScript...&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;code&gt;querySelector()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;querySelectorAll()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;getElementByID()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;getElementsByClassName()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;getElementsByName()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;getElementsByTagName()&lt;/code&gt;&lt;/li&gt;
&lt;li&gt;&lt;code&gt;getElementsByTagNameNS()&lt;/code&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;There&#39;s probably even more than that!&lt;/p&gt;
&lt;p&gt;Inside those &lt;mark&gt;methods&lt;/mark&gt; you pass in &lt;mark&gt;parameters&lt;/mark&gt; to select the element(s) you want (check the docs for each method if you want to know what &lt;abbr title=&quot;parameters&quot;&gt;params&lt;/abbr&gt; they can take).&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Personally, I like to use &lt;code&gt;querySelector()&lt;/code&gt; and &lt;code&gt;querySelectorAll&lt;/code&gt; pretty much exclusively.&lt;/strong&gt; Their &lt;abbr title=&quot;parameters&quot;&gt;params&lt;/abbr&gt; are just like CSS selectors we all know and love.&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot; tabindex=&quot;0&quot; data-language=&quot;javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// selector examples:&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; myElement &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;querySelector&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;.class-name&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; myElement2 &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;querySelector&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;#unique-ID&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; myElement3 &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;querySelector&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;[name=&quot;rating&quot;]&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; myNodeList &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;querySelectorAll&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;button&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;//...you get the idea!&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;div class=&quot;no-print&quot;&gt;
  &lt;details class=&quot;c-details&quot;&gt;
    &lt;summary class=&quot;c-details__summary [ relative bg-bar ]&quot;&gt;
      &lt;strong class=&quot;c-details__title [ font-base text-body h4 ]&quot;&gt;A quick note about querySelector()&lt;/strong&gt;
    &lt;/summary&gt;
    &lt;div class=&quot;c-details__content [ flow bg-body text-body ]&quot;&gt;&lt;p&gt;Remember, you don&#39;t always have to use &lt;code&gt;document&lt;/code&gt; with &lt;code&gt;querySelector()&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;An alternative can be to query other elements you&#39;ve already selected, making DOM traversal faster.&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot; tabindex=&quot;0&quot; data-language=&quot;javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; form &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;querySelector&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;.js-form&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; toggleButton &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; form&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;querySelector&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;.js-toggle&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This slightly improves performance when you can use it.&lt;/p&gt;
&lt;/div&gt;
  &lt;/details&gt;
&lt;/div&gt;
&lt;div class=&quot;c-details print-only&quot;&gt;
  &lt;h4&gt;A quick note about querySelector()&lt;/h4&gt;
  &lt;div class=&quot;c-details__content flow&quot;&gt;&lt;p&gt;Remember, you don&#39;t always have to use &lt;code&gt;document&lt;/code&gt; with &lt;code&gt;querySelector()&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;An alternative can be to query other elements you&#39;ve already selected, making DOM traversal faster.&lt;/p&gt;
&lt;pre class=&quot;language-javascript&quot; tabindex=&quot;0&quot; data-language=&quot;javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; form &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;querySelector&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;.js-form&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; toggleButton &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; form&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;querySelector&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;.js-toggle&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This slightly improves performance when you can use it.&lt;/p&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;Do you see how messy and inconsistent it can become, using whatever old &lt;abbr title=&quot;JavaScript&quot;&gt;JS&lt;/abbr&gt; selector you like? That inconsistency becomes even more evident once you work with others in a team.&lt;/p&gt;
&lt;p&gt;&lt;abbr class=&quot;[ no-underline undefined ]&quot; title=&quot;Alert emoji&quot;&gt;⚠️&lt;/abbr&gt; &lt;strong&gt;It&#39;s really good to have code standards for these things!&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;If you start implementing selectors consistently now, I &lt;em&gt;promise&lt;/em&gt; your future self (and any devs who have to work on your code in future) &lt;strong&gt;&lt;em&gt;will&lt;/em&gt; thank you&lt;/strong&gt; for it!&lt;/p&gt;
&lt;h2 id=&quot;the-problem&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/selectors-in-js/#the-problem&quot;&gt;&lt;span&gt;The problem&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Inconsistency, mixed selectors, and (even worse) nested element selectors are the enemy of clean code.&lt;/p&gt;
&lt;p&gt;The biggest issue of all when you use (or a team uses) inconsistent approaches to element selection is it &lt;strong&gt;makes your code vulnerable to bugs being caused by code in other files&lt;/strong&gt;. You lose all visibility in HTML of what JavaScript is doing.&lt;/p&gt;
&lt;aside class=&quot;c-aside c-aside--info [ relative text-body ]&quot; aria-labelledby=&quot;5b1bc8dd-d544-477f-8bbb-a9345db2eb38&quot;&gt;
  &lt;div class=&quot;c-aside__icon [ grid place-content-center ]&quot;&gt;
    &lt;svg aria-hidden=&quot;true&quot; focusable=&quot;false&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;var(--icon-fill, var(--post-bg))&quot; stroke=&quot;var(--icon-stroke, var(--rainbow--teal))&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;[ h-full w-full ]&quot;&gt;&lt;circle cx=&quot;12&quot; cy=&quot;12&quot; r=&quot;10&quot;&gt;&lt;/circle&gt;&lt;line x1=&quot;12&quot; y1=&quot;16&quot; x2=&quot;12&quot; y2=&quot;12&quot;&gt;&lt;/line&gt;&lt;line x1=&quot;12&quot; y1=&quot;8&quot; x2=&quot;12.01&quot; y2=&quot;8&quot;&gt;&lt;/line&gt;&lt;/svg&gt;
  &lt;/div&gt;
  &lt;div class=&quot;c-aside__content flow&quot;&gt;&lt;strong id=&quot;5b1bc8dd-d544-477f-8bbb-a9345db2eb38&quot; class=&quot;c-aside__title [  block font-heading leading-tight no-underline uppercase tracking-wide text-sm ]&quot;&gt;Example of fragility&lt;/strong&gt;&lt;div class=&quot;flow&quot;&gt;&lt;p&gt;Imagine your JavaScript targets a specific element like an &lt;code&gt;h3&lt;/code&gt; that has a &lt;code&gt;tabindex=&#39;-1&#39;&lt;/code&gt; so that it can move focus to that element following a user action (like clicking a button to progress through a multi-step form).&lt;/p&gt;
&lt;p&gt;Then an accessibility bug comes in saying the headings need re-ordering in the HTML.&lt;/p&gt;
&lt;p&gt;That tiny HTML fix — changing the heading to an &lt;code&gt;h2&lt;/code&gt; — &lt;strong&gt;will break the JavaScript functionality&lt;/strong&gt; because the selector no longer matches, and no one may even realise.&lt;/p&gt;
&lt;p&gt;Even if you have a file structure that groups HTML, CSS and JS together and a process in place to always check every related file, or rely on a framework where you think this wouldn&#39;t happen... Experience tells me it is so easy to miss problems like this!&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;/aside&gt;
&lt;p&gt;Another issue with inconsistent selectors is it simply slows a team down. You have to &lt;em&gt;think&lt;/em&gt; afresh every time, &amp;quot;what shall I use to get my element here?&amp;quot; Exhausting.&lt;/p&gt;
&lt;aside class=&quot;c-aside c-aside--alert [ relative text-body ]&quot; aria-labelledby=&quot;beaa4ee3-a64c-4800-a4d9-fa24cdc4259e&quot;&gt;
  &lt;div class=&quot;c-aside__icon [ grid place-content-center ]&quot;&gt;
    &lt;svg 2000=&quot;&quot; aria-hidden=&quot;true&quot; focusable=&quot;false xmlns=&quot; http:=&quot;&quot; www.w3.org=&quot;&quot; svg&quot;=&quot;&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;var(--icon-fill, var(--post-bg))&quot; stroke=&quot;var(--icon-stroke, var(--rainbow--teal))&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;[ h-full w-full ]&quot;&gt;&lt;polygon points=&quot;7.86 2 16.14 2 22 7.86 22 16.14 16.14 22 7.86 22 2 16.14 2 7.86 7.86 2&quot;&gt;&lt;/polygon&gt;&lt;line x1=&quot;12&quot; y1=&quot;8&quot; x2=&quot;12&quot; y2=&quot;12&quot;&gt;&lt;/line&gt;&lt;line x1=&quot;12&quot; y1=&quot;16&quot; x2=&quot;12.01&quot; y2=&quot;16&quot;&gt;&lt;/line&gt;&lt;/svg&gt;
  &lt;/div&gt;
  &lt;div class=&quot;c-aside__content flow&quot;&gt;&lt;strong id=&quot;beaa4ee3-a64c-4800-a4d9-fa24cdc4259e&quot; class=&quot;c-aside__title [  block font-heading leading-tight no-underline uppercase tracking-wide text-sm ]&quot;&gt;Why not IDs?&lt;/strong&gt;&lt;div class=&quot;flow&quot;&gt;&lt;p&gt;For more about &lt;strong&gt;why I discourage using IDs as JS selectors&lt;/strong&gt; check out the relevant section within this &lt;a href=&quot;https://fedmentor.dev/posts/id-attribute-masterclass#ids-as-a-js-selector&quot;&gt;ID attribute masterclass&lt;/a&gt;.&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;/aside&gt;
&lt;h2 id=&quot;the-solution&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/selectors-in-js/#the-solution&quot;&gt;&lt;span&gt;The solution&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Use a consistent method of element selection that&#39;s reserved &lt;em&gt;only&lt;/em&gt; for JavaScript.&lt;/p&gt;
&lt;h3 id=&quot;1-prefixed-classes&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/selectors-in-js/#1-prefixed-classes&quot;&gt;&lt;span&gt;1. Prefixed classes&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;&lt;abbr class=&quot;[ no-underline undefined ]&quot; title=&quot;Idea emoji&quot;&gt;💡&lt;/abbr&gt; I recommend using &lt;code&gt;js-&lt;/code&gt; prefixed class selectors on every element you need to select in JavaScript, along with &lt;code&gt;querySelector()&lt;/code&gt; or &lt;code&gt;querySelectorAll&lt;/code&gt;, like this:&lt;/p&gt;
&lt;pre class=&quot;language-html&quot; tabindex=&quot;0&quot; data-language=&quot;html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;&amp;lt;!--HTML--&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;class&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;js-toggle&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;...&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&quot;language-javascript&quot; tabindex=&quot;0&quot; data-language=&quot;javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;/* JS */&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; toggleButton &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;querySelector&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;.js-toggle&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;This approach removes all ambiguity. It can be consistently applied across a team and is immediately clear when looking at the HTML what is being affected by JavaScript. That is a &lt;strong&gt;huge bonus&lt;/strong&gt;!&lt;/p&gt;
&lt;h3 id=&quot;2-custom-data-attribute&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/selectors-in-js/#2-custom-data-attribute&quot;&gt;&lt;span&gt;2. Custom data attribute&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;A very similar alternative that&#39;s &lt;strong&gt;just as good&lt;/strong&gt; is using a specific data attribute for every element you want to select with JavaScript, like this:&lt;/p&gt;
&lt;pre class=&quot;language-html&quot; tabindex=&quot;0&quot; data-language=&quot;html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;&amp;lt;!--HTML--&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;data-js&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;toggle&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;...&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&quot;language-javascript&quot; tabindex=&quot;0&quot; data-language=&quot;javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;/* JS */&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; toggleButton &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;querySelector&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;[data-js=&quot;toggle&quot;]&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Try one of these approaches out and see how you get on...&lt;/p&gt;
&lt;h2 id=&quot;summary&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/selectors-in-js/#summary&quot;&gt;&lt;span&gt;Summary&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;Using a specific and consistent method for JS selectors
&lt;ul&gt;
&lt;li&gt;removes ambiguity&lt;/li&gt;
&lt;li&gt;bakes in that consistency&lt;/li&gt;
&lt;li&gt;removes some cognitive burden on developers&lt;/li&gt;
&lt;li&gt;and provides clear visibility of what JavaScript is doing in the HTML, leading to fewer unexpected bugs.&lt;/li&gt;
&lt;/ul&gt;
&lt;/li&gt;
&lt;li&gt;Establishing code standards — such as &amp;quot;This is how we always select elements in JavaScript&amp;quot; — can &lt;em&gt;only&lt;/em&gt; improve your code and your team&#39;s efficiency.&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;It&#39;s never too early to start building good habits! &lt;abbr class=&quot;[ no-underline undefined ]&quot; title=&quot;Wink emoji&quot;&gt;😉&lt;/abbr&gt;&lt;/p&gt;
</content>
	</entry>
	
	<entry>
		<title>What is the ID attribute in HTML really for?</title>
		<link href="https://fedmentor.dev/posts/id-attribute-masterclass/"/>
		<updated>2023-01-31T00:00:00Z</updated>
		<id>https://fedmentor.dev/posts/id-attribute-masterclass/</id>
		<content type="html">&lt;p&gt;When we talk of IDs, really we&#39;re looking at the attribute &lt;strong&gt;value&lt;/strong&gt;, as demonstrated here with &amp;quot;uniqueHeadingId&amp;quot; in this example:&lt;/p&gt;
&lt;pre class=&quot;language-html&quot; tabindex=&quot;0&quot; data-language=&quot;html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;h2&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;uniqueHeadingId&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  This heading has an ID attribute.&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;h2&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;That &lt;code&gt;uniqueHeadingId&lt;/code&gt; can be referenced and used in a variety of ways throughout Front End code. You&#39;ll see IDs in HTML, CSS and JavaScript, but that doesn&#39;t mean every code example is using them well!&lt;/p&gt;
&lt;h2 id=&quot;important-points-to-note&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/id-attribute-masterclass/#important-points-to-note&quot;&gt;&lt;span&gt;Important points to note&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;A few quick caveats about this super-important little attribute...&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;You don&#39;t need IDs on everything!&lt;/strong&gt; Only add them when you need to (see uses below).&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;IDs must not contain spaces or special characters&lt;/strong&gt;. That&#39;s invalid HTML.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&lt;strong&gt;Every ID value on a page must be unique&lt;/strong&gt;. If you remember nothing else from this post, please remember that!&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;This last point sounds easy to achieve but can be very tricky in practice. For example, consider component-based systems, (especially on CMS-powered sites) where you may not know exactly &lt;em&gt;where&lt;/em&gt; or &lt;em&gt;how frequently&lt;/em&gt; a component might be used on a page.&lt;/p&gt;
&lt;p&gt;Or course if you &lt;em&gt;know&lt;/em&gt; an element will only &lt;em&gt;ever&lt;/em&gt; occur once on a page, it&#39;s fine to hard-code an ID. For example, a menu or theme toggle located in the site header is likely to be static, so can have a hard-coded ID value.&lt;/p&gt;
&lt;p&gt;Just be warned — In other scenarios, you may need to work harder for those unique IDs!&lt;/p&gt;
&lt;aside class=&quot;c-aside c-aside--alert [ relative text-body ]&quot; aria-labelledby=&quot;bb782e84-6e1d-429c-944c-e77e0c184087&quot;&gt;
  &lt;div class=&quot;c-aside__icon [ grid place-content-center ]&quot;&gt;
    &lt;svg 2000=&quot;&quot; aria-hidden=&quot;true&quot; focusable=&quot;false xmlns=&quot; http:=&quot;&quot; www.w3.org=&quot;&quot; svg&quot;=&quot;&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;var(--icon-fill, var(--post-bg))&quot; stroke=&quot;var(--icon-stroke, var(--rainbow--teal))&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;[ h-full w-full ]&quot;&gt;&lt;polygon points=&quot;7.86 2 16.14 2 22 7.86 22 16.14 16.14 22 7.86 22 2 16.14 2 7.86 7.86 2&quot;&gt;&lt;/polygon&gt;&lt;line x1=&quot;12&quot; y1=&quot;8&quot; x2=&quot;12&quot; y2=&quot;12&quot;&gt;&lt;/line&gt;&lt;line x1=&quot;12&quot; y1=&quot;16&quot; x2=&quot;12.01&quot; y2=&quot;16&quot;&gt;&lt;/line&gt;&lt;/svg&gt;
  &lt;/div&gt;
  &lt;div class=&quot;c-aside__content flow&quot;&gt;&lt;strong id=&quot;bb782e84-6e1d-429c-944c-e77e0c184087&quot; class=&quot;c-aside__title [  block font-heading leading-tight no-underline uppercase tracking-wide text-sm ]&quot;&gt;A note on SVGs&lt;/strong&gt;&lt;div class=&quot;flow&quot;&gt;&lt;p&gt;Watch out for ID attributes on SVGs. It&#39;s fine to have IDs on &lt;strong&gt;symbols within an svg sprite&lt;/strong&gt; (IDs are used to reference those symbols and populate svgs later in the DOM).&lt;/p&gt;
&lt;p&gt;But inlining svg code that has IDs within it can easily lead to duplicate IDs being present on a page. Automated accessibility scans will usually flag that as a problem.&lt;/p&gt;
&lt;p&gt;Therefore, it&#39;s best to strip IDs from SVG code, if possible.&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;/aside&gt;
&lt;p&gt;&lt;abbr class=&quot;[ no-underline undefined ]&quot; title=&quot;unknown emoji&quot;&gt;📖&lt;/abbr&gt; Further reading on unique IDs: look up &#39;GUIDs&#39;&lt;/p&gt;
&lt;h2 id=&quot;what-can-ids-be-used-for&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/id-attribute-masterclass/#what-can-ids-be-used-for&quot;&gt;&lt;span&gt;What can IDs be used for?&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;Think of an ID an &lt;strong&gt;anchor point&lt;/strong&gt; in the HTML. That&#39;s it&#39;s primary job! But there are a number of ways it &lt;em&gt;can&lt;/em&gt; be used:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;As a CSS selector&lt;/li&gt;
&lt;li&gt;As a JS selector&lt;/li&gt;
&lt;li&gt;As an anchor for navigation&lt;/li&gt;
&lt;li&gt;As an anchor for other HTML attributes (to programmatically link elements to each other)&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Let&#39;s look at each one in turn with some practical examples.&lt;/p&gt;
&lt;h3 id=&quot;id-as-a-css-selector&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/id-attribute-masterclass/#id-as-a-css-selector&quot;&gt;&lt;span&gt;ID as a CSS selector&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;Just because you &lt;em&gt;can&lt;/em&gt; use ID attributes as style selectors, it doesn&#39;t mean you &lt;em&gt;should&lt;/em&gt;. Example:&lt;/p&gt;
&lt;pre class=&quot;language-html&quot; tabindex=&quot;0&quot; data-language=&quot;html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;&amp;lt;!-- HTML --&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;p&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;cool-id&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;...&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&quot;language-css&quot; tabindex=&quot;0&quot; data-language=&quot;css&quot;&gt;&lt;code class=&quot;language-css&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;/* CSS */&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token selector&quot;&gt;#cool-id&lt;/span&gt; &lt;span class=&quot;token punctuation&quot;&gt;{&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  ...&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;abbr class=&quot;[ no-underline undefined ]&quot; title=&quot;Warning emoji&quot;&gt;⚠️&lt;/abbr&gt; &lt;strong&gt;This is not recommended!&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;ID selectors have a &lt;strong&gt;higher specificity&lt;/strong&gt; in  CSS than classes. Generally, you want to keep CSS specificity as small/low/flat as possible. Anything that increases specificity is therefore undesirable.&lt;/p&gt;
&lt;p&gt;You may think, &amp;quot;It&#39;s fine! I know this element will only ever be used this once and will never need its styles changing.&amp;quot; But that brings up a new negative... &lt;strong&gt;Would other developers think the same?&lt;/strong&gt; (including your future self!)&lt;/p&gt;
&lt;p&gt;I&#39;ve seen IDs change a LOT while working on various code bases over the years. Either the ID names weren&#39;t clear enough, or a new system gets introduced to make sure they&#39;re always unique, or they get changed for some other reason. If (when) that happens, the styles suddenly break. And no one ever expects changing IDs to have an impact on styling because it&#39;s well-established that styling hooks should be on classes, not IDs.&lt;/p&gt;
&lt;aside class=&quot;c-aside c-aside--info [ relative text-body ]&quot; aria-labelledby=&quot;3e49ad3f-6907-4102-a362-825704236acf&quot;&gt;
  &lt;div class=&quot;c-aside__icon [ grid place-content-center ]&quot;&gt;
    &lt;svg aria-hidden=&quot;true&quot; focusable=&quot;false&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;var(--icon-fill, var(--post-bg))&quot; stroke=&quot;var(--icon-stroke, var(--rainbow--teal))&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;[ h-full w-full ]&quot;&gt;&lt;circle cx=&quot;12&quot; cy=&quot;12&quot; r=&quot;10&quot;&gt;&lt;/circle&gt;&lt;line x1=&quot;12&quot; y1=&quot;16&quot; x2=&quot;12&quot; y2=&quot;12&quot;&gt;&lt;/line&gt;&lt;line x1=&quot;12&quot; y1=&quot;8&quot; x2=&quot;12.01&quot; y2=&quot;8&quot;&gt;&lt;/line&gt;&lt;/svg&gt;
  &lt;/div&gt;
  &lt;div class=&quot;c-aside__content flow&quot;&gt;&lt;strong id=&quot;3e49ad3f-6907-4102-a362-825704236acf&quot; class=&quot;c-aside__title [  block font-heading leading-tight no-underline uppercase tracking-wide text-sm ]&quot;&gt;Summary: IDs in CSS&lt;/strong&gt;&lt;div class=&quot;flow&quot;&gt;&lt;ul&gt;
&lt;li&gt;IDs as CSS selectors &lt;strong&gt;increase CSS specificity&lt;/strong&gt;, creating the potential for &#39;style wars&#39; later&lt;/li&gt;
&lt;li&gt;IDs as CSS selectors are &lt;strong&gt;unexpected&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;IDs are &lt;strong&gt;not as permanent and unchanging as you may think&lt;/strong&gt;, making styles prone to breakage when hooked onto ID attributes&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;abbr class=&quot;[ no-underline undefined ]&quot; title=&quot;unknown emoji&quot;&gt;❌&lt;/abbr&gt; &lt;em&gt;In short, avoid using ID selectors in CSS!&lt;/em&gt;&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;/aside&gt;
&lt;h3 id=&quot;ids-as-a-js-selector&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/id-attribute-masterclass/#ids-as-a-js-selector&quot;&gt;&lt;span&gt;IDs as a JS selector&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;This isn&#39;t &lt;em&gt;as bad&lt;/em&gt; and is certainly a more common practice you&#39;ll encounter. For example:&lt;/p&gt;
&lt;pre class=&quot;language-html&quot; tabindex=&quot;0&quot; data-language=&quot;html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;&amp;lt;!--HTML--&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;super-cool-id&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;...&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;cool-id&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;...&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;pre class=&quot;language-javascript&quot; tabindex=&quot;0&quot; data-language=&quot;javascript&quot;&gt;&lt;code class=&quot;language-javascript&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;/* JS */&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; myButton &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;querySelector&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;#super-cool-id&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token comment&quot;&gt;// or... (a marginally less performant version)&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token keyword&quot;&gt;const&lt;/span&gt; myOtherButton &lt;span class=&quot;token operator&quot;&gt;=&lt;/span&gt; document&lt;span class=&quot;token punctuation&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;token function&quot;&gt;getElementByID&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;token string&quot;&gt;&#39;cool-id&#39;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;abbr class=&quot;[ no-underline undefined ]&quot; title=&quot;Warning emoji&quot;&gt;⚠️&lt;/abbr&gt; &lt;strong&gt;In my opinion&lt;/strong&gt;, using IDs as JS selectors is still not a great idea!&lt;/p&gt;
&lt;p&gt;It&#39;s sort of OK if your team has this as an established pattern because if IDs change, you and your team will know to go and check that any JavaScript functionality still works.&lt;/p&gt;
&lt;p&gt;The problems come&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;When IDs have to be &lt;strong&gt;programmatically generated&lt;/strong&gt; to be unique. Suddenly your nice code standard can&#39;t be used any more and you&#39;ll have to lean on a class or element selector instead.&lt;/li&gt;
&lt;li&gt;When there is a lack of &lt;strong&gt;clarity&lt;/strong&gt; &lt;em&gt;(How would a dev looking at the HTML &lt;strong&gt;know&lt;/strong&gt; that an ID is important for JS functionality?)&lt;/em&gt;&lt;/li&gt;
&lt;li&gt;With lack of &lt;strong&gt;consistency&lt;/strong&gt;. Usually, when people use IDs in JS, it&#39;s not an exclusive pattern. I often see a mixture of ID and element and class selectors, which can only lead to confusion and breakage as a team grows.&lt;/li&gt;
&lt;/ol&gt;
&lt;aside class=&quot;c-aside c-aside--alert [ relative text-body ]&quot; aria-labelledby=&quot;d662ce04-d997-4933-87f0-30c265364ad7&quot;&gt;
  &lt;div class=&quot;c-aside__icon [ grid place-content-center ]&quot;&gt;
    &lt;svg 2000=&quot;&quot; aria-hidden=&quot;true&quot; focusable=&quot;false xmlns=&quot; http:=&quot;&quot; www.w3.org=&quot;&quot; svg&quot;=&quot;&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;var(--icon-fill, var(--post-bg))&quot; stroke=&quot;var(--icon-stroke, var(--rainbow--teal))&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;[ h-full w-full ]&quot;&gt;&lt;polygon points=&quot;7.86 2 16.14 2 22 7.86 22 16.14 16.14 22 7.86 22 2 16.14 2 7.86 7.86 2&quot;&gt;&lt;/polygon&gt;&lt;line x1=&quot;12&quot; y1=&quot;8&quot; x2=&quot;12&quot; y2=&quot;12&quot;&gt;&lt;/line&gt;&lt;line x1=&quot;12&quot; y1=&quot;16&quot; x2=&quot;12.01&quot; y2=&quot;16&quot;&gt;&lt;/line&gt;&lt;/svg&gt;
  &lt;/div&gt;
  &lt;div class=&quot;c-aside__content flow&quot;&gt;&lt;strong id=&quot;d662ce04-d997-4933-87f0-30c265364ad7&quot; class=&quot;c-aside__title [  block font-heading leading-tight no-underline uppercase tracking-wide text-sm ]&quot;&gt;A better alternative for JS selectors&lt;/strong&gt;&lt;div class=&quot;flow&quot;&gt;&lt;p&gt;For more info on the negatives of using IDs in this way, check out this post on my &lt;a href=&quot;https://fedmentor.dev/posts/selectors-in-JS&quot;&gt;recommended approaches for JS selectors&lt;/a&gt;. Maybe you&#39;ll see an approach you prefer...&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;/aside&gt;
&lt;p&gt;A bonus of &lt;em&gt;not&lt;/em&gt; using IDs as JS selectors is that they&#39;re left alone for their real purpose... anchoring.&lt;/p&gt;
&lt;h3 id=&quot;ids-as-navigation-anchors&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/id-attribute-masterclass/#ids-as-navigation-anchors&quot;&gt;&lt;span&gt;IDs as navigation anchors&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;HTML is pretty beautiful. &lt;strong&gt;Any time you use an ID attribute, you get navigation anchors for free&lt;/strong&gt; with no extra work. That means you can add &lt;code&gt;#your-id&lt;/code&gt; to the end of any URL and jump straight to that ID&#39;s location on page load. Incredibly useful!&lt;/p&gt;
&lt;p&gt;That&#39;s how this post&#39;s table of content works, for example. Go on — &lt;a href=&quot;https://fedmentor.dev/posts/id-attribute-masterclass/#tocTitle&quot;&gt;go back to the table of contents&lt;/a&gt; and click on &amp;quot;IDs as an anchor for navigation&amp;quot;. You&#39;ll come right back here &lt;abbr class=&quot;[ no-underline undefined ]&quot; title=&quot;smile emoji&quot;&gt;😊&lt;/abbr&gt;. I&#39;ll wait...&lt;/p&gt;
&lt;aside class=&quot;c-aside c-aside--info [ relative text-body ]&quot; aria-labelledby=&quot;bb6276eb-4350-4aad-bfb9-8f1469fdd367&quot;&gt;
  &lt;div class=&quot;c-aside__icon [ grid place-content-center ]&quot;&gt;
    &lt;svg aria-hidden=&quot;true&quot; focusable=&quot;false&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;var(--icon-fill, var(--post-bg))&quot; stroke=&quot;var(--icon-stroke, var(--rainbow--teal))&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;[ h-full w-full ]&quot;&gt;&lt;circle cx=&quot;12&quot; cy=&quot;12&quot; r=&quot;10&quot;&gt;&lt;/circle&gt;&lt;line x1=&quot;12&quot; y1=&quot;16&quot; x2=&quot;12&quot; y2=&quot;12&quot;&gt;&lt;/line&gt;&lt;line x1=&quot;12&quot; y1=&quot;8&quot; x2=&quot;12.01&quot; y2=&quot;8&quot;&gt;&lt;/line&gt;&lt;/svg&gt;
  &lt;/div&gt;
  &lt;div class=&quot;c-aside__content flow&quot;&gt;&lt;strong id=&quot;bb6276eb-4350-4aad-bfb9-8f1469fdd367&quot; class=&quot;c-aside__title [  block font-heading leading-tight no-underline uppercase tracking-wide text-sm ]&quot;&gt;Quick Note&amp;hellip;&lt;/strong&gt;&lt;div class=&quot;flow&quot;&gt;&lt;p&gt;Did you know web pages have a built-in ID specifically for navigating &lt;a href=&quot;https://fedmentor.dev/posts/id-attribute-masterclass/#top&quot;&gt;&lt;strong&gt;back to the top&lt;/strong&gt;&lt;/a&gt; of a page? There&#39;s no need to add a custom ID for this kind of jump link.&lt;/p&gt;
&lt;p&gt;All you need is a link with &lt;code&gt;href=&amp;quot;#top&amp;quot;&lt;/code&gt; and you&#39;ll scroll there without reloading the page.&lt;/p&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;/aside&gt;
&lt;h3 id=&quot;ids-as-element-anchors&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/id-attribute-masterclass/#ids-as-element-anchors&quot;&gt;&lt;span&gt;IDs as element anchors&lt;/span&gt;&lt;/a&gt;&lt;/h3&gt;
&lt;p&gt;&lt;strong&gt;Finally, the good stuff!&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;This&lt;/em&gt; is where IDs shine (and why it&#39;s so important that they are unique)! Take this example from the &lt;a href=&quot;https://www.frontendmentor.io/challenges/intro-component-with-signup-form-5cf91bd49edda32581d28fd1&quot;&gt;Frontend Mentor &#39;Intro component with sign-up form&#39; challenge&lt;/a&gt;:&lt;/p&gt;
&lt;figure class=&quot;[ flex flex-col  ]&quot;&gt;&lt;picture&gt;&lt;source type=&quot;image/webp&quot; srcset=&quot;https://fedmentor.dev/posts/id-attribute-masterclass/intro-with-signup-button-terms-800w.webp 800w, https://fedmentor.dev/posts/id-attribute-masterclass/intro-with-signup-button-terms-1200w.webp 1200w&quot; sizes=&quot;(min-width: 40rem) 50vw, 100vw&quot; /&gt;&lt;source type=&quot;image/jpeg&quot; srcset=&quot;https://fedmentor.dev/posts/id-attribute-masterclass/intro-with-signup-button-terms-800w.jpeg 800w, https://fedmentor.dev/posts/id-attribute-masterclass/intro-with-signup-button-terms-1200w.jpeg 1200w&quot; sizes=&quot;(min-width: 40rem) 50vw, 100vw&quot; /&gt;&lt;img alt=&quot;Clipped portion of a design showing a button that says &#39;Claim your free trial&#39; with writing underneath that says &#39;By clicking the button, you are agreeing to our Terms and Services&#39; where terms and services is a link&quot; loading=&quot;lazy&quot; decoding=&quot;async&quot; src=&quot;https://fedmentor.dev/posts/id-attribute-masterclass/intro-with-signup-button-terms-800w.jpeg&quot; width=&quot;1200&quot; height=&quot;330&quot; /&gt;&lt;/picture&gt;&lt;/figure&gt;
&lt;p&gt;Laying aside some of the accessibility issues like color contrast and the DOM order in this design &lt;em&gt;(and laying aside the fact that this design would probably break EU law, which requires an explicit terms and conditions opt-in)&lt;/em&gt;, I would write the mark up as follows:&lt;/p&gt;
&lt;pre class=&quot;language-html&quot; tabindex=&quot;0&quot; data-language=&quot;html&quot;&gt;&lt;code class=&quot;language-html&quot;&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;button&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;type&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;button&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;aria-describedby&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;terms&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  Claim your free trial&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;button&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;p&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;id&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;terms&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;  By clicking the button, you are agreeing to our &lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;&lt;/span&gt;a&lt;/span&gt; &lt;span class=&quot;token attr-name&quot;&gt;href&lt;/span&gt;&lt;span class=&quot;token attr-value&quot;&gt;&lt;span class=&quot;token punctuation attr-equals&quot;&gt;=&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;/&lt;span class=&quot;token punctuation&quot;&gt;&quot;&lt;/span&gt;&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;Terms and Services&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;a&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;&lt;span class=&quot;highlight-line&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token tag&quot;&gt;&lt;span class=&quot;token punctuation&quot;&gt;&amp;lt;/&lt;/span&gt;p&lt;/span&gt;&lt;span class=&quot;token punctuation&quot;&gt;&gt;&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;abbr class=&quot;[ no-underline undefined ]&quot; title=&quot;unknown emoji&quot;&gt;✅&lt;/abbr&gt;  This is the perfect use case for an ID attribute!&lt;/p&gt;
&lt;p&gt;Thanks to this little ID, aria-describedby can now &lt;strong&gt;programmatically link&lt;/strong&gt; the terms to the form submit button. That means, on focus of the button, a screen reader will now announce &lt;q&gt;button, submit, by clicking the button you are agreeing...&lt;/q&gt;&lt;/p&gt;
&lt;p&gt;Check out the HTML in this CodePen for more good use cases:&lt;/p&gt;
&lt;div class=&quot;c-iframe c-iframe--codepen &quot;&gt;&lt;iframe class=&quot;c-iframe__iframe [ h-full w-full ]&quot; style=&quot;--media-ratio: 3/2&quot; title=&quot;Good use-cases for the ID attribute&quot; src=&quot;https://codepen.io/grace-snow/embed/abjKyBe?default-tab=html,result&amp;theme-id=dark&quot; frameborder=&quot;0&quot; loading=&quot;lazy&quot; allowtransparency=&quot;true&quot; scrolling=&quot;no&quot; allowfullscreen=&quot;true&quot;&gt;&lt;p&gt;&lt;a href=&quot;https://codepen.io/grace-snow/pen/abjKyBe?editors=0100&quot; target=&quot;_blank&quot; rel=&quot;noopener&quot;&gt;See the Pen&lt;/a&gt;&lt;/p&gt;&lt;/iframe&gt;&lt;/div&gt;
    &lt;p class=&quot;print-only&quot;&gt;
      &lt;a href=&quot;https://codepen.io/grace-snow/pen/abjKyBe?editors=0100&quot;&gt;CodePen code example: Good use-cases for the ID attribute&lt;/a&gt;
    &lt;/p&gt;
&lt;aside class=&quot;c-aside c-aside--info [ relative text-body ]&quot; aria-labelledby=&quot;b98dc741-f2a6-409d-a3a7-ec3765ccb142&quot;&gt;
  &lt;div class=&quot;c-aside__icon [ grid place-content-center ]&quot;&gt;
    &lt;svg aria-hidden=&quot;true&quot; focusable=&quot;false&quot; xmlns=&quot;http://www.w3.org/2000/svg&quot; viewBox=&quot;0 0 24 24&quot; fill=&quot;var(--icon-fill, var(--post-bg))&quot; stroke=&quot;var(--icon-stroke, var(--rainbow--teal))&quot; stroke-width=&quot;2&quot; stroke-linecap=&quot;round&quot; stroke-linejoin=&quot;round&quot; class=&quot;[ h-full w-full ]&quot;&gt;&lt;circle cx=&quot;12&quot; cy=&quot;12&quot; r=&quot;10&quot;&gt;&lt;/circle&gt;&lt;line x1=&quot;12&quot; y1=&quot;16&quot; x2=&quot;12&quot; y2=&quot;12&quot;&gt;&lt;/line&gt;&lt;line x1=&quot;12&quot; y1=&quot;8&quot; x2=&quot;12.01&quot; y2=&quot;8&quot;&gt;&lt;/line&gt;&lt;/svg&gt;
  &lt;/div&gt;
  &lt;div class=&quot;c-aside__content flow&quot;&gt;&lt;strong id=&quot;b98dc741-f2a6-409d-a3a7-ec3765ccb142&quot; class=&quot;c-aside__title [  block font-heading leading-tight no-underline uppercase tracking-wide text-sm ]&quot;&gt;Summary: IDs as anchors&lt;/strong&gt;&lt;div class=&quot;flow&quot;&gt;&lt;p&gt;&lt;strong&gt;These are some of the most common &lt;em&gt;good&lt;/em&gt; use cases for using IDS (often with aria)&lt;/strong&gt;&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;Giving elements an accessible name with aria-labelledby&lt;/li&gt;
&lt;li&gt;Linking inputs to error message containers&lt;/li&gt;
&lt;li&gt;Linking supplementary information or help text in forms&lt;/li&gt;
&lt;li&gt;Linking repetitive buttons (like &amp;quot;read more&amp;quot; on a set of cards) to their closest title&lt;/li&gt;
&lt;li&gt;Linking svgs to a symbol in an svg sprite&lt;/li&gt;
&lt;li&gt;In-page navigation&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;&lt;/div&gt;
&lt;/aside&gt;
&lt;h2 id=&quot;summing-up&quot; tabindex=&quot;-1&quot;&gt;&lt;a class=&quot;header-anchor&quot; href=&quot;https://fedmentor.dev/posts/id-attribute-masterclass/#summing-up&quot;&gt;&lt;span&gt;Summing up&lt;/span&gt;&lt;/a&gt;&lt;/h2&gt;
&lt;p&gt;I hope this has helped you gain a deeper understanding of how powerful and important IDs can be in HTML.&lt;/p&gt;
&lt;p&gt;Take this as both&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;&lt;strong&gt;A challenge&lt;/strong&gt; - to only use IDs for navigation and programmatically linking elements&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;And an opportunity&lt;/strong&gt; - to learn a little sprinkling of aria &lt;abbr class=&quot;[ no-underline undefined ]&quot; title=&quot;winking face  emoji&quot;&gt;😉&lt;/abbr&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;&lt;em&gt;Just remember - no aria is often better than the wrong aria! So test, test, test! And ask for help and feedback from others while you practice.&lt;/em&gt;&lt;/p&gt;
</content>
	</entry>
</feed>
