Mike Anthony
Solid State Member
- Messages
- 15
- Location
- United States
I am trying to center an image with CSS instead of using <div align="center">
My code looks like this:
<head>
<style type="text/css">
.center {
margin:auto;
width:100%
display:block;
}
</style>
</head>
<body>
<div class="center">
<img src="image.png">
</div>
</body>
Everything I read says margin:auto; should center it. Then I read you had to make it a block for it to center, and that isn't working either. Anyone know?
EDIT: text-align:center; worked perfectly. I guess that's how you do it.
My code looks like this:
<head>
<style type="text/css">
.center {
margin:auto;
width:100%
display:block;
}
</style>
</head>
<body>
<div class="center">
<img src="image.png">
</div>
</body>
Everything I read says margin:auto; should center it. Then I read you had to make it a block for it to center, and that isn't working either. Anyone know?
EDIT: text-align:center; worked perfectly. I guess that's how you do it.