Interview practice question
Centring an element horizontally and vertically
Frontend Engineering · HTML and CSS · Beginner
How would you centre a box both horizontally and vertically inside its container?
What a strong answer covers
Your AI report card counts how many of these ideas you cover.
- Flexbox: display flex + justify-content + align-items center.
- Grid: display grid + place-items center.
- Container needs height.
- Margin auto for horizontal block centring.
- Absolute + transform older approach.
Practise this topic
Start without signing up. Sign in free to get an AI report card on your answer.