Full Width [alt+shift+f] Shortcuts [alt+shift+k]
Sign Up [alt+shift+s] Log In [alt+shift+l]
SplitDuck.com Use A/B testing to increase revenue
1

HTML esoterica - en-GB vs en_GB

from HTMHell Advent Calendar 2025 [alt+shift+b] in programming

by Terence Eden Here's a fun little historic mystery for HTML nerds. Most websites report the language they're written in using the lang attribute. <html lang="en-GB"> But on the <meta> element, it's common to see: <meta content="en_GB" property="og:locale"> Why does that use an underscore rather than a hyphen? What is a language anyway? Here's how the lang attribute works: 3.2.6.2 The lang and xml:lang attributes OK, so what is a valid BCP 47 language tag? Language tags permit only the characters A-Z, a-z, 0-9, and HYPHEN-MINUS (%x2D). 6. Character Set Consideration For example, en is English. en-GB is British English and en-CA is Canadian English. The two parts are separated by a hyphen. Where else is language specificity useful? That's not the only way language tags can appear in HTML. If you want your web page to show a little preview when you share it - perhaps on social media or a messaging app - you can use Open Graph Protocol. og:locale - The locale these tags are marked up in. Of the format language_TERRITORY. Default is en_US. Optional Metadata - Open Graph Protocol (Hurrah for American hegemony!) Here's the example it gives: <meta property="og:description" content="Sean Connery found fame and fortune as the suave, sophisticated British agent, James Bond." /> <meta property="og:locale" content="en_GB" /> That says the locale of the tags, not the page, is British English. So you could have a page in the Japanese language but OGP tags written in Cherokee. Now I have two questions. Why doesn't this use the lang attribute? Why does this use an underscore rather than a hyphen? For example, this is valid HTML: <meta property="og:site_name" content="Les Misérables" lang="fr"> <meta property="og:description" content="A book by Victor Hugo." lang="en-GB"> That says the site's name is in French but the description is in English. That will parse perfectly. What's going on with OGP? As I've ranted before, development of Open Graph...
yesterday

Stay updated

Get a weekly newsletter with the top 5 articles worth reading every week.

More from HTMHell Advent Calendar 2025

Top layer troubles: popover vs. dialog

