CSS: Why “vertical-align: middle” does not work?
Consider the following example: ( live demo here ) HTML: <a><img src="http://img.brothersoft.com/icon/softimage/s/smiley.s_challenge-131939.jpeg" /></a> CSS: a { display: block; background: #000; line-height: 40px; } img { vertical-align: middle; } The output is: Why the image is not vertically centered ? How could I fix that so it will work in all major browsers ? Please don't assume any image size (like 32x32 in this case), because in the real case the image size is unknown. sandeep You can use position:absolute; for this. For example: a { display: block; background: #000; line-height: 40px;