display: flex; In addition to this, if you want to align the button in the right position, you can also use the same property and right as its value as given below: The element will then take up the specified width, and the remaining space will be split equally between the two margins: This div element is centered. w3schools .com THE WORLD'S LARGEST WEB DEVELOPER SITE Looking at the example, I'm assuming you want to see the X icon in the center of the button. I've really taken recently to display: table to give things a fixed size such as to enable margin: 0 auto to work. Has made my life a lot easie... align. The