Results 1 to 4 of 4

Thread: getting pixel length of text

  1. #1
    Join Date
    Apr 2008

    getting pixel length of text

    Are there any methods that I can use to get the pixel length of a text element? The text element would change pixel length depending on its font.

  2. #2
    Join Date
    Aug 2007
    To the best of my knowledge no. You can get the length the container it's in if that is any use to you, I'm not sure the information you've given.

  3. #3
    Join Date
    Sep 2006
    Copenhagen, Denmark
    A span element with no padding should have the same length as the text which it contains.
    #define question (2B || !2B)
    HTMLElement and W3C Event Handling in IE
    My JavaScript Library

    Don't PM me about answers to questions. If I don't reply in a thread it's because:
    • You didn't read the message posting guidelines
    • Your code is too unstructured and/or formatted poorly - correcting it is too time consuming
    • I simply don't know the answer

  4. #4
    Join Date
    Apr 2008
    I used Span.

    Just had to set:
    .style.whiteSpace = "nowrap";

    and then use the .offsetWidth property to get the width.


Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center