How block elements can be centered with CSS1?

0

Block level elements can be centered by:
The margin-left and margin-right properties can be set to some explicit value:
BODY {width: 40em;background: fluorescent;}P {width: 30em;margin-right: auto;margin-left: auto}
CSS Copy In this case, the left and right margins will be each, five ems wide since they split up the ten ems left over from (40em-30em). It was unnecessary for setting up an explicit width for the BODY element; it was done here for simplicity.

Css
asked Apr 14, 2023 at 18:18
Sign in to add a comment

0 Answers

0
📝 No answers yet!

Be the first to answer this interview question.

Your Answer

Sign in to post your answer and help the community.