user3025289
user3025289

Reputation:

Is it possible to detect text-width with pure css?

I would like to know how much percent width a sentence (in relation to window width) have.

Example:

Given:

  1. Sentence with 20 letters including white space
  2. Font Arial, font-size 20px

Wanted:

Width of the text (without wrap) in percentage in any resolution

Upvotes: 1

Views: 141

Answers (1)

niutech
niutech

Reputation: 29922

It is now possible to find out the width of text using container query length units, see Roman Komarov's article for details.

Upvotes: 0

Related Questions