Frontend Masters Boost RSS Feed https://frontendmasters.com/blog Helping Your Journey to Senior Developer Tue, 14 Oct 2025 15:51:14 +0000 en-US hourly 1 https://wordpress.org/?v=6.8.3 225069128 A11Y Linting HTML with CSS https://frontendmasters.com/blog/a11y-linting-html-with-css/ https://frontendmasters.com/blog/a11y-linting-html-with-css/#respond Tue, 14 Oct 2025 15:51:12 +0000 https://frontendmasters.com/blog/?p=7418 Will Mendes has a bit of CSS to highlight accessibility issues on HTML elements. Things like missing alt text and labels that aren’t linked properly to inputs. If you want to try it out quick on a website, I wrapped it in a little injection JavaScript so you could paste it in the console wherever.

Console Code
document.head.insertAdjacentHTML("beforeend", `<style>html:not([lang]),
html[lang=""] {
  border: 2px dotted red !important;
}

/*  highlight images missing alt text */
img:not([alt]) {
  filter: blur(5px) !important;
}

/* highlight on all elements that are inside of lists but not a list item <li> and displays them with a red outline.*/
:is(ul, ol) > *:not(li) {
  outline: 2px dotted red !important;
}

/* highlight on links without valid href attribute */
a:not([href]),
a[href="#"],
a[href=""],
a[href*="javascript:void(0)"] {
  outline: 2px dotted red !important;
}

/* highlights label with invalid for attribute */
label:not([for]),
label[for="#"],
label[for=""] {
  border: 2px dotted red !important;
}

/* Avoids div buttons from hell. More details in https://www.htmhell.dev/2-div-with-button-role/ */
div[role="button"] {
  color: red;
  text-decoration: blink !important;
}

/* highlight on empty anchors/buttons */
button:empty,
a:empty {
  border: 2px dotted red !important;
}</style>`);

Not that you should be pasting code that strangers give you into the console. But ya know, we’re cool.

]]>
https://frontendmasters.com/blog/a11y-linting-html-with-css/feed/ 0 7418
Style your underlines https://frontendmasters.com/blog/style-your-underlines/ https://frontendmasters.com/blog/style-your-underlines/#respond Tue, 02 Sep 2025 22:02:55 +0000 https://frontendmasters.com/blog/?p=7059 Jeremy Keith:

We shouldn’t rely on colour alone to indicate that something is interactive.

Then goes on to show how links should be underlined, but that the default underline can be a little intense, and essentially shows how to chill them out. Exactly like we showed! I still think it’s a great balance.

]]>
https://frontendmasters.com/blog/style-your-underlines/feed/ 0 7059
contrast-color() ships in Safari Technology Preview https://frontendmasters.com/blog/contrast-color-ships-in-safari-technology-preview/ https://frontendmasters.com/blog/contrast-color-ships-in-safari-technology-preview/#respond Thu, 15 May 2025 19:09:12 +0000 https://frontendmasters.com/blog/?p=5895 When I first looked at the new color contract function in CSS, the words were reversed, so that’s notable. It’s contrast-color() now, and starting it’s life in Safari Technology Preview. Now it only takes one argument, a color, and you get back either black or white (rather than providing your own color choices). Once this makes it’s way to a browser support level you’re comfortable with, it seems like a nicely low-effort way to ensure an accessible color to sit on top of an unknown background, so long as that background is a solid color. Except that it’s using the WCAG 2 algorithm to make the choices, and it has some notable limitations, including literally make the wrong call. But it’s possible the underlying algorithm gets updated to APCA, which seems much smarter, doing things like factoring in size and weight, but it’s unclear if browsers will ever be allowed to use it Because Drama™.

]]>
https://frontendmasters.com/blog/contrast-color-ships-in-safari-technology-preview/feed/ 0 5895
Comparing local large language models for alt-text generation https://frontendmasters.com/blog/comparing-local-large-language-models-for-alt-text-generation/ https://frontendmasters.com/blog/comparing-local-large-language-models-for-alt-text-generation/#respond Mon, 17 Mar 2025 17:21:14 +0000 https://frontendmasters.com/blog/?p=5415 Dries Buytaert:

I have 10,000 photos on my website. About 9,000 have no alt-text. I’m not proud of that, and it has bothered me for a long time.

