7 Great HTML features you might not be using

Nathan KaduruNathan Kaduru
3 min read

HTML (Hypertext Markup Language) is the backbone of web development and where most web developers begin their journey, it's responsible for structuring, as well as defining the content of the website. Although you might be familiar with popular HTML tags like <div>, <p>, and <img>, there are some lesser-known HTML features that can significantly enhance your coding abilities and improve your overall user experience in your web projects. In this article, we'll explore ten unused HTML features that every developer should know about, and I'll provide practical examples of how to use them effectively.

The 'details' and 'summary' Elements

The 'details' and 'summary' elements are a very powerful combination used together for creating interactive and collapsible content. They allow you to hide secondary information and present it in a neat, expandable format. Here's an example:

<details>
  <summary>Click to reveal more information</summary>
  <p>Hidden content that can be shown or hidden when clicking the summary.</p>
</details>

The code written above will produce this result;

This creates a toggle section that reveals text when clicked, this can be used for FAQ sections or just for toggling content, it also works for images, links, etc.

The 'contenteditable' Attribute

The 'contenteditable' attribute enables users to edit the content of elements directly within the browser. Here is how it is used;

<p contenteditable="true">Try editing this paragraph within the browser.</p>

The contenteditable attribute should only be used on elements that can contain text appropriate for user interaction. Generally, the attribute is applied to block-level elements like <div>, <p>, and <section>, or inline elements like <span>, but it should not be used on elements like <button>, <a>, or other interactive elements, which makes it great for creating text editors.

The 'hidden' Attribute

The 'hidden' attribute allows you to hide elements from the user interface, making it useful for dynamically showing or hiding content based on certain conditions:

<div id="hiddenElement" hidden>This content is hidden by default.</div>

When hidden is applied to an element it disappears completely and doesn't take up space on the page.

The 'translate' Attribute

The 'translate' attribute is great for websites with different languages. It specifies whether an element's content should be translated or not:

<p translate="no">This text should not be translated.</p>

The 'download' Attribute

The 'download' attribute can be used with links to allow the user to download linked resources instead of navigating to them, these are usually the kind of links you encounter when downloading media or documents, downloading through links is made possible thanks to the download attribute:

<a href="path/to/document.pdf" download>Download PDF</a>

The 'spellcheck' Attribute

The 'spellcheck' attribute can be used with form inputs to enable or disable spellchecking within them:

<input type="text" spellcheck="false" placeholder="No spellcheck here!">

The 'autofocus' attribute

The autofocus attribute is used for focusing on an input field automatically when a webpage loads. This can really improve user experience, especially in forms to direct the user's attention to an input field. For example:

<input type="text" autofocus>

Conclusion

Adding these lesser-known attributes to your HTML projects can significantly enhance the user experience and improve your code. By staying curious and continuously exploring new HTML features, you'll become a very effective developer. Try to experiment more with these features and discover the ways they can help you build more interactive and engaging websites for your users.

0
Subscribe to my newsletter

Read articles from Nathan Kaduru directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Nathan Kaduru
Nathan Kaduru

I am a self-taught Front-end developer skilled in HTML, CSS, JavaScript, React, Typescript, and Nextjs, also a technical writer looking to expand my portfolio