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

Julia 👩🏻‍💻 GDE @yuridevat

About: 👋 Selftaught Accessibility & Frontend Developer 💻 Dev & UX Accessibility Specialist @Atos | CPACC 🙆 Improving the world with accessible web content ✍️ Content creator, Tips on How To Get Into Tech

Location:
Vienna, Austria
Joined:
May 11, 2020

HTML can do this? Part 1

Publish Date: Dec 16 '23
208 43

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!

Comments 43 total

  • Christine Belzie
    Christine Belzie Dec 16, 2023

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

  • Thomas Bnt
    Thomas BntDec 16, 2023

    Cool post ✨

  • Vipin M S
    Vipin M SDec 16, 2023

    Informative

  • Ara Ara no Mi
    Ara Ara no MiDec 16, 2023

    I thought the 1, 2 and 4 were common sense. I got taught HTML5 back in 2014 when I was studying a web dev degree and these tags already existed back then.

    • АнонимDec 17, 2023

      [deleted]

      • Ara Ara no Mi
        Ara Ara no MiDec 18, 2023

        Dude stfu, all your comments are low quality, go be a hater somewhere else.

    • Julia 👩🏻‍💻 GDE
      Julia 👩🏻‍💻 GDEDec 17, 2023

      That's the thing! They exist for so long and still so many devs don't know about them!! Good for you, that you are using them and get the most out of HTML already for years, Ara!

  • Corina: Web for Everyone
    Corina: Web for EveryoneDec 17, 2023

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

    • Julia 👩🏻‍💻 GDE
      Julia 👩🏻‍💻 GDEDec 17, 2023

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

      • Ben Sinclair
        Ben SinclairDec 17, 2023

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

  • Codeguage
    CodeguageDec 17, 2023

    👏 Very very nice post Julia.

    Semantic HTML elements, in the common 'semantic' sense, no doubt, are unsung heroes of HTML. Especially when we're talking about accessibility, it's quite surprising to know how easy semantic HTML elements could make navigation for people using assistive screen reading technologies.

    I'd like to add in an extra point over here regarding <del> that is worth noting:

    <del> and <s> might be styled the same but they serve different purposes. <del> makes sense when we have interactive capabilities in the underlying document, whereby things could be inserted and deleted — and that's precisely what <ins> and <del> are meant for. If we just want to strike-through text, merely for display purposes, <s> is what we need (which is a replacement for the deprecated <strike> element).

    A while ago, when I was about to teach semantic HTML on Codeguage, I myself came across a surprisingly large number of elements in HTML that I never knew of, and now try to use routinely. The world of semantic HTML is huge and I am sure you'll have a lot to come up with even more amazing posts than this one!

    • Julia 👩🏻‍💻 GDE
      Julia 👩🏻‍💻 GDEDec 17, 2023

      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.

      • Codeguage
        CodeguageDec 17, 2023

        Looking forward to your next article. 🙂

    • Russell Bateman
      Russell BatemanDec 21, 2023

      Thanks for pointing out obliquely that the proper designation is element (and not tag).

      • Codeguage
        CodeguageDec 22, 2023

        That's a good judgement.

  • Abdulmumin yaqeen
    Abdulmumin yaqeenDec 17, 2023

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

    Great article!

  • Lucas Boillot
    Lucas BoillotDec 17, 2023

    Great article! I'll definitely recommend it around me! Thanks for taking the time to write and post it :)

  • EJ Centeno
    EJ CentenoDec 18, 2023

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

  • Nadia Sylvester
    Nadia SylvesterDec 18, 2023

    Thank you Julia 👏

  • Jr. Saplings
    Jr. SaplingsDec 18, 2023

    Great post :) ૮ ˶ᵔ ᵕ ᵔ˶ ა

  • Aryan Dev Shourie
    Aryan Dev ShourieDec 18, 2023

    Great post!
    I'll share this, found it very useful.

  • Matvey Romanov
    Matvey RomanovDec 18, 2023

    is the most fantastic tip. Thanks for letting us know!

  • Ced💣
    Ced💣Dec 20, 2023

    There's also the contenteditable attribute that allows the user to edit content in any tag: developer.mozilla.org/fr/docs/Web/...

  • Sakar
    SakarDec 21, 2023

    It is nice to know about these HTML tags. The tag is really great.

  • Elayeche
    ElayecheDec 23, 2023

    Good post thank you.

  • Michael Casile
    Michael CasileDec 30, 2023

    Cool stuff. I especially liked the summary/detail. Looks good w/no CSS, better with the CSS you provided.

  • ittafame
    ittafameJan 3, 2024

    nice

  • Kusuma Hendra
    Kusuma HendraJan 4, 2024

    we need part 2!!

  • Matias Facio
    Matias FacioJan 7, 2024

    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 ).

    • Julia 👩🏻‍💻 GDE
      Julia 👩🏻‍💻 GDEJan 7, 2024

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

  • Renato Teixeira
    Renato TeixeiraFeb 1, 2024

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

Add comment