0

Can anyone explain how this block of code works?

img{
display:block;
margin:auto;
}

I used this block of code to center a gif. My teacher said to try using align:center; but that had not worked either. I found the answer online but didn't understand it. I know a margin is used to create a space between two different blocks/backgrounds/borders. But what does the auto mean? Thanks.

Wonders
  • 3
  • 3

1 Answers1

0

Using display : block style sets the element to take up it's full horizontal space on the page. The margin: auto sets the element horizontally within a container. It evenly distributes the space on left and right margin.

FNunez
  • 98
  • 2
  • 12