To make the input match a specific length in pixels (e.g. 100px) you need to set the width
.
This will make your input take 100px width.
To get a proper text overflow you add overflow:hidden
and text-overflow:ellipsis
.
Lastly add your text into the title
attribute too, so you get the full text as tooltip when hovering the button - This is optional but i'd strongly recommend it for accessibility reasons.
.trimmedbutton {
width: 100px;
overflow: hidden;
text-overflow: ellipsis;
}
<html>
<body>
<input class="trimmedbutton" type="button" value="Trim long long long long long long long text that goes beyond a specified length" title="Trim long long long long long long long text that goes beyond a specified length" />
</body>
</html>