DEV Community

The HTML Elements You’re (Probably) Misusing – And How to Fix It

Maxime on February 20, 2025

Most developers start with <div> and <span> and never look back. Need a button? Wrap it in a <div> and slap an onclick. Need a ...
Collapse
 
xwero profile image
david duymelinck • Edited

Not a lot of people know the button tag is very powerful.

<div class="alwaysVisible">
<button 
     type="submit" 
     form="longForm"
     formmethod="post" 
    formaction="/save-long-form" 
    formenctype="multipart/form-data">Save</button>
</div>
<form id="longForm">
<!-- a lot of inputs -->
</form>
Enter fullscreen mode Exit fullscreen mode
Collapse
 
digitalminds profile image
Maxime

Exactly! The <button> tag is powerful and a lot of people don’t realize all the built-in functionality it has. Nice example!

Collapse
 
ishimwe_ningque_26744785 profile image
Ishimwe Ning Que

👍

Collapse
 
crosschainer profile image
crosschainer

You should make an article on the built-in JS features for browsers like:
confirm("Do you want to proceed?") - which pops up a browser-default confirmation window
and
input("Type in your name") - which pops up a input field in the browser

Collapse
 
digitalminds profile image
Maxime

Thanks for the suggestion! I’ll think about it (There’s no input(), you might be thinking of prompt())

Collapse
 
nickcoffey profile image
Nicholas Coffey

In React it can be easy to end up with <div>’s everywhere. I agree 100% that we should be using the proper HTML tags no matter the stack. I also didn’t know about the <figure> and <figcaption> tags. Great article!

Collapse
 
digitalminds profile image
Maxime

Thanks! And I agree, it’s easy to rely on <div> everywhere in React. Glad you found the <figure> and <figcaption> tips helpful!

Collapse
 
melfunc profile image
MeL

Very valid points and promotes good coding practices.

Collapse
 
digitalminds profile image
Maxime

Many thanks!

Collapse
 
slobodan4nista profile image
Slobi

Nice ⭐ figure figcaption 🔖

Collapse
 
madhurima_rawat profile image
Madhurima Rawat • Edited

Thanks, great article 👍 All this are very useful for web development projects.

Collapse
 
digitalminds profile image
Maxime

Thanks! Glad you found it useful

Collapse
 
aadswebdesign profile image
Aad Pouw

The 'main' element is somewhere in the middle, right?

Collapse
 
ishimwe_ningque_26744785 profile image
Ishimwe Ning Que

Help me I have problem in JavaScript switch question is (by us a switch case write a program that ask for a number (1-7) and print the corresponding day of the week.

Some comments have been hidden by the post's author - find out more