[WEB4LIB] specifying the width, in pixels, of a line of text with CSS

Thomas Dowling tdowling at ohiolink.edu
Fri Jan 7 12:25:37 EST 2005


John Fitzgibbon wrote:
> Hi,
> 
> Is it possible to specify, in pixels, the width of a line of text? The
> text is between two small images.
> 
> I wish to accurately calculate the width of the two images plus the
> text.
> 
> I could set a value for the width property of the span containing the
> text and set overflow to clip but this may cause me to lose some of the
> text which I am hoping to avoid. I really need to be able to specify the
> width of the font or the width of each letter.
> 
> The width of the images, I already know. If I could specify the width of
> the font or the width of each letter I can reckon the total width.
> 

My first recommendation is to rethink the design so it isn't dependent 
on pixel-perfect dimensions.

If that's absolutely not possible, open up your graphics program of 
choice and make a PNG image of the text you want, with the pixel 
dimensions you want.

FWIW, the width directive isn't defined for inline elements, so a 
compliant browser wouldn't apply it to <span> anyway.


-- 
Thomas Dowling
tdowling at ohiolink.edu



More information about the Web4lib mailing list