Reputation: 21
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
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
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