HTML & CSS · Junior · Question 60 of 75
Why doesn't text-align: center center a <div> with a fixed width inside its parent?
- ✓Correct answer: It aligns inline content inside a block, not the block itself; use
margin-inline: autoor Flexbox - 2
text-alignonly works on<p> - 3It needs
!important
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.