As you know, we love unusual tech at Lingo.dev. So when in my last essay, David commented he was surprised to not see "dialog" HTML element, it hit me - wait, but there's so many HTML5 elements that we don't even know about!
In our rush to embrace sophisticated frameworks and libraries, we've overlooked some of the most elegant solutions built right into HTML5. There's something beautiful about achieving with a single tag what might otherwise take dozens of lines of JavaScript.
The best code is often the code you don't have to write. How many times have you reached for a JavaScript library to create a modal window? Or written complex CSS for collapsible sections? What if I told you that HTML5 already has native elements for these exact purposes?
These aren't just any HTML elements - they're the ones that make you go "Wait, we could do that all along?" Let's explore eight surprisingly powerful HTML elements you probably aren't using - but absolutely should be.
1. The <dialog> Element: Native Modal Windows
Picture this: you're starting a new project and need to add a modal dialog. Your first instinct? Reach for React, grab a UI library, or write a bunch of JavaScript. I get it - I've done the same thing countless times.
But HTML5 has a built-in element specifically designed for this purpose:
You still need a bit of JavaScript to handle the open/close actions:
The browser handles focus management, backdrop rendering, and keyboard accessibility. Most developers I talk to have never used this element, despite it being supported in all major browsers since around 2022.
You can style it however you want:
I've been using this in production for a couple of years now. The main gotcha is iOS Safari support, which was spotty until 2023, but it's solid now. For complex modals with lots of interactive elements, you might still want a dedicated library, but for most use cases, the native element works perfectly.
2. The <details> and <summary> Elements: Native Accordions
Accordions are everywhere on the web - FAQs, product details, settings panels. Most developers reach for a JavaScript solution, but HTML5 has native elements for this:
That's all you need. The browser handles the toggle functionality, accessibility attributes, and keyboard navigation.
You can style it to match your design system:
These elements are particularly useful for nested navigation. I used them recently in a documentation site where we needed three levels of collapsible navigation:
The main limitation is animation - if you need smooth animations when opening/closing, you'll need to add JavaScript. But for many use cases, the default behavior is perfectly fine.
3. The <datalist> Element: Native Autocomplete
Autocomplete functionality is a staple of modern web forms. Most developers reach for a third-party solution, but HTML5 has a built-in element for this:
This gives you a text input that shows suggestions as you type, with the ability to select from the list or enter custom text.
One interesting use case is creating a color picker with named colors:
The user can either type a color name or a hex code. Add a bit of JavaScript to show a preview:
The main limitation of <datalist> is styling - you can't easily customize the appearance of the dropdown options. If you need custom styling for the suggestions, you might still need a JavaScript solution. But for many use cases, the native element is perfectly adequate.
4. The <meter> Element: Semantic Measurement Display
When displaying values within a known range, most developers use a div with a background color. But HTML5 has a dedicated element for this:
The browser styles it based on the thresholds you set. If the value is in the "low" range, it might show as yellow. If it's in the "high" range, it might show as orange. And if it's near the "optimum" value, it shows as green.
This is particularly useful for dashboards:
The optimum attribute indicates whether higher or lower values are better, which affects the color.
Browser support is good, but styling options are limited. If you need a highly customized appearance, you might still need a custom solution. But for dashboards and monitoring UIs, the native element works well and communicates semantic meaning to screen readers.
5. The <output> Element: Dynamic Calculation Results
When building calculators or interactive forms, most developers use a div to show the result. But HTML5 has a dedicated element for this:
The for attribute creates an explicit relationship between the inputs and the output, which helps screen readers understand that the output is a result of those specific inputs.
I used this in a side-project last year for a mortgage calculator:
The main advantage is semantic meaning - screen readers can announce that the value is a calculation result. It's also a form element, so it can be included in form submissions if needed.
6. The <mark> Element: Semantic Highlighting
When highlighting text, most developers use a span with a background color. But HTML5 has a dedicated element for this:
By default, browsers style it with a yellow background, but you can customize it:
This is particularly useful for search results:
The advantage is semantic meaning - screen readers can announce that text is highlighted, giving users a better understanding of why certain text stands out.
I've found this especially useful in documentation sites and knowledge bases, where highlighting search terms helps users quickly find what they're looking for.
7. The <time> Element: Semantic Dates and Times
Most developers display dates and times using regular text elements, but HTML5 has a dedicated element for this:
The datetime attribute allows you to specify the date in a standardized format (ISO 8601) that machines can understand, while displaying a human-friendly format to users.
This is useful for search engines, which can extract the exact date, and for browsers or extensions that might want to offer features like adding events to calendars.
You can use it for various date and time formats:
One practical application is for relative times:
With JavaScript, you can update these periodically:
This element is particularly valuable for blogs, news sites, and social media platforms, where accurate date and time information is important.
8. The <figure> and <figcaption> Elements: Semantic Image Captions
Most developers implement image captions with divs and paragraphs, but HTML5 has dedicated elements for this:
The <figure> element isn't just for images - it can be used for any content that is referenced as a single unit:
These elements are particularly useful for content management systems and blogs, where editors need to add captions to images and other media.
A simple CSS setup can create a nice-looking gallery:
The main advantage is semantic meaning - screen readers can announce that the text is a caption for the associated content, improving accessibility.
Conclusion?
Embrace the Power of Native HTML.
We've explored eight HTML5 elements that offer elegant, built-in solutions to common web development challenges:
- <dialog> for native modal windows
- <details> and <summary> for collapsible content
- <datalist> for native autocomplete
- <meter> for semantic measurement display
- <output> for dynamic calculation results
- <mark> for semantic highlighting
- <time> for semantic dates and times
- <figure> and <figcaption> for semantic image captions
These elements reduce dependency on JavaScript, improve accessibility, and make your HTML more semantic and meaningful.
They're not perfect for every use case - building Lingo.dev oftentimes requires more customization or browser support than they can provide. But they're worth considering before reaching for a third-party solution.
What other HTML elements have you found useful in your projects? Let me know in the comments!
Useful links:
- Lingo.dev on Twitter/X - dev + fun;
- GitHub repo - give it a star :)
- Discord - users told we need a Discord, so we created one 👀