Centering an image CSS-style
Today a simple little tip from an unglamouruos, oft-maligned language: CSS.
In the olden days we all centered our images using ye olde <center></center> tags and it was goode. But then along came HTML 4.0 and center was deprecated. So now what?
Well, we used center anyway because who really cares about validation? C'mon, admit it, you still use center, maybe when no one's looking? Its not like browsers are going to stop supporting that tag any time anyway, at least not during my lifespan (though come to think of it we have done away with blink....)
Well center no more, nu-skool img centering to the rescue:
-
img {
-
margin: 10px auto 10px auto;
-
}
This sticks a 10 pixel margin top and bottom of your images and centers them left and right within whatever container they're in. Ta da. Impressed?
(And if you're thinking "Well duhhh" after that, go read Reg and chew on some of that, you....)
