Reputation: 1564
This code should work (in my opinion) but, I ca't figure out why it won't. Thanks in advance
<body>
<div id="wrap">
<div style="margin:auto;"><img src="logo.png" alt="logo"/></div>
</div>
</body>
</html>
EDIT: I'm trying to center it. It stays in the upper left hand corner. Adding a height and width of auto to both divs also did not work.
Upvotes: 0
Views: 643
Reputation: 1015
you need to check 2 things before you set your division's to center.
Doctype : check whether it is not in quirks mode.
Width of inner div must me less that width of parent div.
do check these things you will get your answer...All the best.
Upvotes: 0
Reputation: 1354
I imagine that the wrap has a set width, the div holding the image will need a set width as well.
Fiddle so you can see that it does work. (a bit overkill for this question, I know :) )
Upvotes: 0
Reputation: 2553
If you want to horizontally center the logo then you have to also specify the width of the containing div. Here is a sample code.
<html>
<body>
<div id="wrap">
<div style="width:100px; margin:0 auto;"><img src="logo.png" alt="logo"/></div>
</div>
</body>
</html?
Upvotes: 2