<!DOCTYPE html> <html> <body> <input size="20" value="abcde"> <script> document.body.offsetWidth; document.getElementsByTagName("input")[0].maxLength = "2"; </script> </body> </html>