How to Align Pricing Plan Cards Side by Side with CSS
To line up pricing plan cards, make the outer container a CSS Grid and give each card grid-template-rows: subgrid. The rows inside each card then align with the neighboring cards. Even when one plan has a one-line description and another has four lines, the feature list and the button start at the same height. I also checked how to place a badge on the recommended plan and how to stack the cards on narrow screens.
The test environment was Ubuntu 24.04, Node.js 22.23.4, Playwright 1.63.0, and Chromium 153. I opened the HTML and CSS page with Playwright and measured the top edge of each element (in px from the top of the page) with getBoundingClientRect(). I did not test Firefox, Safari, real smartphones, or screen reader output.

- 1. Use the same structure in every card's HTML
- 2. Vertical flex with margin-top: auto does not align the feature lists
- 3. Use subgrid to align the rows inside the cards
- 4. Place the featured badge with position: absolute
- 5. Switch to a single column on narrow screens
- 6. Browser versions that support these features
Use the same structure in every card's HTML
Make each card an li inside a ul, and use the same element order in every plan. There are five elements: plan name, price, description, feature list, and button.
<ul class="plans">
<li class="plan">
<h3>フリー</h3>
<p class="price"><span class="amount">0円</span><span class="unit">/月</span></p>
<p class="desc">まずは試してみたい人に。</p>
<ul class="features">
<li>プロジェクト 1件</li>
<li>保存容量 1GB</li>
</ul>
<a class="cta" href="#">無料ではじめる</a>
</li>
<li class="plan featured">
<p class="badge">おすすめ</p>
<h3>スタンダード</h3>
…
</li>
…
</ul>
In the test page, I made only the Standard description long (four lines at an 800px viewport width), and I varied the number of features per plan: 2, 4, and 3. Visual-only styles such as borders and font sizes are in a separate file. At first, I hid the "Recommended" badge on Standard with display: none and measured positions. The numbers in the comparison image and in the sections up to "Placing the featured badge" are from that state with the badge hidden.
Vertical flex with margin-top: auto does not align the feature lists
To place cards side by side, display: flex is enough. But even when the cards have equal heights, the buttons sit at positions that depend on each card's content. At an 800px viewport width, the top edges of the buttons were 213px, 335px, and 240px from the left.
To pin the buttons to the bottom, make each card a vertical flex container and give the button margin-top: auto.
/* Make the card a vertical flex container and push the button to the bottom */
.plans {
display: flex;
gap: 24px;
}
.plan {
flex: 1;
display: flex;
flex-direction: column;
gap: 12px;
}
.cta {
margin-top: auto;
}
When a flex item has an auto margin, the free space goes into that margin (see the section on auto margins in MDN's Aligning items in a flex container). With this CSS, the top edges of all three buttons were at 383px.
However, the top edges of the feature lists were 182px for Free and Pro, and 250px for Standard. Because the description has a different number of lines, the start of the list below it shifts. Each card is its own flex container, so the height of the neighbor's description does not affect it.

Use subgrid to align the rows inside the cards
To align the rows inside the cards, make the outer container a grid and make each card a subgrid.
/* Align the rows inside each card with its neighbors */
.plans {
display: grid;
grid-template-columns: repeat(3, 1fr);
gap: 24px;
}
.plan {
display: grid;
grid-template-rows: subgrid;
grid-row: span 5;
row-gap: 12px;
}
grid-row: span 5 makes each card use five rows of the outer grid. A card with grid-template-rows: subgrid uses those five rows as its own. The outer grid sets the row heights, so the rows line up with the tallest content among the three cards. Set the span value to match the number of elements in the card (five here).
At an 800px viewport width, all three cards started the plan name at 49px, the price at 90px, the description at 148px, the feature list at 250px, and the button at 383px. The card with the shorter description has empty space below it.
The row-gap: 12px is needed because a subgrid inherits the gap of the outer grid. The MDN subgrid documentation also says that the outer gap is inherited and can be overridden on the subgrid. Without row-gap, the spacing between rows inside each card stayed at the outer 24px, and the card height grew from 428px to 476px.
Place the featured badge with position: absolute
The "Recommended" badge on the recommended plan is an element the other cards don't have. If it sits in normal flow, only the Standard card has six child elements, and the rows shift by one. In my test, the Standard plan name started at 90px (where the other cards' prices start), and the button's top edge was at 312px, the same as the feature list, so the two overlapped.
According to the MDN subgrid documentation, a subgrid does not automatically add rows for extra items in that direction. Items that don't fit go into the last row. That is why the button overlapped the feature list.
Giving the badge position: absolute removes it from the row layout.
/* Make the recommended plan stand out */
.plan.featured {
position: relative;
border-color: #d85878;
box-shadow: 0 0 0 1px #d85878;
}
.badge {
position: absolute;
top: 0;
left: 50%;
translate: -50% -50%;
padding: 2px 12px;
border-radius: 999px;
background: #d85878;
color: #fff;
font-size: 13px;
font-weight: 700;
}
An element with absolute positioning inside a grid is taken out of normal flow. It does not use a grid row, and the other items are placed as if it were not there. With this CSS, the Standard plan name also started at 49px, the same as the others, and the button stayed at 383px. The badge spanned from 13.5px to 36.5px, crossing the card's top edge at 24px, and its horizontal center matched the card's center. left: 50% and the first -50% in translate center the badge horizontally on the card. top: 0 and the second -50% shift it up so it straddles the top edge. In the measured layout, the top half of the 23px-tall badge (11.5px) was outside the card.
You could also make the outline thicker by setting border to 2px. In my test, that added 1px to the border, and only the Standard plan name started at 50px, one pixel off from the other cards. Using the fourth value of box-shadow (the spread) to add 1px outside the border, as in the CSS above, makes the outline look 2px thick while the inner positions stay the same as the other cards.
Switch to a single column on narrow screens
With three columns, the cards become too narrow on small screens. Setting grid-template-columns to repeat(auto-fit, minmax(min(100%, 200px), 1fr)) places as many cards per row as fit at 200px or wider. For details on auto-fit versus auto-fill and this pattern, see my other article on this blog, "How to Automatically Arrange Cards to Fit the Width with CSS Grid." The complete CSS is below.
/* Arrange the pricing cards and align the rows inside them */
.plans {
display: grid;
grid-template-columns: repeat(auto-fit, minmax(min(100%, 200px), 1fr));
gap: 24px;
}
.plan {
display: grid;
grid-template-rows: subgrid;
grid-row: span 5; /* number of elements in the card */
row-gap: 12px;
}
/* The recommended plan (.plan.featured and .badge) is the same as above */
These are the results when I changed the viewport width:
| Viewport width | Layout | Row alignment |
|---|---|---|
| 800px | Three cards in one row | All three start at the same height |
| 600px | Two cards in the first row, one below | The top two align. Pro, in the second row, is only as tall as its own content (333px) |
| 375px | One card per row, stacked | Each card is only as tall as its own content (306px, 405px, 333px) |
When the cards were stacked, the spacing between them was the outer gap of 24px. Cards in different rows do not share rows, so their heights are not matched. For that reason, there was no empty space below the shorter cards in the single-column layout. Even at 375px, the featured badge straddled the top edge of the Standard card and was shown at the card's horizontal center.
Browser versions that support these features
These are the versions in which the newer features used in this article's CSS became available, according to MDN compatibility data (@mdn/browser-compat-data 8.1.8).
| Feature | Chrome | Firefox | Safari |
|---|---|---|---|
grid-template-rows: subgrid |
117 | 71 | 16 |
translate property |
104 | 72 | 14.1 |
min() |
79 | 75 | 11.1 |
According to the compatibility data, all the features used in the final CSS are supported from Chrome 117, Firefox 75, and Safari 16 onward (Chrome and Safari were last to support subgrid, and Firefox was last to support min()).





