button width according to text code example
Example 1: button size html
<button style="height:40px; width:40px;">Press Me</button>
Example 2: button width based on text csss
Remove the width and display: block and then add display: inline-block to the button.