Recall & Review
beginner
What does the CSS property
z-index control?The
z-index property controls the vertical stacking order of elements that overlap on a webpage. Higher values appear on top of lower values.Click to reveal answer
beginner
Which elements can have a
z-index value applied?Only elements with a position value other than
static (like relative, absolute, fixed, or sticky) can have a z-index value applied.Click to reveal answer
intermediate
What happens if two overlapping elements have the same
z-index value?If two elements have the same
z-index, the one that appears later in the HTML code will be displayed on top.Click to reveal answer
intermediate
Can
z-index have negative values? What does it mean?Yes,
z-index can be negative. Negative values place the element behind elements with zero or positive z-index values.Click to reveal answer
advanced
What is a stacking context in relation to
z-index?A stacking context is a group of elements that have their own local stacking order. Elements inside a stacking context are stacked relative to each other, but the entire group stacks as one unit in the parent context.
Click to reveal answer
Which CSS property must be set for
z-index to work on an element?✗ Incorrect
The position property must be set to relative, absolute, fixed, or sticky for z-index to take effect.
What does a higher
z-index value mean?✗ Incorrect
A higher z-index means the element appears on top of elements with lower values.
If two elements overlap and have the same
z-index, which one appears on top?✗ Incorrect
The element that appears later in the HTML code is stacked on top if z-index values are equal.
Can
z-index have negative values?✗ Incorrect
Negative z-index values place elements behind those with zero or positive values.
What is a stacking context?
✗ Incorrect
A stacking context is a group of elements that stack together with their own local order, separate from the rest of the page.
Explain how
z-index affects overlapping elements and what conditions must be met for it to work.Think about how layers of paper stack and what makes one paper appear on top.
You got /4 concepts.
Describe what a stacking context is and why it matters when using
z-index.Imagine groups of stacked cards inside boxes stacked on a table.
You got /4 concepts.