Full Width [alt+shift+f] Shortcuts [alt+shift+k]
Sign Up [alt+shift+s] Log In [alt+shift+l]
36

The UX of HTML

from HTMHell [alt+shift+b] in programming

by Vasilis van Gemert Recently when I gave a coding assignment — an art directed web page about a font — a student asked: does it have to be semantic and shit? The whole class looked up, curious about the answer — please let it be no! I answered that no, it doesn’t have to be semantic and shit, but it does have to be well designed and the user experience should be well considered. Relieved, all of my students agreed. They do care about a good user experience. The joke here is, of course, that a well considered user experience starts with well considered HTML. Somehow my students are allergic to semantics and shit. And they’re not alone. If you look at 99% of all websites in the wild, everybody who worked on them seems to be allergic to semantics and shit. On most websites heading levels are just random numbers, loosely based on font-size. Form fields have no labels. Links and buttons are divs. It’s really pretty bad. So it’s not just my students, the whole industry doesn’t understand semantics and shit. Recently I decided to stop using the word semantics. Instead I talk about the UX of HTML. And all of a sudden my students are not allergic to HTML anymore but really interested. Instead of explaining the meaning of a certain element, I show them what it does. So we look at what happens when you add a label to an input: The input and the label now form a pair. You can now click on the label to interact with a checkbox. The label will be read out loud when you focus on an input with a screenreader. When you hover over a label, the hover state of the connected input is shown. My students love stuff like that. They care about UX. I show them that a span with an onclick-event might seem to be behaving like a link, but that there are many layers of UX missing when you look a bit closer: right-click on this span, and a generic context menu opens up. When on the other hand you right-click on a proper link like this one a specialised context menu opens, with all kinds of...
1st Dec 2023

Stay updated

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

More from HTMHell

#35 a perfectly structured button

button table { margin: 0; } .fa-arrow-left::before {content:"←"} Bad code <button type="button" onclick="window.open('https://example.com/other-page')"> <table> <tbody> <tr> <td> <i class="fa fa-arrow-left" aria-hidden="true"></i> </td> <td align="left">Back</td> </tr> </tbody> </table> </button> Back Issues and how to fix them The HTML isn't valid because the table element isn't allowed as a child of the button element. Based on the content categories listed on MDN, the table element qualifies as flow content and can only be placed inside an element that expects flow content. The button element, on the other hand, expects phrasing content, not flow content. The semantic information of the table doesn't cause any issues because the button's content is presentational See Buttons Role on W3C, Presentational Children. Keep it simple and structure the button element using CSS, such as Flexbox. Instead of using tables to structure the button element, use phrasing content elements, such as span, img, or SVG. Good code <button type="button" onclick="alert('Hello World!')"> Back </button> Resources <button> on MDN <table> on MDN Content categories on MDN Buttons Role on W3C <button> on W3Schools <table> on W3Schools Presentational Children

11th Sep 2025 • 1 votes
A link on a logo in the header, what should the alt-text be?

by Rian Rietveld It's a common pattern to use a logo in the header as a link to the homepage. Fun fact: the alt text of the image inside a link, will be added to the link text. The problem with linking a logo is that it serves 2 purposes: a logo, that tells you which site you are visiting; a link, that leads to the homepage. So add both that info in the alt text. Explain what's on the image and where the link leads to: "Site name logo, to the homepage". Note: Start the alt text with the visible text, then the link will be easier to target for people using voice recognition software. Let's take as example the logo of my home town Leidschendam-Voorburg. In code (simplified): <a href="/"> <img alt="Leidschendam-Voorburg logo, to the homepage" src="logo-lv.svg" /> </a> Generated HTML: VoiceOver in Safari will announce this as: All info is there. There is an advantage of using the alt text instead of an aria-label solution. When the connection is slow, the alt text will show up before the image does and already informs all users of the site name and link destination. It's quite robust. Discussion Do I need the word logo? Isn't that redundant, like the word image or picture? Yes, in this case the fact that this is a logo tells important info. Not only for blind users, but for all screenreader users. If you are visually impaired but not totally blind, you may see the image vaguely. With the addition of the word logo, you also know what the image is. The site name is required, but the logo gives extra context. Isn't this a violation of 2.5.3 Label in Name? No, the visible name is in the alt text, which becomes the accessible name of the link. Adding extra context to the link is common practice. Compare this with the notorious "Read more" link in a card. A common pattern is to use a sr-only CSS class (or equivalent) with additional text: <a href="url">Read more<span class="sr-only"> about cute kitten</span></a> . You see Read more. You hear Read more about cute kitten. In our case: You see the site name and logo; the visual position tells the link destination. You hear the site name, the fact it's a logo and the link destination. The whole visible text should be in the accessible name, but extra information, like the meaning of the image and link destination can be added for context. That way the purpose of the link is explained. Why didn't you use an aria-label? Of course there are other and also valid solutions. By using plain simple HTML I want to honor the first rule of ARIA: If you can use a native HTML element or attribute with the semantics and behavior you require already built in, instead of re-purposing an element and adding an ARIA role, state or property to make it accessible, then do so. Happy Holidays!

