惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
WordPress大学
WordPress大学
云风的 BLOG
云风的 BLOG
Stack Overflow Blog
Stack Overflow Blog
MongoDB | Blog
MongoDB | Blog
腾讯CDC
V
V2EX
Martin Fowler
Martin Fowler
A
About on SuperTechFans
大猫的无限游戏
大猫的无限游戏
Blog — PlanetScale
Blog — PlanetScale
Cyber Security Advisories - MS-ISAC
Cyber Security Advisories - MS-ISAC
酷 壳 – CoolShell
酷 壳 – CoolShell
C
Check Point Blog
博客园 - 【当耐特】
Cisco Talos Blog
Cisco Talos Blog
The Hacker News
The Hacker News
K
Kaspersky official blog
Security Latest
Security Latest
H
Help Net Security
博客园_首页
美团技术团队
Spread Privacy
Spread Privacy
博客园 - 司徒正美
Hugging Face - Blog
Hugging Face - Blog
S
SegmentFault 最新的问题
G
Google Developers Blog
NISL@THU
NISL@THU
爱范儿
爱范儿
I
Intezer
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
阮一峰的网络日志
阮一峰的网络日志
N
News and Events Feed by Topic
P
Privacy International News Feed
Application and Cybersecurity Blog
Application and Cybersecurity Blog
S
Security @ Cisco Blogs
Schneier on Security
Schneier on Security
雷峰网
雷峰网
人人都是产品经理
人人都是产品经理
V
Vulnerabilities – Threatpost
W
WeLiveSecurity
P
Palo Alto Networks Blog
G
GRAHAM CLULEY
Hacker News: Ask HN
Hacker News: Ask HN
I
InfoQ
The Cloudflare Blog
F
Full Disclosure
SecWiki News
SecWiki News
宝玉的分享
宝玉的分享
N
Netflix TechBlog - Medium

Matthias Ott

Hello Again, World This, Still Not for Everyone The Shape of Friction WeissKlang L1 – Punching Above Its Weight Continvoucly Morged Value Webspace Invaders To Affinity and Beyond The Mystery of Storytelling Amateurs! Echoes of Connection Linear() Is Not (That) Linear View Transitions: The Smooth Parts Adding AVIF and WebP Support to My Craft CMS Site Challenge Acoustic Room Treatment and Building Sound Panels, Part 1: Planning Play On Overshoot Listening Closely Compressed Fluid Typography The Lifeblood of the Web What Could Go Wrong? That’s My Rank Making Space CSS :is() :where() the Magic Happens Visual Regression Testing for External URLs With Playwright Jane Goodall’s Famous Last Words European Tech Alternatives 🇪🇺 Independent Type Foundry Advent Calendar – Day 24: NaN Independent Type Foundry Advent Calendar – Day 23: Typotheque Independent Type Foundry Advent Calendar – Day 22: 205TF Independent Type Foundry Advent Calendar – Day 21: HvD Fonts Independent Type Foundry Advent Calendar – Day 20: Frere-Jones Type Independent Type Foundry Advent Calendar – Day 19: Fontwerk Independent Type Foundry Advent Calendar – Day 18: Vectro Independent Type Foundry Advent Calendar – Day 17: Studio René Bieder Independent Type Foundry Advent Calendar – Day 16: R-Typography Independent Type Foundry Advent Calendar – Day 15: David Jonathan Ross Independent Type Foundry Advent Calendar – Day 14: Interval Type Independent Type Foundry Advent Calendar – Day 13: Newglyph Independent Type Foundry Advent Calendar – Day 12: Swiss Typefaces Independent Type Foundry Advent Calendar – Day 11: Sharp Type Independent Type Foundry Advent Calendar – Day 10: Colophon Foundry Independent Type Foundry Advent Calendar – Day 9: Commercial Type Independent Type Foundry Advent Calendar – Day 8: Letters from Sweden Independent Type Foundry Advent Calendar – Day 7: Lineto Independent Type Foundry Advent Calendar – Day 6: Ohno Type Company Independent Type Foundry Advent Calendar – Day 5: Milieu Grotesque Independent Type Foundry Advent Calendar – Day 4: TypeMates Independent Type Foundry Advent Calendar – Day 3: Klim Type Foundry Independent Type Foundry Advent Calendar – Day 2: Dinamo Independent Type Foundry Advent Calendar – Day 1: Grilli Type The Independent Type Foundry Advent Calendar 2022 A Conversation With ChatGPT ChatGPT, please explain websites in the words of William Shakespeare Transient Frameworks Leaving Twitter Behind Converting Your Twitter Archive to Markdown The Wrong Question It Wasn’t Written Syndicating Posts from Your Personal Website to Twitter and Mastodon Suspension None of Your Business Shitty Code Prototypes Doing Our Part Patch That Package Brain Dump Generating Accessibility Test Results for a Whole Website With Evaluatory The CSS Cascade, a Deep Dive Updates About Updates How to Delete Your Commit History in Git Unblocking Your Writing Blocks, Part 2: I’m Not an Expert nor a “Thought Leader” Connections No Wrong Notes Better Options Design Debt Finite and Infinite Games Don’t Assume, Validate. Necessity Is the Ultimate Teacher One Egg Go Deep There Is No Secret Code Balancing Risk Blue Eyes, Brown Eyes The Shortcut Boomerang My RSS Feed Collection of Personal Websites Frequency The Illusion of Control The Decisions Journey Write It Down Nownownow Into the Personal-Website-Verse Considering the Opposite What is it for? Unlimited Bowling. Never done. We Are Team Internet. We Need to Save #NetNeutrality. Progressive Search Data loss (also) by JavaScript Books I Will Definitely Maybe Read in 2017 Starting to Write Notes
The HTML Output Element
Matthias Ott · 2025-10-15 · via Matthias Ott