by Stephanie Eckles Have you ever tried to set z-index: 9999 to solve element layering issues? If so, you’ve been fighting a fundamental CSS concept of stacking contexts. The stacking context defines the order things are placed in the third dimension, or the “z” axis. Think of the z-axis as layers of DOM elements between the root of the stacking context within the viewport, and you, the user, looking through the browser viewport. An element can only be re-layered within the same stacking context. While z-index is the tool to do it, the failure happens due to a change in stacking contexts. This can happen in a few ways, such as a fixed or sticky positioned element, or combining position absolute or relative along with a z-index, among others as listed on MDN. A modern web feature is the “top layer,” which is guaranteed to be the top-most layer above any other stacking context. It spans the entire viewport, although elements existing in the top layer may have smaller visible dimensions. Promoting an element to the top layer breaks it free of any stacking context it may otherwise exist within. Although the top layer directly addresses a CSS-related issue, there is currently no property available to promote an element to the top layer. Instead, certain elements and conditions gain access to the top layer, including native dialogs via showModal() and elements designated as popovers. The Popover API is a newly available HTML feature that enables you to create declarative non-modal overlay elements. The ability to escape any stacking context by gaining top layer access is usually a desirable feature of choosing the Popover API. However, there’s a sneaky potential conflict to be aware of before hastily opting for this native upgrade. Setting the scene Picture this, the web, 2025: your web app includes a notification service that displays via “toast” messages. You know, those pop-up messages that usually appear in a corner or other location with a lower likelihood of obstructing any other UI. Usually these toast notifications are for real-time alerts of things like a successful save, or errors such as a failed form submit. They are sometimes time limited, or include a dismissal mechanism like a close button. Sometimes they include an additional action, such as to “Retry” for re-submitting a failed workflow. Since your app is hip to the times, you’ve recently decided to upgrade the toasts to use the Popover API. This enables you to place the toast component anywhere in the app structure, and not have to hack around stacking context issues. After all, toasts absolutely must appear over everything else, so the top layer access afforded via popovers makes sense! You ship the enhancement, proud of your work. Later that week, you get an urgent bug report. Not just any bug report, but an accessibility violation. Dialog vs. popover Because your app is hip, you also had previously upgraded to native HTML dialogs. That was an incredible upgrade because you got to reduce a JavaScript dependency in favor of a native web feature. That’s another reason you were excited to enhance your toasts to use popover as well. So, what was the bug? A keyboard user was in a workflow that involved a dialog. While the dialog was open, a background process caused a toast notification to trigger. The notification was for an error, and required user interaction. The bug occurred when the keyboard user tried to tab into the toast, which they were able to visually see above the dialog backdrop. Unfortunately, their focus never successfully entered the toast, and instead seemed to skip over it, jumping unexpectedly to the browser UI instead. You can experience this error yourself in this CodePen, where by using the tab key, you too will never be able to access the toast. You can also try it out using a screen reader, and notice that the virtual cursor is also unable to get into the toast. See the Pen conflicting by Stephanie Eckles (@5t3ph) on CodePen. If you are able to click on the popover, you may think it’s at least working with that method. But shortly we’ll learn that thing aren’t always as they seem. Why the toast popover is unreachable While top layer allows beating out standard stacking contexts, items that exist within the top layer are still affected by layering order. The most recently added top layer item appears over previous top layer items. This is why the toast was visually appearing over the dialog’s backdrop. So if the popover is visually available, why is it unreachable via keyboard or a screen reader’s virtual cursor? The reason has to do with the popover competing with a modal dialog. When the native HTML dialog is launched via showModal(), the page outside of the dialog becomes inert. The state of inert is a necessary accessibility behavior, which results in isolating the dialog contents, and prevents both tab and virtual cursor access to the background page. The bug is due to the toast popover being part of the background page’s DOM. This means it has been made inert due to being outside of the DOM boundary of the dialog. But, due to top layer order, since it was created after the dialog was opened, it is confusingly sitting visually over the dialog. If you thought clicking the popover was working, it’s in fact not, even though the popover does dismiss. What is really happening is that you are triggering the light dismiss behavior of the popover. This means it is closing because you are technically clicking outside of it’s boundaries, since the dialog is capturing the click instead. So, while the popover was dismissed, the “Retry” button was not actually clicked, meaning any associated event listener was not triggered. Even if you created an automated test to check your alert functionality specifically when a dialog was open, the automated test may have had a false positive because it triggered a programmatic click on the toast button. That pseudo click was falsely getting around the issue created from the dialog causing the page to be inert. Regaining popover access The solve is two-fold: move the popover physically inside the DOM of the dialog ensure use of popover="manual" to prevent clicks inside the dialog from prematurely triggering light dismiss on the popover Once we’ve done both of those things, the popover is now both visually available and fully interactive via any method. See the Pen conflicting by Stephanie Eckles (@5t3ph) on CodePen. Learnings and additional considerations What we’ve learned is that you will need to work out a mechanism to launch popovers from within dialogs if your website or app has the possibility of both displaying at once, and they have independent timelines. Alternatively, you could opt to suppress background page popovers until the dialog closes. This may not be ideal if notifications require timely interaction, or if the dialog contents have the potential to trigger a toast. Another issue you may need to handle for, besides visibility and interactivity, is if the popover needs to outlive the dialog. As in, it needs to remain open - perhaps to keep waiting for the user to take action - once the dialog is closed. While I am a huge proponent of using native platform features, and I think popover in particular is an incredible feature, sometimes conflict points can’t be entirely avoided. In fact, you may have already had to contend with a similar conflict against the inert behavior of a modal dialog. So, this article may mostly be a warning to not entirely rip out your previous custom popover architecture if you have this potential issue of displaying background popovers and modal dialogs simultaneously. If this is an issue that currently, or may in the future affect your work, keep an eye on this HTML issue where solutions are being discussed.

1st Dec 2025 • 1 votes

More in programming

How to tokenmaxx correctly

Parallelize discovery and execution, but serialize judgement.

15 hours ago • 1 votes
You really shouldn't vibe code a newsletter app

Sending email is easy. Making sure good emails land where they should is not.

16 hours ago • 2 votes
User preferences, exclusion, and understanding what you’re deciding

