Nico den Boer - 2009-10-06 06:21:36
If we write a string into a HTML element, how can we then determine the final required height of an object?
Example:
$msg = "Hello,
This is an email from me with some text for you. This is an email from me with some text for you. This is an email from me with some text for you. This is an email from me with some text for you.
I do have something to say, but ... cannot find the right words :)
";
PHP script line:
echo "<div style\"width: 200px;\">$msg</div>";
In this example string, I have pressed enter a few times. You can also (probably) see the wordwrap. The div elemenent has a fixed width, but no fixed height. Within the div, my text will wrap.
The big question is, how can I beforehand determine in this case what the final height of the element will become after it is rendered in the browser?
Of course we know which font we use, which size, which style (plan, bold, italic, underlined).
It seems to be a typographical question, but, PHP programmers will need to answer it sometimes. For me, I face the question for the first time and don't know how to answer it (yet). Your help will be appreciated ...
Kind regards,
Nico