0
0
CSSmarkup~5 mins

Z-index basics in CSS - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
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?
Aposition
Bdisplay
Cmargin
Dcolor
What does a higher z-index value mean?
AThe element is smaller
BThe element is further back
CThe element is invisible
DThe element is on top
If two elements overlap and have the same z-index, which one appears on top?
AThe one with the higher <code>z-index</code>
BThe one that appears first in the HTML
CThe one that appears last in the HTML
DThe one with the bigger size
Can z-index have negative values?
ANo, only positive values are allowed
BYes, negative values place elements behind others
CYes, but negative values make elements invisible
DNo, negative values cause errors
What is a stacking context?
AA group of elements stacked together with their own order
BA CSS property for colors
CA type of HTML tag
DA JavaScript function
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.