Skip to main content
CSS Tip

Equal width buttons

Make a set of buttons equal in width to the largest one using a few lines of code.

eqaul width buttons

.container {
display: grid; /* OR inline-grid*/
grid-auto-flow: column; /* OR row */
grid-auto-columns: 1fr;
width: max-content; /* not needed with inline-grid */
}

See the Pen Equal width buttons by Temani Afif (@t_afif) on CodePen.


More CSS Tips