What is the logic behind this please?

Hiya,

I’ve got this step right. But, I only got it via trial and error.
Why would I put the property as auto if I want it to be horizontal?
Maybe I’m over-thinking it. Not sure if it’s super clear in step’s question, lol.
Thank you.

# Step 90Passed

The image you added is not centered horizontally like the Coffee heading above it. img elements are “like” inline elements.

To make the image behave like heading elements (which are block-level), create an img type selector and use the value block for the display property and use the applicable margin-left and margin-right values to center it horizontally.

My answer:


img {

  display: block;

  margin-left: auto;

  margin-right: auto;

}

We need your code and link to the challenge step to help you.

Well, for this particular question, since you solved it, maybe link to the challenge will be enough.

And if it is about margin, refer to the below. There are examples with auto value and some explanations.

Oh no, it’s been a long day. I’ll post it now. Thanks for reminding me.

Amazing, thank you so much. There’s so much info. I can over complicate and cannot always figure out where to even look ha. This looks really helpful.

Use MDN, it will help to figure out stuff like that

Yeah, I’ve just had a look. It’s a great website- it has everything- thank you.