Text-align :center not working

why the img-caption text is not centering ?

https://codepen.io/advitya-sharma/pen/JjYVRRO

It does work your other elements are interfearing with it.

When I added <div> around <figurecaption> and added #img-caption to that div, it was centered.

<div id="img-caption">
  <figurecaption>
    The Missile Man of India
  </figurecaption>
</div>

can you specify which elements ?

Hello there,

You have defined an element with id="img-div", but have #imd-div in the CSS. After changing that, I suggest you use something like this:

display: flex;
flex-direction: column;

Inside the #img-div in the CSS.

Hope this helps

1 Like

why it worked ? how its related to #img-caption ?

You have an invalid element figurecaption. It should be figcaption. If you change it to the correct element it will be a block-level element and will center.