How do you center an image using Cascading Style Sheets?
I have noticed when using CSS there is no option for centering anything other then text, or I just have not seen it, how can this be done? Or would I just use the <div align="center>?
Public Comments
- text-align is just badly named, it effects all inline content in the container it applies to (including images). http://dorward.me.uk/www/centre/
- yeah its better use <div align="center" olso there is valign="top,center, or bottom" from css it will not work well i think ;)
- you place the image on a div, then you give the div a 50% left value and a -x px left margin where x is half the width of the div with postion:absolute ex my image is 200 px wide so i create a 200px wide div gave it a 50% distance from the left ,then i gave it a -100 px margin in the left.. code: .image{ height: 200px; width: 200px; margin-left: -100px; left: 50%; position: absolute; }
Powered by Yahoo! Answers