-2
.logo {
    border: 1px solid goldenrod;
}

.logo img {
    margin: auto;
    border: 1px solid red;
}

the above is the CSS and its HTML is:the above is the CSS and its HTML is:the above is the CSS and its HTML is:the above is the CSS and its HTML is:the above is the CSS and its HTML is:the above is the CSS and its HTML is:the above is the CSS and its HTML is:the above is the CSS and its HTML is:the above is the CSS and its HTML is:the above is the CSS and its HTML is:

<header class="theader">
            <div class="logo">
                <img src="https://demo.templatic.com/cartsy/wp-content/themes/Cartsy/images/logo.png" alt="" width="100px" height="auto">
            </div>          
        </header>
CoffeeTableEspresso
  • 2,614
  • 1
  • 12
  • 30
  • Images are inline elements and so do not respond to `margin`. Place `text-align:center` on `.logo.` – Paulie_D Jan 19 '21 at 10:05

1 Answers1

-1

make it block and it will work

.logo img {
   border: 1px solid red;
   display: block;
   margin: auto;
}
  • Why was I downvoted. I didn't posted spam? – fitnessninja Jan 19 '21 at 15:38
  • it's fine fitnessninja just your question was already has answered in the top link, because of that someone down voted you. you should check and see if your question is not in the platform, if not than post your question, otherwise you will end up with down vote have a good day my friend --mostafa-- – Mostafa Tabrizian Jan 23 '21 at 19:23