He img element should be centered within its parent element. Please help me, I couldn't figure it out

This is my code. Please let me know what I did wrong.

1 Like

I don’t see a picture in your codepen. Is that the problem? I right clicked the picture (on wikipedia) and selected copy image location in firefox. The url has “upload” in it. It’s a little different than the one you have.
I found out through the solution on this forum post https://forum.freecodecamp.org/t/codepen-not-displaying-image/186820?u=tlc35us

2 Likes

You can try to click on podELaK near the image. Let me know if you can see my code.

It should be the last task : User Story #9: The img element should be centered within its parent element.

Images are inline elements but you can center them by first making them block elements. This you can do by setting the display to block then also set the margin to auto to center the image.

Below is an example if you don’t remember how to write the code. I would advise you to only open it if you don’t remember the codes used.

display: block;

margin: auto;

I checked your code and you used text-align, as the name says it can only be used to center text and not images, take note. Also fix the image link so it displays an actual image because there is no image on your website

@Larisa97, when a test fails click the red button to see which test(s) are failing and text to help you correct the issue.
Be sure and read more than just the first line of the failing message. The ability to read and comprehend error messages is a skill you’ll need to acquire as a developer. Ask questions on what you don’t understand.

The full failing message says

Within the "img-div" element, I should see either a <figcaption> or <div> element with a corresponding id="img-caption" that contains textual content describing the image shown in "img-div".
expected null to not equal null
AssertionError: expected null to not equal null 

Your image is not displaying because you’re pointing to a pointer. You’ll need to right click the image and then “copy image address”. That is what you’ll put into the src attribute.

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.