How do I make two button aligned horizontally in a div? I want no space between the two buttons.
We can align the buttons horizontally as well as vertically. We can center the button by using the following methods: text-align: center - By setting the value of text-align property of parent div tag to the center. margin: auto - By setting the value of margin property to auto.
If you have multiple buttons that should sit side-by-side on the same line, add the data-inline="true" attribute to each button. This will style the buttons to be the width of their content and float the buttons so they sit on the same line.
You can remove floats and align the container of your "buttons" to the right with the property text-align . You don't want your heading to be aligned to the right so you've to cancel it with text-align: left; .
Sometimes you might want to have two buttons next to each other, but to center both together on the page. You can achieve this by wrapping both buttons in a parent <div> and using flexbox to center them on the page. Notice that we also added margin-right: 20px to the first button, in order to add space between them.
Well, they are by default aligned. Just check this code snippet and you'll understand better :) Just make sure to leave no white space between the buttons.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With