John Commons
John Commons

Reputation: 21

HTML Align header image to the center not working

I have an image that I'm trying to align to the center as a header that is not working, here is my code, help is appreciated because anything else I find online is currently not working.

.center {  	
  display: block;
  margin-left: auto;
  margin-right: auto;
  width: 40%;
}
<body class="news">
  <div id="geheel">
    <div id="header"><img src="Images/turbinezaal9-2-2.jpg"/></div>
</body>

Upvotes: 1

Views: 47

Answers (3)

J. Doe
J. Doe

Reputation: 133

you forgot the tag

.center {  	
  display: block;
  margin-left: auto;
  margin-right: auto;
  width: 40%;
}
<body class="news">
  <div id="geheel">
    <div id="header"><center><img src="Images/turbinezaal9-2-2.jpg"/></center></div>
</body>

Upvotes: 1

Courtney Mill
Courtney Mill

Reputation: 39

That's because you haven't the center used tag in your code, here's a working example!

.center {  	
  display: block;
  margin-left: auto;
  margin-right: auto;
  width: 40%;
}
<body class="news">
  <div id="geheel">
    <div id="header"><center><img src="Images/turbinezaal9-2-2.jpg"/></center></div>
</body>

Upvotes: 2

John Commons
John Commons

Reputation: 21

I forgot to use the class .center

Upvotes: 1

Related Questions