Going back and hand-writing alt for 9,000 images isn’t a job that most of us can fit into our lives and I empathize. Are computers up for the task finally? Rather than pick a model and wire it up and do it, Dries wanted to do some testing and pick the best option. The answer isn’t perfectly clear, but there are some decent options and other forward thinking ideas here.

]]>
https://frontendmasters.com/blog/comparing-local-large-language-models-for-alt-text-generation/feed/ 0 5415
Automatically Contrasted Colors https://frontendmasters.com/blog/automatically-contrasted-colors/ https://frontendmasters.com/blog/automatically-contrasted-colors/#respond Tue, 10 Dec 2024 18:29:18 +0000 https://frontendmasters.com/blog/?p=4781 What is a good contrast text color on a black background? White. What about on a white background? Black. What about on #f06d06? Less clear. Devon Govett posted a good trick to having CSS pick for you, which works across browsers today. Lea Verou has a much deeper dive. There is supposed to be a CSS color-contrast() function, but it’s not usable across browsers yet.

]]>
https://frontendmasters.com/blog/automatically-contrasted-colors/feed/ 0 4781
Display Contents https://frontendmasters.com/blog/display-contents/ https://frontendmasters.com/blog/display-contents/#respond Thu, 19 Sep 2024 19:25:50 +0000 https://frontendmasters.com/blog/?p=3892 Ahmad Shadeed on CSS display: contents; — a feature that makes the DOM pretend that element just isn’t there (but it’s children are). Anything you use it for requires specific accessibility testing, but it can be quite useful. There are lots of use-cases here many of which boil down to “sometimes I want all these elements to be siblings, and sometimes I want wrappers around some of them”. I like Jeremy’s idea that HTML web component wrappers use this to remove themselves from equation, if the only purpose of that web component is augmenting the content already within it.

]]>
https://frontendmasters.com/blog/display-contents/feed/ 0 3892
“Why does this have to be a modal?” https://frontendmasters.com/blog/why-does-this-have-to-be-a-modal/ https://frontendmasters.com/blog/why-does-this-have-to-be-a-modal/#respond Tue, 17 Sep 2024 15:51:50 +0000 https://frontendmasters.com/blog/?p=3873 It’s not that modals are all automatically bad, it’s that, as Adrian Egger says, “modals are the crutch of the inarticulate design and developer” and they “are easily replaced with other patterns that are less jarring.” on the dedicated site for this crusade: modalzmodalzmodalz.com. Adrian’s personal site is sweet, too.

]]>
https://frontendmasters.com/blog/why-does-this-have-to-be-a-modal/feed/ 0 3873
(Danger!) Preventing Zoom from Changing Text Size https://frontendmasters.com/blog/danger-preventing-zoom-from-changing-text-size/ https://frontendmasters.com/blog/danger-preventing-zoom-from-changing-text-size/#respond Wed, 22 May 2024 20:18:08 +0000 https://frontendmasters.com/blog/?p=2356 Zooming in browsers is an accessibility feature. I’d say that any attempt to fight against it is bad form. Don’t do it. Leave it be.

I have seen compelling examples of ways to code that work with browser zoom that help make a site look nicer when high levels of zoom are applied. But they don’t fight against it.

You might say: but I zoomed my site in to 500% and it looks bad! It might, it’s true. But that’s just, like, your opinion, man. Zoom works consistently. People that use it know what it does. They know what to expect. They aren’t you, they might have a different approach an expectation than you do.

I wanted to write all that before I share this snippet. This is a variation of what someone sent me the other day as a way to size type that scales with the window:

html {
  --size-factor: (0.00188323 * 100vw);
  font-size: calc(12 * var(--size-factor));
}

Their version was a bit more exotic, incorporating different scaling numbers for pages in landscape vs. portrait and such. This has the effect of “fluid type” on a website, the bigger the window, the bigger the type, and vice versa. The magic number you see above there is essentially so that that you can multiply against it with reasonable numbers that maybe feel something close to pixel (px) numbers, 12px in this case. In that way, it’s a lot like the font-size: 62.5%; thing we used to see a lot such that the math works out that 1.2rem would be 12px (you can do it in your head easier). I’d suggest scrapping that thinking. Don’t think about font sizing in pixels at all — it isn’t useful.

What is ultimately going on here though is that the font-size is being set in viewpoint units only. This is what “fights” the browser zoom. I could have done html { font-size: 3vw; } and the effect would have been basically the same.

The reason you see any shift at all here is that the body’s default margin of 8px is scaling up with the zooming.

Bad news bears.

The advice: any time you are setting a font-size, it cannot only be viewport units. It has to factor in some other kind of unit. Heck, even px works to maintain some scaling. Even this freaks me out a little bit because it affects that rate of scaling and if you speed that up or slow that down too much, that’s also messing up with the natural exceptions of how zoom works.

The best approach that I know of is to use clamp() so that font-size can’t get too big or too small based on window size alone, then include a rem value (that’s somewhere in the vicinity of 1) in the calculation such that zooming still works normally.

See the Fluid Type Scale website for easy to generate snippets.

