25

Each element in HTML has a default display mode like "block", "inline", etc. For example, the "div" display is "block", and the "span" display is "inline".

I need a display mode like the "button" elements. It's more like the "inline" because you can put some of them in one line, but unlike the "inline" they can have width property.

OK, enough, let's back to my question. Which display mode do HTML buttons have?

Milad Rahimi
  • 3,464
  • 3
  • 27
  • 39

2 Answers2

22

A button is by default an inline-block, so multiple buttons without a line break or some will be displayed next to each other:

<button>button 1</button>
<button>button 2</button>

If you want them to be under each other, you could display them as block:

button {
  display: block;
}
<button>button 1</button>
<button>button 2</button>
GreyRoofPigeon
  • 17,833
  • 4
  • 36
  • 59
-2

And by changing button's display value to block, you could easily center it like so: (suppose it has a class of btn)

.btn{
    display: block;
    margin: 2em auto;
}