in reply to Pixel length of strings

I wouldn't use HTML in the first place. Why not use SVG?

Replies are listed 'Best First'.
Re^2: Pixel length of strings
by TruthSeeker (Initiate) on Jul 11, 2009 at 19:42 UTC
    I don't know what SVG is. My perl programs generate HTML which is then (after a little massaging) published as a web page. This is all part of a softball website that I support.

      I believe the point the monk above was making is that "HTML IS NOT PIXEL PERFECT".

      You're at the whim of the fonts the end user has chosen, their preferred display size, differences in rendering, and more.

      If you absolutely must have something be pixel perfect use an image, PDF, or similar.

      Steve
      --

      Scalable Vector Graphics (SVG) is a standard for including vector graphics (drawings) into a HTML page.

      HTML itself does not (and can not) guarantee how your page is rendered, for it is a device independent format. You can't be sure even that your page is rendered as text (braille browsers, voice synthesis, etc.)

      So pure HTML is not the right choice for a fixed format output; on the other hand, SVG is a format for specifying graphics and compliant browsers (most if not all modern browsers) try to render it exactly as you specified.

      Rule One: "Do not act incautiously when confronting a little bald wrinkly smiling man."

        > and compliant browsers (most if not all modern browsers) try to render it exactly as you specified.

        Unfortunately Internet Explorer does not currently (as of IE 7.0) support SVG natively, (but third-party plug-ins are available such as Adobe SVG Viewer)

        Cheers Rolf

      Trying to emulate the layout descisions made by the browser (note that there are many browser distributions and versions each doing it slightly differently) is neither anticipated by the browser developers nor a generally good design, since HTML never was supposed to give complete control of the final layout.

      SVG is very easy to generate and you have much more accurate control of the layout. If you have to deal with browsers that doesn't understand it, you can use a server side tool to render a bitmap image from SVG.

      Since it is an XML based standard, it is straight forward to create templates and use them much the same way you'd publish web pages. All you need to change is the content type.

      Try taking a look at some SVG examples or the SVG specification.

      Another obvious alternative to SVG is generating bitmap graphics straight away as suggested in other posts.