<div question, getting fixed size of contents, not just character count

L

lhjayunaz

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> :) :)
 
N

Neredbojias

Well bust mah britches and call me cheeky, on Sat, 25 Aug 2007 22:59:50 GMT
scribed:
hi, is it possible in anyway, to read or determine absolute pixel
width size of contents within a <div> tag?

-Of bare text? I think you'd need a container of some sort. Then it's
possible.
so like <div>what is pixel wXX size of this text?</div> :) :)

Position the div absolutely.
 
J

Jim Moe

hi, is it possible in any way, 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>
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?
 
M

Martin Jay

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> :) :)

There is a discussion about this here:
<http://www.ozzu.com/ftopic39999.html>.

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
<http://www.spam-free.org.uk/pages/div_width.php>.

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,763
Messages
2,569,563
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top