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,891
  • 5
  • 48
  • 80
1213
  • 688
  • 2
  • 8
  • 22

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
  • 431,103
  • 135
  • 960
  • 1,075