Why is there no float: center?
When they were writing the specifications for CSS, why didn’t they allow things to be floated center?
I was looking through an old site at work this week, that was developed long before me, and I saw someone tried to do this: float: center. So that got me thinking, why would they include the specification to float left and right, but not center?
Imagine the posibilities…the following are just a couple of simple examples of what could be possible, they are not meant to be used in a production environment.
- Float an Image Between Two Columns
In this example, I just floated the image to the right, and gave it a -100px right margin (half the width of the image). Then I just added an empty div to the right hand column, floated it left, and gave it a height and width.
- Float an Image in the Middle of One Column
This one is really hacky. I absolutely positioned the image, chose a monospaced font, and then added non-breaking spaces so that the image was no longer covering the text.
I think being able to float something in the center could really make pages more interesting. I would be curious to know if there was any specific explanation for why you cannot float to the center.