And this goes for using container units too!

]]>
https://frontendmasters.com/blog/danger-preventing-zoom-from-changing-text-size/feed/ 0 2356
On Alt https://frontendmasters.com/blog/on-alt/ https://frontendmasters.com/blog/on-alt/#respond Wed, 01 May 2024 14:36:50 +0000 https://frontendmasters.com/blog/?p=2014 Jake Archibald, by way of being convinced by Léonie Watson, says that the alt text of an of <img src="..." alt="..." width="..." height="..."> should evoke emotion:

The relevant parts of an image aren’t limited to the cold hard facts. Images can make you feel a particular way, and that’s something that should be made available to a screen reader user.

If necessary, that is. Some images just aren’t particularly emotional, like a screenshot of a banking dashboard. I think what Scott Vandehey says is a more broadly useful way to think about it:

Write alternative text as if you’re describing the image to a friend.

That’s helpful to me. Scott’s article has a bunch more practical advice and links about this topic from the community. Also good to remember: alt text shows when images are broken and different browsers handle that differently depending on how much of it there is.

]]>
https://frontendmasters.com/blog/on-alt/feed/ 0 2014
You Want border-color: transparent, Not border: none https://frontendmasters.com/blog/you-want-border-color-transparent-not-border-none/ https://frontendmasters.com/blog/you-want-border-color-transparent-not-border-none/#comments Wed, 13 Mar 2024 21:36:37 +0000 https://frontendmasters.com/blog/?p=1120 If you find yourself removing a border from an element that has a border and are tempted to use border: 0 , border: none, or outline: none, I’d urge you to stop for a moment and reconsider. It’s like the old G.K. Chesterton saying about fences:

Do not remove a fence until you know why it was put up in the first place.

In the case of interactive form controls (inputs, textareas, buttons, etc.), those pesky borders were put there because they have an accessibility benefit when using High Contrast Mode, a feature used by 30.6% of low-vision users. Usually when we’re talking about High Contrast Mode in web development we’re specifically referencing Windows High Contrast Mode, but nearly every desktop and mobile operating system has contrast settings, each behaving a little differently. Windows High Contrast flattens all colors to black on white with blue accents (or white on black with yellow accents) and remove all background images from the document.

If we look at some thing more interactive like the comment form on the Boost blog, we can see how the “Post Comment” button loses a bit of punch in High Contrast Mode and might be mistaken as text floating on the page.

To make that button look more like a button in high-contrast mode, we remove the border: 0 and instead use border-color: transparent we get a control that looks like a button for low-vision users as well.

Sighted users will never know the difference! So instead of removing the border, try setting border-color to transparent instead:

border-color: transparent;

The same trick works for overriding outline , set outline-color to transparent:

outline-color: transparent;

Oops! I’ve already nuked my borders

If you’ve already removed borders everywhere and want to support High Contrast Mode (you do) but don’t want to re-architect your entire CSS, you can use the forced-colors media query to detect High Contrast Mode and layer in styling as necessary:

/* Example code, do not use */
@media (forced-colors: active) {
  input, textarea, button {
    border: 1px solid transparent!important;
  }
}

There are other places (e.g. text on images) where the forced-colors media query can get you out of a jam.

Testing forced-colors

To test forced-colors the easiest way is to emulate forced-colors inside Chrome DevTools. There are two easy ways in any version of Chromium browser and an even easier way in Microsoft Edge.

  1. Chrome DevTools > Three Dots Menu > More Tools > Rendering > Emulate CSS media feature forced-colors
  2. Chrome DevTools > Open Command Palette (CMD + Shift + P) > Search for “Emulate CSS forced-colors: active”

Edge DevTools has an easy way to access color emulation from the Device Emulation Screen as well.

  • Edge DevTools > Device Emulation > Open Eye Droppers dropdown in top toolbar > forced-colors: active

One other aspect to consider is that folks using high-contrast mode are often using it with a screen magnifier or 200%~400% browser zoom as well. So be sure to test those situations as well.

High-Contrast Mode keeps you honest about color usage

Testing in High-Contrast Mode is probably something you’re not doing, but that’s okay because you can start today. While it’s worthwhile to test High-Contrast Mode just to support low-vision users, because it aggressively flattens and removes colors it has a knock-on effect of showing places where you’ve over-relied on color to make elements or states distinct, which is another accessibility error in itself (§1.4.1).

High-Contrast Mode may seem like a far out edge case, but it’s not. Lots of folks depend on it. Understanding High-Contrast Mode and its limitations are a step on the pathway to becoming a better front-end developer.

Thanks Melanie Sumner for the inspiration for this post and check out her work on Continuous Accessibility.

]]>
https://frontendmasters.com/blog/you-want-border-color-transparent-not-border-none/feed/ 5 1120