Centering a Text Inside a Button
· One min read
Instead of centering headings and paragraphs, let’s center text inside another element (<button> </button>). Aligning the button, and the text inside the button, would differ slightly from the examples.
That’s because the text-align property only works on the content inside block-level elements, such as headings and paragraphs, and not inline elements, such as buttons.
So here's what we'll do instead:
- Wrap the button in a
div - Then, add an inline style declaration to the div, i.e.
<div style="text-align:center">.
