dcsimg
www.webdeveloper.com
Results 1 to 4 of 4

Thread: getting pixel length of text

  1. #1
    Join Date
    Apr 2008
    Posts
    28

    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
    Posts
    3,767
    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
    Location
    Copenhagen, Denmark
    Posts
    1,253
    A span element with no padding should have the same length as the text which it contains.

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

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

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

    Thanks.

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



Recent Articles