Forum Moderators: not2easy
Next I added an image and set the height and width both to 20px.
The result was the font was smaller than the image. I even measured with a ruler to make sure I knew which one was off and for certain it was the font. So, my question is, how do I get a font to accurately size according to it's css tag?
Did you try different fonts (arial, georgia, courier, etc.)? Or just one? It may also be that the font you tried is just designed that way...
You'd have to ask a graphic designer that know typography pretty well.
I was playing around with the example you gave, and I cannot figure out how to do what you want in a way that is simple and straightforward. There are ways, but they include extra elements and other quirky workarounds.
One example:
<span style="background-color: #00dd00; height: 50px; width: 50px; float: left; position: relative;"><span style="font: 85px 'courier new'; position: absolute; top: -17px;">M</span></span><img src="" style="background-color: #aaaaff; height: 50px; width: 50px;">
* Add vertical-align: top; to the <span>. This appears to be enough for FF(win) and Opera(win).
* Add vertical-align: top; to the <img>. This seems to correct for IE(win) and have no affect on FF and Opera.
One problem I did see was that my FF showed nothing (for image place holder) at all without a correct image path and image. With images properly sourced all looked like what I think you are trying to achieve.