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

Discussion in 'HTML' started by lhjayunaz@gmail.com, Aug 25, 2007.

  1. Guest

    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> :) :)
     
    , Aug 25, 2007
    #1
    1. Advertising

  2. Neredbojias Guest

    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.

    --
    Neredbojias
    Half lies are worth twice as much as whole lies.
     
    Neredbojias, Aug 26, 2007
    #2
    1. Advertising

  3. Jim Moe Guest

    Re: <div question, getting fixed size of contents, not just charactercount

    wrote:
    > 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?

    --
    jmm (hyphen) list (at) sohnen-moe (dot) com
    (Remove .AXSPAMGN for email)
     
    Jim Moe, Aug 26, 2007
    #3
  4. Martin Jay Guest

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

    >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.
    --
    Martin Jay
     
    Martin Jay, Aug 26, 2007
    #4
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. JezB
    Replies:
    14
    Views:
    876
    Kevin Spencer
    Jul 7, 2004
  2. =?Utf-8?B?QmlkYXJrb3Rh?=

    How to set the DataGrid Row Size to a fixed size.

    =?Utf-8?B?QmlkYXJrb3Rh?=, May 19, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    828
    =?Utf-8?B?QmlkYXJrb3Rh?=
    May 19, 2005
  3. Some One
    Replies:
    5
    Views:
    815
    Toby A Inkster
    Aug 9, 2003
  4. fixed size div

    , Dec 12, 2005, in forum: HTML
    Replies:
    1
    Views:
    6,273
    Mark Parnell
    Dec 12, 2005
  5. Stevo
    Replies:
    20
    Views:
    1,020
    dorayme
    Aug 17, 2008
Loading...

Share This Page