CSS CSS Selectors Selectors - Beyond the Basics DRY CSS

Why do we use display: block to the img?

Please can someone explain what the use of display:block is in this context? Is this because we want to centre the image using margin: 0 auto, and therefore this will only be centered if display:block is applied?

Thanks

1 Answer

Steven Parker
Steven Parker
203,990 Points

You guessed it! A block mode element with a specified width can the centered using auto margins. A "flow" mode element will ignore the width setting and the auto margin.

Thanks Steven