This is an article about user preferences. It is also about the larger framework of decisions designers sit inside of when employing them, and the outcomes that they can create. I wrote this article because the power dynamics and downstream effects surrounding user preferences is something multiple accessibility practitioners I know are aware of. My, and their thinking about these dynamics and end results is worth being aware of. Discussing the concerns that surround how user preferences are introduced can also be, ahem, counterproductive to healthy working relationships when brought up in the moment. So, I am writing it out here instead for people to read and digest at their own pace. What are user preferences? For the uninitiated, user preferences are different modes you can set in your operating system to help you use a digital device. Examples include, but are not limited to: Dark mode, Reduced motion, Reduced transparency, Increased contrast, Forced colors, etc. All of these user preferences enable, improve, and enhance someone’s ability to operate digital experiences. Consequently, they can be considered assistive technology. However, someone enabling user preferences isn’t a given. This is worth emphasizing because the existence of user preferences can also serve as an excuse during the product or feature design process. Just because a user preference exists does not mean someone who could benefit from it is using it There are a whole host of reasons as to why this is. Here’s a few: Low digital literacy means someone does not know how to navigate to their operating system preferences, or that said preferences even exist in the first place. Someone might not know they have a disability, and consequently will not seek out a related user preference. Related, internalized ableism means someone does not think the accessibility section of operating system preferences applies to them. A device might be locked down by someone’s employer, with large swaths of functionality set to be restricted. A device may be shared due to economic circumstance, where individuals in disadvantaged communities share a device or access one from locations like a public library or shelter. A device’s operating system may not be updated to a version where support for the user preference was added. etc. An example of where the existence of user preferences gets abused A common example I’ve had to contend with is color contrast. A common response to contrast issues being brought up is to propose setting a high contrast theme that kicks in if someone has the increased contrast user preference enabled. This is done in an attempt to avoid the minimum contrast ratio demanded by the Web Content Accessibility Guidelines (WCAG) requires. More abstractly, this response enables a designer avoiding deeper inquiry into their sense of aesthetics. This in turn avoids questioning how personal opinions around taste impact the audiences they ultimately serve. The reason why a low-contrast-experience-as-default is a non-starter is obvious if you understand what the spirit of WCAG is getting at. It is also why a website offering an increased contrast theme switcher using color values in the UI that are too low contrast is also not a viable approach. That reason is content in its default state may be unable to be perceived. And if it cannot be seen, it cannot be read or used. It’s as simple as that. These examples, and other related ones compels a change of mindset. Accessible by default, opt-out by choice Disability intersecting with digital experiences creates a range of outcomes from mild annoyance, to hard barriers, and even direct harm. This intersection compels an approach that means proactively accommodating the widest swath of unknown people with unknown preferences, capabilities, devices, and circumstances as the default. Another example: I know someone who had a seizure because of a full-screen animation a website played. The animation implementation itself honored a reduced motion user query. However, the person did not know that the reduced motion user preference existed and consequently did not enable it. Are we to blame them? People who work in the digital accessibility space are already aware of this accessible-by-default approach. It is why the WCAG is phrased the way it is. As a positive example of this, this is why GitHub underlines its links by default now, but also enables you to switch link underlines off. However, this accessible by default, opt-out by choice mindset isn’t always present for designers. This brings about three tough, yet vital questions that need to be asked, and this article’s format is a safer way to provide the larger surrounding context of why they need to be asked. Who do you want to exclude? Asking this question in a structured way, in good faith at the beginning of a project is a great way to help build awareness and consensus. This question is what an in-house accessibility practitioner is likely thinking when they hear a proposal to present an accessible alternative hidden away under a user query. I will also note that asking it directly at later stages of the design process isn’t feasible in most professional environments. What are you deciding? Here’s another question your peer really can’t ask in the moment. Accessibility practitioners tend to think of their work as an output coming from an ethical or harm prevention way of thinking. Unfortunately, this kind of thinking isn’t always the most compelling or effective strategy in contemporary business culture. Because of this, there are three more pragmatic lenses we can view design choices through: Usability Constraining the methods of operation of a digital experience to work in only the ways you personally use something is a decision. And that decision limits how usable the experience is to others. In opposition to this artificially-applied constraint, conferring the ability for someone to efficiently navigate and take action on a digital experience is one of the main jobs you have as a designer. This applies to both the public and private sectors. Profitability Another main job of designers working in the private sector is to enable the creation and continuation of profit, and profitability is impacted by usability. To that point, poor usability leads to less profitability if your product is actively competing in the market. Consequently, choosing to limit usability also chooses to limit profitability. Here, in the context of lucrative SaaS contracts I would like to call out both the tyranny of the majority and also the correlations between age, disability, and decision-making power. Law At the end of the day it is a court—and not you—that decides whether or not a barrier is present for a disabled person using a service. Here, know two things: There is also plenty of precedent in the private sector in the United States to draw from, and also WCAG helps inform how to avoid many forms of barriers in digital experiences. I am not going to say that you are choosing to break the law when you lead with an inaccessible default. However, I will say that a jury might. Where do you want to place the burden? Learning about and enabling user preferences takes effort. Forcing disabled people to fiddle with obscure operating system preferences places the burden on them to get basic accessibility accommodation. Also know It is a fallacy to assume the presence of an active user query means someone is accommodating their disability. For example, I use a reduced motion media query on my laptop and phone because I am impatient and want OS transition effects to get out of the way and take as little time as possible. As alluded to earlier with my comments on age and decision-making power, it is also a fallacy to assume the presence of disability or use of a user query means a lack of ability, competency, or value. This mindset is largely due to how pervasive ableism—and how it shapes ideas about disability—is in our culture. Try sitting with this To quote my friend Soren: User preference settings or accessibility settings cannot replace our responsibility to design and build accessible apps and websites. The ideas and viewpoints shared in this post article are something you may not be exposed to due to both a historic lack of disability theory in design education, and also a lack of organizational prioritization of accessibility in design practice. Your ideas and values may be challenged by this, as well as your aesthetic sensibilities. Spend some time reflecting on why you feel this friction and unease, as well as the power and responsibility you wield as someone who creates digital experiences.

16 hours ago • 1 votes
NSRS georeferencing

The US is updating its primary spatial reference system, replacing NAD 83 with NATRF 2022 and other systems.

yesterday • 1 votes
Creating Beveled Corners with “corner-shape”

The new “corner-shape” CSS property is incredibly useful, but if we really want to get the most out of it, we need to use some surprisingly-sophisticated tricks. In this post, I’ll share how I’ve used this new property to create a retro-sci-fi aesthetic with diagonal corners everywhere. 📐

yesterday • 1 votes
📚 BoredReading

You seem to be enjoying this.

Join free to unlock everything.

Create free account

Already have an account? Sign in