Isabella
Joined: 15 Jun 2006 Posts: 103
|
Posted: Fri Aug 11, 2006 11:44 pm Post subject: Some Elements Center, Others Don't! |
|
|
First, remember that the ALIGN attribute is a deprecated HTML attribute, meaning it's marked for deletion in future versions. Of course, deprecated doesn't mean that it will stop working tomorrow or even next year. But it does mean that you should be alert to display issues in current and future browser versions.
Since ALIGN may not behave as you expect, how should you center an image?
Your first thought is probably to include the align="center" property/value pair to your image tag. After all, it works for paragraphs, tables, and other elements:
| Code: | <p align="center">paragraph content here</p>
<table align="center">table content here</table>
<div align="center">div content here</div>
<h2 align="center">header content here</h2> |
The content inside those tags centers reliably across browsers because they're block-level tags. But the IMG tag is an inline element, so it displays relative to the content around it. That's why the only supported ALIGN values are those that indicate how text and other page elements should display in relation to the image.
| Quote: | | You can move an image to the left or right on the Web page or control its vertical placement with the ALIGN property, but you can't center it using the ALIGN attribute. align="center" isn't valid HTML. All browsers ignore align="center" when it's part of an IMG tag. |
Via Larisa
|
|