HTML & CSS · Junior · Question 60 of 75

Why doesn't text-align: center center a <div> with a fixed width inside its parent?

Explanation

text-align affects text and inline/inline-block children. A block with a width is centered with auto margins or by the parent's flex/grid alignment.

Further reading

Problem with a question

HTML & CSS · Junior · question 60

Test yourself

Take the HTML & CSS · Junior quiz: questions and options are shuffled, and you get a review of your mistakes at the end.

Take this quiz