1st Dec 2024 • 69 votes
#34 a button is not a link

Bad code <button type="button" onclick="window.open('https://example.com/other-page')">Link target description</button> Issues and how to fix them A button opening a link will be unexpected behavior for screen reader users. No matter how it is styled. Links disguised as buttons won’t show up in the link list of a site in assistive technologies. Use links for navigation to other pages or sections, and buttons for actions performed on the current page or within the application. Good code <a href="https://example.com/other-page">Link target description</a> Resources ` on MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/a) - [`` on MDN](https://developer.mozilla.org/en-US/docs/Web/HTML/Element/button) - [Buttons vs. Links by Eric Eggert](https://yatil.net/blog/buttons-vs-links)

26th Nov 2024 • 65 votes
#33 make me one (input) with everything

The good intentions were there but in the HTML and Accessibility world, less is sometimes more. Bad code <label for="textinput">First name</label> <input type="text" id="textinput" aria-label="First name" placeholder="First name" title="First name"> Issues and how to fix them The aria-label, placeholder, and title attributes all provide the same informaton ("First name"), leading to the screenreader reading the same text multiple times. The aria-label is unnecessary since the input is already correctly labeled by the <label> element. <label> elements should be preferred to aria-label since they are also visible to sighted users. The title attribute is not needed here, as the label and placeholder already convey the necessary information. Using title in this context adds unnecessary complexity. The placeholder text should provide a hint / example to the user what kind of input is expected, it should not act as a label or contain the same content. Good code <label for="textinput">First name</label> <input type="text" id="textinput"> Resources <label> on MDN aria-label on MDN placeholder on MDN title on MDN

27th Aug 2024 • 86 votes

More in programming

AI Homelab Part 4: Lowering the floor for Scout

Helping Scout focus and remember

5 hours ago • 1 votes
The Explorer Pattern for product invention and development.

tl;dr: the Explorer Pattern is one individual or team building a functional implementation that minimizes cross-team and cross-functional impacts as much as humanly possible, and then reconciling the details with other teams after that prototype is completed, accepting that this approach can require very substantial rework to that initial development. Why write this? Imprint previously called this the “Tech-led” or “Engineering-led” development model, but it’s pretty unclear to folks what that means. This writeup provides a more defined term, the “Explorer Pattern”, and explains in more detail how this works. Why do we need to adjust the way we work? Before 2026: Code is expensive, and we design process to minimize implementation and rework In and after 2026: Writing software is extremely cheap, but it’s a wider phenomenon: generating output is effectively-free across many dimensions. Code is nearly free — if we have appropriate constraints. Designs are nearly free — if they follow patterns. Analysis is nearly free — if we’ve instrumented things properly Reworking software is extremely cheap. Historically industry has optimized around avoiding engineering rework because engineering was the highest cost / narrowest constraint. In many companies this was interpreted as writing code being the constraint, which was never true, but many common practices were designed as if that were true (e.g. bringing engineering into problem-solving late “to protect their time”) Working on the system is much more effective than historically if we get automated integration and feedback loops right, e.g. not improving a one-off design but improving the design system. Any place where improving the higher-leverage process is slower than solving the one-off is a bug in our process Explorer Pattern: primary-and-replicas metaphor The easiest metaphor to think about the Explorer Pattern is database replication. Databases like MySQL and PostgreSQL have a primary database, where writes are performed. Every write is verified at that point, and once it’s verified, you know that the writes will flow downstream to various secondary replicas. Those downstream replicas can be delayed but they can’t be wrong because writes are verified upstream. (I’ve resisted the desire to talk about the CAP theorem.) A different model for database design is that used by Dynamo or Cassandra (or MongoDB to a certain extent), where you have a replica set, and have to get an acknowledgement from the majority of the replica set for a write to be strongly consistent. This is a very reliable setup, because it means you can tolerate losing a node, but it also introduces inconsistencies, and on a fixed amount of hardware they tend to be much, much slower than running a primary-secondary setup (or rely on bad performance metrics that don’t fsync to disk to create the illusion of throughput). The Explorer Pattern is the former primary-secondary model, where the vast majority of the work is done by the working individual or team. This makes all work internally consistent because it’s passed through the same small group. It doesn’t, however, mean that the work is perfect. For example, you can always insert data that meets the table’s requirements but is still inherently wrong (e.g. 200 is a valid integer, but it doesn’t mean that my credit limit was supposed to be 200, that depends on the surrounding application logic). Other teams become aware of the changes downstream, not synchronously upfront, and it’s instead the working group’s responsibility to both rationalize approach and create visibility into their work for other teams to engage in a non-blocking fashion. Example: Support for Financial Aggregators A concrete example of this practice at Imprint was rolling out financial aggregator support, e.g. allowing folks to connect to their Imprint powered accounts via Plaid. This has always been something folks want, but it’s particularly important in the realm of agentic commerce where more folks’ agents are analyzing their financial state for them. For this project, one of our engineering leaders (Ron), built the first pass of the feature at a low-burn while understanding the shape of the problem in a private alpha. He chatted through some of the details periodically to keep other teams aware, but it was a bit of a side project. However, once he found the full shape of the problem and had implemented a full solution, we cut the replica-lag across teams down to near-zero, identified and ran through the small number of remaining issues, and shipped it. Like many of our projects this year, it was never officially on a roadmap, and shipped a quality feature that our members have wanted for some time. How to follow the Explorer pattern The rough rules for following the Explorer pattern: Know your goal and sponsor: every initiative ultimately has to have a specific outcome it’s pursuing and a sponsor who’s bankrolling that pursuit. This doesn’t always need to be explicit, especially for smaller projects, but once a project goes beyond ~3 weeks of effort, if you can’t very explicitly identify who the stakeholder is sponsoring your project and they would not enthusiastically agree, then you are likely closer to “lost” than “exploring” Small working group is small: at most 5 people, and preferably smaller. Everyone in the group has to keep the entire project in their head for as long as possible to detect problems and opportunities Small working group is flexible: folks in small working groups have to “find a way to yes” rather than “find a way to no”. Exploring is about uncovering the fundamental shape of a problem rather than pretending we know the fundamental shape Publish progress in a public channel: explorers have to report home with the progress they are making so others are aware. This is both a Linear Project and a Slack channel. Make the narrowest viable changes to what already exists: when we introduce unnecessary changes, we invalidate others’ mental models about how the world works. When we haven’t made those changes with care, we’re not only invalidating others’ mental model, we are creating the expectation that we’ve done it very intentionally for a good reason, which has a chilling effect on others improving them later, which is very expensive, whereas the Explorer pattern depends on being as inexpensive as possible Exercise good judgment to identify reasonable hypotheses: discard bad ideas immediately, and then filter the rest by trying to implement them as quickly as possible. Once you see the shape of the implementation, you can figure out which of the remainders are interesting Hold assumptions constant to avoid getting stuck: the only way to navigate complex ambiguous problems is to hold things constant, even when you know they are imperfect. For example, to do headcount planning we have to know our revenue, to know our revenue we have to forecast it, to forecast it we have to know the day that partners will go live next year. We don’t truly know any of those things, so just anchoring on a plausible guess to unblock us is much more valuable than trying to get them accurate. A little prework is useful, but a lot is just artificial precision that’s a distraction from progress Hold space for being totally wrong: when we move fast, with low information, we always find the way out, but often it’s not the way out we anticipated when we got started. Being open to throwing it all away, and starting a second, third, fourth time Ship all the way to production behind a feature flag: features and products move fast when we get the pieces working every step from frontend to backend to data pulls. This is the first step of exploration. Just make sure it’s behind a feature flag that’s only enabled for internal folks!

8 hours ago • 1 votes
Value Creation vs Job Preservation

Comparing two different ways of work and working environments.

18 hours ago • 1 votes
Making a dumb TV just smart enough

I own an old, cheap TV. It has no Internet connection, no fancy smart features that make you want to install a Pi-hole, and no ask-me-again-later updates. However, it is connected to my own desktop computer through an HDMI cable, so I can watch movies and TV series from the couch. Setting it up used […] The post Making a dumb TV just smart enough appeared first on Quentin Santos.

2 days ago • 1 votes
Bikepacking across Kyushu

Five days and 540km on a bike across Kyushu, without a laptop. Notes on the peace of riding all day, convenience store dinners, and Japan's emptying countryside.

4 days ago • 1 votes
📚 BoredReading

You seem to be enjoying this.

Join free to unlock everything.

Create free account

Already have an account? Sign in