DEV Community

Cover image for Top 5 HTML Features You’re Not Using (But Should Be)
Safdar Ali
Safdar Ali

Posted on

Top 5 HTML Features You’re Not Using (But Should Be)

HTML is the foundation of web development. While most developers are familiar with the basic elements like

<div>, <p>, and <img>,
Enter fullscreen mode Exit fullscreen mode

HTML offers a plethora of advanced features that can significantly enhance the functionality and efficiency of your web pages. Unfortunately, many of these powerful features remain underutilized. In this article, we’ll explore the top 5 HTML features you’re probably not using but definitely should be.

Top 5 HTML Features- Safdar Ali

1. Dialog Element

The element is a native HTML element that allows you to create modal dialogs without relying on JavaScript libraries. It can be used for alerts, confirmation dialogs, or custom pop-ups, offering a more semantic approach to modals.

Here’s an example:

<dialog id="myDialog">
    <p>This is a modal dialog</p>
    <button onclick="document.getElementById('myDialog').close()">Close</button>
</dialog>

<button onclick="document.getElementById('myDialog').showModal()">Open Dialog</button>
Enter fullscreen mode Exit fullscreen mode

With the element, you can easily control the opening and closing of modals, and it’s also accessible and easy to style.

2. Picture Element

The element is essential for creating responsive images that adapt to different screen sizes and resolutions. It allows you to specify multiple image sources and choose the best one based on the device’s capabilities.

Here’s an example:

<picture>
    <source media="(min-width: 800px)" srcset="large.jpg">
    <source media="(min-width: 400px)" srcset="medium.jpg">
    <img src="small.jpg" alt="Responsive Image">
</picture>
Enter fullscreen mode Exit fullscreen mode

The element improves load times and enhances the user experience by serving the most appropriate image for each device.

3. Output Element

The element is designed to display the result of a calculation or user interaction. It’s especially useful in forms where you want to show real-time feedback based on user input.

Here’s an example:

<form oninput="result.value=parseInt(a.value)+parseInt(b.value)">
    <input type="number" id="a" value="0"> +
    <input type="number" id="b" value="0">
    = <output name="result" for="a b">0</output>
</form>
Enter fullscreen mode Exit fullscreen mode

This element is a simple way to create interactive and dynamic forms without requiring extensive JavaScript.

4. Data Element

The element associates a machine-readable value with its human-readable counterpart. It’s particularly useful for adding semantic meaning to your content, like linking a product ID to its display name.

Here’s an example:

<p>Price: <data value="49.99">$49.99</data></p>
Enter fullscreen mode Exit fullscreen mode

Search engines and web crawlers can use this additional information to understand your content better, which could improve your SEO performance.

5. Details and Summary Elements

The and elements work together to create expandable content sections. This feature is perfect for creating FAQs, collapsible content, or any scenario where you want to hide and reveal information.

Here’s an example:

<details>
    <summary>More Information</summary>
    <p>This is the hidden content that will be revealed when you click on "More Information".</p>
</details>
Enter fullscreen mode Exit fullscreen mode

These elements are easy to implement and provide a better user experience by reducing the amount of information displayed at once, keeping your pages clean and readable.

Conclusion

HTML has evolved significantly, and these features demonstrate just how powerful and flexible it has become. By incorporating these lesser-known elements into your projects, you can create more responsive, dynamic, and user-friendly web pages with less reliance on external libraries and frameworks. So, give these HTML features a try—you might be surprised at how much they can enhance your development process.

That's all for today.

And also, share your favourite web dev resources to help the beginners here!

Connect with me:@ LinkedIn and checkout my Portfolio.

Explore my YouTube Channel! If you find it useful.

Please give my GitHub Projects a star ⭐️

Thanks for 29512! 🤗

Top comments (48)

Collapse
 
tomasdevs profile image
Tomas Stveracek

Great article! Another cool feature to explore is the <template> tag. It lets you define reusable HTML that you can add to the DOM later with JavaScript, without rendering it right away. Perfect for dynamic content.

Collapse
 
safdarali profile image
Safdar Ali

If you found my content helpful or interesting, and you’d like to show your appreciation, why not buy me a coffee? It’s a small gesture that goes a long way in helping me keep creating more content for you.

Just click the button below to support:

Buy Me A Coffee

Collapse
 
darkwiiplayer profile image
𒎏Wii 🏳️‍⚧️ • Edited

Dialogue elements are cool in theory, but I've always found them a bit inconvenient to style in practice. There's no way for the CSS to query how they're being shown, so without weird hacks, getting them to play nicely with both show() and showModal() is a bit of a pain.

EDIT: After a bit more digging, I figured out that :modal is a thing now, so that should (hopefully) make using dialogues a lot more doable than I remember. Now all it's missing is an open event.

Collapse
 
