Interview Question

What is z-index?

z-index orders eligible boxes inside their stacking context.

💡 Concept ✅ Quick Revision 🎨 CSS

Answer

The z-index property controls stack level for positioned and certain layout boxes. • It affects ordering within a stacking context. • A large value cannot escape an ancestor stacking context. • The property can also create a new stacking context in applicable cases.

💡 Simple Example

.dialog { position: fixed; z-index: 100; }

⚡ Quick Revision

z-index orders eligible boxes inside their stacking context.