DEV Community

Discussion on: How do you review CSS?

Collapse
 
thexdev profile image
M. Akbar Nugroho

Why setting z-index are bad practices and should avoided? Overlay, modal, etc works with z-index isn't it?

Collapse
 
codingjlu profile image
codingjlu

z-index is bad for accessibility (like screen readers) because it sort of places stuff in the wrong order and confuses people.

Collapse
 
loucyx profile image
Lou Cyx

As @codingjlu pointed out, is an a11y issue. If you want to put something in top of something else, you should be using the DOM order, not z-index. Is as bad as setting tabindex in HTML.

Thread Thread
 
thexdev profile image
M. Akbar Nugroho

Oh, thank you. I think I need do research about a11y and z-index

Collapse
 
codingjlu profile image
codingjlu

But at the same time, remember that z-index is useful in some situations like popups or banners or nitty gritty stuff.