Fit-to-Width Text: A New Technique
July 30, 2024
Registered custom properties are now available in all modern browsers. Using some pre-existing techniques based on them and complex container query length units, I solved a years-long problem of fitting text to the width of a container, hopefully paving the path towards a proper native implementation.
A long standing challenge for developers–how to fit the width of the text an element to the width of the element (`width: fit-content` does the reverse, makes the width of the element the width of the content) solved.
Now for a platform-native solution!