I've looked, I've researched, I've spent TOO many hours trying to find the answer to this, just what is wrong with <center> </center>?
I have an html5 website that validates perfectly except for this, centering one image is not a problem but two or more, seemingly it's a nightmare.
Has anyone the solution?
Thanks RB
Fotiman
2:26 pm on Mar 31, 2014 (gmt 0)
<center></center> is a presentational element, meaning it doesn't have any semantic meaning, it only affects the presentation. As such, it should be avoided in favor of using CSS to control presentation.
Here's an easy way to center multiple images. Just wrap them into a single container (it's really that container element that you want to center):
div { display: table; /* shrink wrap the contents */ margin: 0 auto; /* center via left/right margins */ }
RedBar
4:10 pm on Mar 31, 2014 (gmt 0)
Thanks, and this does work perfectly, but it is still going left-adjusted, any ideas?
Fotiman
5:29 pm on Mar 31, 2014 (gmt 0)
I'm not sure what you mean by it works perfectly but it is still going left-adjusted.
RedBar
5:31 pm on Mar 31, 2014 (gmt 0)
Not to worry I've cracked it at long last...so darned simple, doh!
drhowarddrfine
1:08 am on Apr 1, 2014 (gmt 0)
Another big reason to avoid the <center> element: it no longer exists in the HTML5 spec. It's gone. Don't use stuff that doesn't exist.
Planet13
2:38 pm on Apr 5, 2014 (gmt 0)
"Not to worry I've cracked it at long last...so darned simple, doh! "
When you solve a problem yourself, it is a good idea to post the solution here in order to help others who might have the same problem... no matter how seemingly obvious the solution might be.