Failing to center my img element within its parent element

#img-div {
width: auto;
height: auto;
max-width: 1200px;
display: block;
text-align: center;
object-fit: fill;
margin: auto;
#image {
width: 100%;
height: auto;
max-width: 1200px;
margin-left: auto;
margin-right: auto;
display: block;

Is this the correct challenge you are asking about? The challenge you linked to doesn’t have anything to do with centering images.

Hi Am sorry.
Am new to FreeCodeCamp. I also don’t understand how the code got in there. The code was automatically generated by FCC it seems. Just realized it’s wrong. Let me try posting the correct code.

If you have a question about a specific challenge as it relates to your written code for that challenge, just click the Ask for Help button located on the challenge. It will create a new topic with all code you have written and include a link to the challenge also. You will still be able to ask any questions in the post before submitting it to the forum.

Thank you.

1 Like

Here is the link to my code. Please help.

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 failing test 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

Do you understand what the test is looking for?

On a side note, verify your email addr with codepen so we can see your pen full view.

HI @Kuhum !
Welcome to the forum!

Make sure to open up the test suite and read the full error message.

Do you understand what the error message means?
What parts are giving you trouble?

The title of your post says you are struggling with centering an image but that is not what the error message says.

How can we help? :grinning:

Thank you so much for your help. I was not understanding what exactly was the problem. Challenge solved :white_check_mark:

1 Like

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