jonrandy profile image
Jon Randy 🎖️

Just use a MutationObserver on the open attribute?

Collapse
 
darkwiiplayer profile image
𒎏Wii 🏳️‍⚧️

That should just be a built-in feature though. It's not like we couldn't already build your own pop-over dialogues before <dialog>, but the point is to provide that out of the box.

Collapse
 
jonrandy profile image
Jon Randy 🎖️ • Edited

Might want to proofread this 👍

Collapse
 
safdarali profile image
Safdar Ali

If you found my content helpful or interesting, and you’d like to show your appreciation, why not buy me a coffee? It’s a small gesture that goes a long way in helping me keep creating more content for you.

Just click the button below to support:

Buy Me A Coffee

Collapse
 
safdarali profile image
Safdar Ali

Sure Jon you can definitedly do that!! I'll be happy if you read my blog.

Collapse
 
jonrandy profile image
Jon Randy 🎖️ • Edited

Well, all the tags you've added are invisible - making the post essentially unreadable

EDIT: I see you've fixed it 👍

Thread Thread
 
safdarali profile image
Safdar Ali

Thank s for your feedback!

Collapse
 
martinbaun profile image
Martin Baun

Jeez, HTML has some good features, but sometimes they can be ugly and difficult to style! Great piece regardless, thanks for this!

Collapse
 
safdarali profile image
Safdar Ali

If you found my content helpful or interesting, and you’d like to show your appreciation, why not buy me a coffee? It’s a small gesture that goes a long way in helping me keep creating more content for you.

Just click the button below to support:

Buy Me A Coffee

Collapse
 
safdarali profile image
Safdar Ali

Great to hear that! Do subscribe my YouTube Channel

Collapse
 
sanwal_mumtaz_116db1f647f profile image
Sanwal Mumtaz

Great job Mr Safdar👌

Collapse
 
safdarali profile image
Safdar Ali

If you found my content helpful or interesting, and you’d like to show your appreciation, why not buy me a coffee? It’s a small gesture that goes a long way in helping me keep creating more content for you.

Just click the button below to support:

Buy Me A Coffee

Collapse
 
safdarali profile image
Safdar Ali

Thanks Sanwal❤

Collapse
 
ibr_nzr_0516 profile image
Ibrahim Naziru

I need some body who can teach me html, css +2439067658762

Collapse
 
safdarali profile image
Safdar Ali

If you found my content helpful or interesting, and you’d like to show your appreciation, why not buy me a coffee? It’s a small gesture that goes a long way in helping me keep creating more content for you.

Just click the button below to support:

Buy Me A Coffee

Collapse
 
safdarali profile image
Safdar Ali

Glad to hear that Ibrahim❤ do subscribe my YouTube Channel. I can do that you can share your details @ 00alisafdar@gmail.com. I can teach you that.

Collapse
 
soumya_17_ profile image
Soumya Ranjan 🎖️

I have Just created an account and read this, It was my first reading 😂😂

Collapse
 
safdarali profile image
Safdar Ali

If you found my content helpful or interesting, and you’d like to show your appreciation, why not buy me a coffee? It’s a small gesture that goes a long way in helping me keep creating more content for you.

Just click the button below to support:

Buy Me A Coffee

Collapse
 
safdarali profile image
Safdar Ali • Edited

Glad to hear that❤. Do subscribe my YouTube Channel

Collapse
 
gunymedian_e1df1644219d8c profile image
Gunymedian

This is useful.
esp. Details and Summary Elements.
Thanks.

Collapse
 
safdarali profile image
Safdar Ali

If you found my content helpful or interesting, and you’d like to show your appreciation, why not buy me a coffee? It’s a small gesture that goes a long way in helping me keep creating more content for you.

Just click the button below to support:

Buy Me A Coffee

Collapse
 
safdarali profile image
Safdar Ali

Glad to hear that❤ do subscribe my YouTube Channel

Collapse
 
progkidscom profile image
ProgKids

Amazing post, thanks!

Collapse
 
safdarali profile image
Safdar Ali

If you found my content helpful or interesting, and you’d like to show your appreciation, why not buy me a coffee? It’s a small gesture that goes a long way in helping me keep creating more content for you.

Just click the button below to support:

Buy Me A Coffee

Collapse
 
safdarali profile image
Safdar Ali • Edited

Glad to hear that❤ do subscribe my YouTube Channel

Collapse
 
blessedtechie profile image
Blessing Emejulu

As frontend developer, I use picture tag when I have different images to display on across different screen sizes

Collapse
 
safdarali profile image
Safdar Ali

If you found my content helpful or interesting, and you’d like to show your appreciation, why not buy me a coffee? It’s a small gesture that goes a long way in helping me keep creating more content for you.

Just click the button below to support:

Buy Me A Coffee