Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. Width of characters

Width of characters

Scheduled Pinned Locked Moved Web Development
javascriptquestion
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    CoolASL
    wrote on last edited by
    #1

    Hi all, Is there any way in which i can find out, using javascript, the width & height of a string when used with a particular font and size. eg.

    <font size=4 face="verdana">Hello</font>
    

    i wish to know what will be the width of "Hello" above as displayed on the web-page. Thanks in advance. *** Who said nothing is impossible? I have been doing it for a long time ***

    G 1 Reply Last reply
    0
    • C CoolASL

      Hi all, Is there any way in which i can find out, using javascript, the width & height of a string when used with a particular font and size. eg.

      <font size=4 face="verdana">Hello</font>
      

      i wish to know what will be the width of "Hello" above as displayed on the web-page. Thanks in advance. *** Who said nothing is impossible? I have been doing it for a long time ***

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      No. You have to put the text in an element, put the element on the page so that it's rendered, and then get the measurements of the element. --- b { font-weight: normal; }

      C 1 Reply Last reply
      0
      • G Guffa

        No. You have to put the text in an element, put the element on the page so that it's rendered, and then get the measurements of the element. --- b { font-weight: normal; }

        C Offline
        C Offline
        CoolASL
        wrote on last edited by
        #3

        Thanks Guffa, again... :-) *** Who said nothing is impossible? I have been doing it for a long time ***

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups