0

Is it possible to keep the exact width of a <span> while changing the font-family of the text inside ? I am thinking about balancing this width with font-size or font-size-adjust because letter-spacing will not render gracefully.

I chose deliberately two very different typefaces: Times and Verdana.

Rollover the demo: http://jsbin.com/ahiba4/20

FreeAsInBeer
  • 12,937
  • 5
  • 50
  • 82
1213
  • 706
  • 2
  • 8
  • 25

1 Answers1

1

It is possible, but only using JavaScript.

  1. Store the container's width in a variable
  2. Change the font in the container
  3. Set the font size so the container matches the previous width again using one of the methods shown in these questions:

Community
  • 1
  • 1
Pekka
  • 442,112
  • 142
  • 972
  • 1,088