When creating custom buttons in CSS using <button>
, I noticed that the text appears to be centered both horizontally and vertically across all browsers without the need for padding, text-align
, or other properties. Simply adjusting the width and height of the button keeps the text consistently in the middle.
I am wondering if this is the default behavior in all browsers, including older versions that I have not tested. Should I consider setting a line-height
and adding padding to center the text vertically, as well as using text-align: center
to ensure horizontal alignment for better compatibility across different browsers?