Search code examples
htmlcss

Change font height and width


I want to change not the font-size of a text element, but two independent properties relative to its width and height. For instance, by applying font-width: 50% to this element:

enter image description here

the text would be stretched to half:

enter image description here

Is this possible with CSS?


Solution

  • CSS transform has the scale function for this:

    p {
      display: inline-block;
      font-size: 32px;
      transform: scale(.5, 1);
    }
    <p>This is text.</p>

    Use the two numbers in the function for X- and Y-axis respectively.