DEV Community

Cover image for 5 Unique HTML Elements You Might Not Know

5 Unique HTML Elements You Might Not Know

Matin Imam on July 09, 2024

HTML offers a vast array of elements that can enhance the way you present content on the web. While most developers are familiar with standard tags...
Collapse
 
maxart2501 profile image
Massimo Artizzu

The <details> element has marked a very important milestone for native element interactivity: it's the first element that updates its attributes on user interaction. Specifically, the open attribute is there if and only if the element is, huh, open.

Why is it important? Because it has such dynamic behavior even without JavaScript. GitHub has used it to create modal dialogs that used to work without JavaScript.

Another interesting thing is that now <details> element can have a name, so that only one with the same name can be open, effectively mimicking the behavior of an (exclusive) accordion.

Now even the <dialog> element behaves the same with its open attribute, but it still needs JavaScript in order to be open (at least, until this proposal gets implemented).

Collapse
 
monfernape profile image
Usman Khalil

Great insights, thank you

Collapse
 
perisicnikola37 profile image
Nikola Perišić • Edited

Wow, first time seeing "ruby" tag. Also, I would like to add one more which a lot of people are not aware of:



<pre>
First line
   Second line
</pre>


Enter fullscreen mode Exit fullscreen mode

This code above will display like this:



First line
   Second line


Enter fullscreen mode Exit fullscreen mode

Collapse
 
aadswebdesign profile image
Aad Pouw • Edited

There is a lot you can do with the details/summary and together with it's own even listener 'toggle' but there is also something to keep in mind!
It is 'private shadow dom' and that means you cannot alter it like you do with a normal dom element.
Still, there are ways to get around with it and one of them is not to drop your content straight into the details element but to use a child container <details><summary></summary><div class="content">where you drop your content in</div></details>, this way you take your control over your content back to the dom.
Aside of that, there are more advanced things you can do but that has some css and javascript involved.

Collapse
 
silentwatcher_95 profile image
Ali nazari

Ruby tag sounds interesting 🧐

Collapse
 
martinbaun profile image
Martin Baun

Really handy article.

Collapse
 
dev_kiran profile image
Kiran Naragund
Collapse
 
ducksauce88 profile image
ducksauce88 • Edited

Am I the only one who was so blind to see the first one "q" and see it as "p" and think, ah, thats not unique its used all the time haha. Cool article!

Collapse
 
maxart2501 profile image
Massimo Artizzu

Almost! <q> is the "mirrored <p>", see?

There's also the upside-down <p>: it's the <b> tag!

To complete the schema, the W3C is working on the "mirrored upside-down <p>": the <d> tag! 🤪

Collapse
 
ducksauce88 profile image
ducksauce88

Haha upside down p got me 🤣

Collapse
 
mexikode profile image
MexiKode ⚙

another cool one is <meter> to show progress or evaluate

Collapse
 
zoujia profile image
zoujia

Great👍I never heard about 1~4 😅. The 5th- is used in article comments of dev.to, and this was the first time I knew it's usage since I joined dev.to~

Collapse
 
akeem_jrodebiyi_809b2d36 profile image
Akeem Jr Odebiyi

I never knew ruby tag existed 🥲

Collapse
 
himangshu_dev profile image
Himangshu De

I just came to know about the "details" tag before reading this article. Thi article just explained all the other tags including "details" tag very well!🔥

Highly appreciated for beginners and intermediaries!✌️

Collapse
 
ayush_saran profile image
Ayush Saran

Thanks, I didn't know the detail tag. That could come in handy

Collapse
 
njoxpy profile image
Godbless Nyagawa

Good insight!

Collapse
 
officialphaqwasi profile image
Isaac Klutse

The ruby and details tag got me, interesting I will try my best to include them in my next project. Thanks for sharing.

Collapse
 
aladinyo profile image
Aladinyo

Great these are interesting tags

Collapse
 
manjeshn profile image
Manjesh N

Thanks for this info! I wasn't aware of most of the tags.

Collapse
 
chrisburkssn profile image
Chris Burks

The <dialog> is my new favorite.
It’s “modals made easy”. However, I’m digging that <ruby>.
Thanks for sharing!!!

Collapse
 
msm_robin_2c623f9163f5552 profile image
MsM Robin

Thanks for sharing.

Collapse
 
syedmuhammadaliraza profile image
Syed Muhammad Ali Raza

Thanks for sharing dont know about

Collapse
 
syedmuhammadaliraza profile image
Syed Muhammad Ali Raza

dont know about
Thanks for sharing

Collapse
 
itsrajcode profile image
Rajan Prajapati

Yahh !
Sir u are providing such a handy and useful knowledge

Collapse
 
ritesh_dev profile image
Ritesh Rajput

yeah it to get first time to know about this