Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

  •   Subject
  • Author
  • Posted on
hi, is it possible in anyway, to read or determine absolute pixel
width size of contents within a <div> tag?

so like <div>what is pixel wXX size of this text?</div> :-) :-)

Well bust mah britches and call me cheeky, on Sat, 25 Aug 2007 22:59:50 GMT  

Quoted text here. Click to load it

-Of bare text?  I think you'd need a container of some sort.  Then it's

Quoted text here. Click to load it

Position the div absolutely.

Half lies are worth twice as much as whole lies.

Re: wrote:
Quoted text here. Click to load it
  For HTML, no.
  It would have to be a client-side function since a div normally expands
to the width of its container. If it is floated, then it shrinkwraps the
text, probably. In either case it depends on the client's current setup:
the width of the viewport, the metrics of the font set.
  What is your application that needs to know this information?

jmm (hyphen) list (at) sohnen-moe (dot) com
(Remove .AXSPAMGN for email)

On Sat, 25 Aug 2007 22:59:50 -0000, wrote:

Quoted text here. Click to load it

There is a discussion about this here:
< .

The fifth message in the thread may be of interest to you.

As I understand it, it's only possible to get the width of a DIV using
Javascript in IE (<7?) if it has been specifically set using CSS.  In
which case you'd probably know it already.

I've uploaded a simplified page using the method described to
< .

Try loading the page into Firefox, Opera or Safari and then hitting
the refresh button in the browser.

As usual IE, versions less then 7 anyway, is the odd man out.  
Martin Jay

Site Timeline