One of the most amazing things about working on the Web is that you can have years of experience under your belt and there are still things you don’t know. Often, people associate this with a more quickly-moving language like JavaScript, but it equally hold true for HTML. Although, on the first sight, HTML seems like a very “easy” markup language, it can still be incredibly hard to write solid, semantic HTML – even for seasoned developers. But then, there are even moments where you are just surprised because you hear about a little detail you never heard before or completely forgot about. And sometimes, that little detail is a whole HTML element.

Earlier this month, Den Odell just wrote a fantastic article about such an element: the HTML <output> element. The <output> element was added to HTML in 2009, in W3C’s HTML 5 Working Draft 12 and it is a form element. Its intent is clearly stated in the HTML Living Standard: The output element represents the result of a calculation performed by the application, or the result of a user action. So it is primarily intended for the output of, let’s say, a little calculator:


  First number:
  

  Second number:
  
  
	Sum:
	0
  

Looking at the code above, there are a few details you might notice: first of all, the <output> element can be used very much like any other form element. It works inside a <form> but you can also use it outside of a form and associate the output with the form via a form attribute. I always go to mdn and have a quick look at what attributes are supported. You can also see that the output element has a for attribute, much like the <input>s. But the for attribute of the <output> actually supports a space-separated list of other elements’ ids, which are indicating which elements contributed input values to the calculation – or otherwise affected the result. Lastly, the <output> can have a name, of course.

Practical Use Cases #

Now, not everyone of us is building basic calculators all the time. So what are practical use cases for this element?

One of the most useful things is that the element is mapped to role="status" in the accessibility tree. For better cross-browser compatibility, it might make sense to add an additional role="status“, for now. So the <output> element will announce its value when it changes, for example via a screen reader, and the entire content is spoken without interrupting the user.

This makes the <output> very flexible and useful. And it might be reason enough to think about how you could use it in one of your next projects. Den, for example, mentions using it for displaying user-friendly versions of range slider values. This is actually something I could consider for the knob components of my little style mixer above, as well. 🤔 He also suggests using it for immediate form validation feedback, like for password strength indicators, character counts, or real-time validation messages. And, of course, it can be useful to output any kind of server-calculated output, even fetched values coming from APIs or the total of a shopping cart. You could also use it to output the adjusted scaled quantities in recipes, show changed interest rates in a mortgage calculator, or to announce the adjusted dates or duration of stay in a booking form. So basically, <output> is super useful when user interaction results in a live calculation or a value update, and you want screen readers to announce it automatically without using extra ARIA hacks.

But as Scott O'Hara notes, the latest version of the HTML standard also isn’t super strict when it comes to the result inside of an output. It can be the result of a math calculation inside of a form, yes. But you could also interpret it a bit more broadly, as everything that makes sense to announce as the “result of a user action” – as long as it is Phrasing Content, so you can’t use headings, lists, or sectioning elements like article, section, div, and so on. But you are not confined to outputting numbers only. Scott, for instance, explored using <output> for toast components, those little, temporary notifications appearing on the screen somewhere. But if you think about it: it could also be used for outputting the number of matched items in interactive filters. So when a user selects a certain set of filters, the <output> shows “42 results” or “No items found” dynamically. It could be used to display the results of interactions on a dashboard (“CPU usage 75%”, “120 visits per month”). It could be used to announce the score or right answers in quizzes or games. Or, you could use it to provide feedback on any interactive action, for example toggling a switch in a settings section (“Notifications enabled!”) or completing a task (“1893 todos remaining for today.”).

If you think about it: the element shines in any situation where user interaction produces a live, dynamic result. It provides semantic meaning and built-in accessibility, offering a lightweight, standards-compliant way to make interfaces both more dynamic and screen-reader friendly. In that regard, it might really be one of HTML's most under-appreciated gems.

Time to play and experiment with it, I guess…

This is post 14 of Blogtober 2025.

~

14 Webmentions

2 Reposts

12 Likes

ⓘ Webmentions are a way to notify other websites when you link to them, and to receive notifications when others link to you. Learn more about Webmentions.