Home > Enterprise >  Why can't I target my footer image with CSS
Why can't I target my footer image with CSS

Time:11-24

.footer_image {
  height: 60rem;
}
<footer>
  <div >
    <img src="https://via.placeholder.com/200x200" style="margin-left:20px">
  </div>
</footer>

I cant seem to target the properties to change my image in my footer, what am I doing wrong?

CodePudding user response:

You can use

.footer_image img {
}

This will work on all pictures which have the html img tag and are inside the .footer_image class

Or you can assign a class or id to your image to define its properties

<img  src="logo_footer.png" style="margin-left:20px">
<img id="mysuperfancyimage" src="logo_footer.png" style="margin-left:20px">

You can call classes with a dot and and IDs with a Rhombus

.mysuperfancyimage {
}
#mysuperfancyimage {
}

CodePudding user response:

This works nicely - the problem might be that you're targeting the image parent, not the image itself.

.footer_image > img {
    height: 60rem;
}
<footer>
  <div >
    <img src="logo_footer.png" style="margin-left:20px">
  </div>
</footer>

  • Related