DEV Community

Cover image for HTML can do this? Part 1
Julia 👩🏻‍💻 GDE
Julia 👩🏻‍💻 GDE

Posted on • Edited on

HTML can do this? Part 1

Welcome to my HTML can do this series, part 1.

In keeping with my GitHub-Can-Do-This series, today I want to write a post about cool things that HTML can do (and that many apparently don't know about).

I am a strong believer that the more people understand HTML and use it to its full extent, the more accessible the web will automatically become.

Table of content

  1. Details & Summary HTML Tag
  2. Link to email or telephone number
  3. List with autocomplete
  4. Text modifications

As I don't know how many more parts will follow, I'll just start the series by describing awesome tags and the HTML magic behind them in alphabetical order.

1. Details & Summary

Open/Close widgets are typically created using JavaScript. For quite a while now, there is a default HTML tag, which covers exactly that behavior.

Styling can be adjust as needed. By default, the widget is closed. Giving <details> the attribute open, it shows its content from the beginning.

2. Linking to email address or telephone number

The <a> tag has an href attribute, which indicates the link's destination. It can link to web pages, files, email addresses, locations in the same page, or anything else a URL can address.

The href attribute is responsible for making the <a> focusable and activates the link when pressing the enter key.

Linking to email address

If you add mailto: and the email address of the intended recipient in the URL scheme of href, a new outgoing email message with open when clicked.

<a href="mailto:nowhere@email.org">Send email to nowhere</a>
Enter fullscreen mode Exit fullscreen mode

You can also add more details inside the URL and include cc, bcc, subject and body 😯.

<a href="mailto:nowhere@email.org?cc=nobody@email.org&subject=This%20is%20the%20subject">Send email with subject to nowhere and nobody</a>
Enter fullscreen mode Exit fullscreen mode

Read more about linking to email address rfc6068.

Linking to telephone number

You can also link to telephone numbers when adding it to the href after tel:.

<a href="tel:+18005551239">(800) 555 1239</a>
Enter fullscreen mode Exit fullscreen mode

Link behavior can vary depending on the device (MDN official docs on linking to telephone number):

  • On mobile devices, the number is dialed automatically.
  • Most operating systems have programs that can make calls, like Skype or FaceTime.
  • Websites can make phone calls with registerProtocolHandler, such as web.skype.com.
  • Other behaviors include saving the number to contacts, or sending the number to another device.

Read more about linking to telephone numbers rfc3966.

3. List with autocomplete

Using <datalist>, a dropdown menu appears when the user starts to write in the input field and makes it possible for them to choose from the available options form the list.

4. Text modifications

Using specific tags, text can directly be modified without additional CSS. Very handy.


Thanks for reading. I really appreciate it!

Top comments (43)

Collapse
 
reenatoteixeira profile image
Renato Teixeira

The <details> and <datalist> definitely were surprising to me, didn't knew that! Thanks for sharing! 🙂

Collapse
 
yuridevat profile image
Julia 👩🏻‍💻 GDE

Glad you learned something new :)

Collapse
 
matias-tanguito profile image
Matias Facio

Thanks for this Article, Julia. For the first idea, I would like to add that if you add a same 'name' attribute to each details tags, you can change the behaviour to have only one summary open at the same time ( same as with radio buttons ).

Collapse
 
yuridevat profile image
Julia 👩🏻‍💻 GDE

Thanks for mentioning this! A behavior, many devs want to achieve with open/close widgets.

Collapse
 
corinamurg profile image
Corina: Web for Everyone

Oh, super cool! So many tags I did not know about. Saving this for future reference. Many thanks!

Collapse
 
yuridevat profile image
Julia 👩🏻‍💻 GDE

Thanks Corina. Yeah, HTML has so much to give out of the box already. We have to start using it on a regular basis.

Collapse
 
moopet profile image
Ben Sinclair

A linting rule that flags a warning every time a div or span is used might be a good start!

Collapse
 
yuridevat profile image
Julia 👩🏻‍💻 GDE • Edited

Thanks for your comment and insights.

Thanks for pointing out the different purposes. A future article will be exactly about that - and even more, about the accessibility part of these tags, which I did not mention here at all (since, I consider it a bit more advanced):

These tags do have semantic meaning, and always should used accordingly, BUT, these most of these formatting semantics are not recognized by screen readers, at least now.

It still make sense to use them though for future compatibility! There are work arounds I want to talk about more in my next artcile on HTML tags.

Collapse
 
thomasbnt profile image
Thomas Bnt

Cool post ✨

Collapse
 
yuridevat profile image
Julia 👩🏻‍💻 GDE

Thanks Thomas! Appriciate your comment.

Collapse
 
cbid2 profile image
Christine Belzie

Great post @yuridevat! :) I never knew about text modification. That’s an HTML element I can see myself using in the future! :)

Collapse
 
yuridevat profile image
Julia 👩🏻‍💻 GDE

Haha me neither actually. Found out about them while researching for this article.

Collapse
 
abdulmuminyqn profile image
Abdulmumin yaqeen

Super cool new features keep coming, so we can ship less JavaScript!

Great article!

Collapse
 
yuridevat profile image
Julia 👩🏻‍💻 GDE

Thank you!

Collapse
 
ejcenteno_ profile image
EJ Centeno

Awesome article! Can't wait for the next part! Keep up the great work!

Collapse
 
yuridevat profile image
Julia 👩🏻‍💻 GDE

Thanks a lot.

Collapse
 
nadya58s profile image
Nadia Sylvester

Thank you Julia 👏

Collapse
 
yuridevat profile image
Julia 👩🏻‍💻 GDE

:)

Collapse
 
phonghaw2 profile image
Jr. Saplings

Great post :) ૮ ˶ᵔ ᵕ ᵔ˶ ა

Collapse
 
yuridevat profile image
Julia 👩🏻‍💻 GDE

Thank you ٩(๑❛ᴗ❛๑)۶

Some comments may only be visible to logged-in visitors. Sign in to view all comments.