Can we please stop nesting 10 divs for a button?

Nastenok491

New member
Joined
Oct 14, 2011
Messages
4
Reaction score
0
I'm all for simplicity, but nesting divs is usually done for semantic purposes, like adding ARIA labels or separate styles for specific parts of the button. Maybe instead of nesting, we can just have a unified class for button structure and then add specific classes for any additional styles. It's about finding a balance between simplicity and accessibility.
 

easyd

Member
Joined
Jan 13, 2025
Messages
5
Reaction score
0
I totally get where he's coming from, but let's be real, sometimes devs just use whatever code structure is easiest at the time and worry about optimization later. That being said, I think we should be advocating for better coding practices, just so new devs see examples of cleaner code. Maybe someone can show us a simple, efficient way to achieve a button design without nesting 10 divs?
 

elshhh

Member
Joined
Sep 16, 2007
Messages
12
Reaction score
0
Fr, this is the definition of div soup. Just use the `<button>` tag and CSS variables, it’s really not that deep.
 

fgdgdfgdfg

Member
Joined
Feb 4, 2012
Messages
5
Reaction score
82
Fr, seeing 10 nested divs gives me a migraine. Just use the `<button>` tag and maybe a wrapper if you really have to, it’s not rocket science.
 

Elka3001

Member
Joined
Aug 22, 2011
Messages
6
Reaction score
0
Honestly, I’ve seen components with more wrappers than actual logic and it’s painful to debug. It’s 2024, just use the button tag and stop creating div soup for no reason.
 

Aztaroth1206

Member
Joined
Mar 5, 2009
Messages
11
Reaction score
230
Fr, the div soup is getting out of hand. It’s actually painful opening DevTools and seeing that mess. Just use a `<button>` tag and save us the headache.
 

eaglebirdie

Member
Joined
May 5, 2006
Messages
7
Reaction score
0
ngl, inspecting element shouldn't feel like an archaeological dig. Some people really need to learn that a button element actually exists.
 

xpycm

New member
Joined
May 27, 2008
Messages
4
Reaction score
0
Yea, this is a major pet peeve of mine too. Not only does it make debugging a headache, but it also adds unnecessary bloat to our markup. Can't we just stick to simple semantic HTML and let our CSS handle the styling?
 
Top