Intermediate HTML & CSS
Q41 / 100

What is the difference between "margin: 0 auto" centering a block element and "text-align: center"?

Correct! Well done.

Incorrect.

The correct answer is B) "margin: 0 auto" centers a block-level element with a defined width horizontally within its parent, while "text-align: center" centers inline/inline-block content (like text) inside its container

B

Correct Answer

"margin: 0 auto" centers a block-level element with a defined width horizontally within its parent, while "text-align: center" centers inline/inline-block content (like text) inside its container

Explanation

For a block element to be centered with "margin: 0 auto", it needs an explicit width (so auto margins can distribute remaining space); text-align affects how inline-level content is aligned within its containing block.

Progress
41/100