Why is there no float center in CSS?
Instead of using float: left
, use display: inline-block
on the individual elements and center their container.
http://jsfiddle.net/ExplosionPIlls/rAkNY/5/
Yes, There is not Float center/middle and may the W3C having the answer.
There is <center>
tag but no-longer.
The
<center>
tag is deprecated as of HTML 4, and using it creates a few different issues. HTML centered elements can display differently in different browsers, and using the tag can increase page load time. Also, heavy use of will complicate your site redesigns — removing hundreds of tags takes a lot longer than changing one style rule in a stylesheet.The tag was officially deprecated many, many years ago, but it is still recognized by most browsers through their backward-compatibility features. So yeah, if you something, it'll be centered. However, in the interest of future-proofing you should use modern CSS centering methods instead.
Use margin:0 auto;
If you're centering something else, margin: 0 auto; will get your element centered most of the time. (Quick note: your element must have a declared width for this to work.)
The margin: 0 auto; rule is shorthand for 0 top and bottom margin, and automatic left and right margins. Automatic left and right margins work together to push the element into the center of its container.