How can I center button text both horizontally and vertically in Webflow without using flexbox?

TL;DR
  • Set text alignment to center for horizontal centering.  
  • Match line-height to button height for vertical centering, and ensure no conflicting padding is applied.

To center button text both horizontally and vertically without using Flexbox in Webflow, you can use padding and text alignment techniques.

1. Use Text Alignment for Horizontal Centering

  • Select the button element in the Webflow Designer.
  • In the Style panel, set Text Alignment to Center.
  • This will horizontally center the text inside the button.

2. Use Padding or Line Height for Vertical Centering

  • Vertical centering without Flexbox requires controlling the height and line-height.
  • Set a fixed height for your button (e.g., 40px).
  • Then, set line-height equal to that button height (e.g., 40px).
  • This will vertically center single-line text within the button.

3. Ensure No Conflicting Styles

  • Make sure the button doesn't have any conflicting padding-top or padding-bottom that would offset the vertical alignment.
  • If needed, adjust these paddings to zero and only rely on line-height for centering.

4. Optional: Use Inline-Block for Inline Buttons

  • If the button is inline and not behaving as expected, set its Display to Inline-Block to retain proper alignment.

Summary

To center button text without flexbox, use centered text alignment for horizontal centering and match the line-height to the button height for vertical alignment. This approach works best for single-line text.

Rate this answer

Other Webflow Questions