Hey guys, I'm trying to align a pic by itself on my page and I can't get it to be centered. It's either to the left or the right. I'd thought that I could just use <img align="center"> but I quess I'm wrong. Anyone have any suggestions (I'm still learning)? Thanks.
Personally, the easiest way IMO is to just wrap the center tags around it. <center><img src="http://www.purelywrestling.com/news/wp-content/ecwons2.gif"></center> Code (markup):
The center element is no longer a part of html. It should not be used in any new document. An image is an inline replaced element. As such, it may be treated as if it were text. p { text-align: center; } ======= <p><img src="some.jpg" alt=""></p> Code (markup): Or you can declare it to display as a block element and center it as you would any other block element. img { display: block; margin: 0 auto; } =========== <img src="some.jpg" alt=""> Code (markup): cheers, gary
Hello, RH78. You can't write <img align="center"> because "align" is not an attribute of the "img" tag. Each tag has its set of attributes. If you use an erroneous attribute, most probably the browser you are using for your tests won't complain, but nothing will happen. Before adding an attribute, you should consult your software's help to see if the attribute is allowed for the tag. You can also visit my site for an introduction to HTML.