Flexbox: How to have a flex child not fill entire height

Join the AI Workshop to learn more about AI and how it can be applied to web development. Next cohort February 1st, 2026

The AI-first Web Development BOOTCAMP cohort starts February 24th, 2026. 10 weeks of intensive training and hands-on projects.


I had a horizontal list of items, and if a line of text got to 2 lines, I had some additional space and its flex siblings were extending to full height.

Before

This was the code

<li class="flex">
  <code class="flex-none text-sm whitespace-normal mr-2 mt-0.5 bg-white text-black p-1 ">
    {new Date(post.date).toString().slice(4, 11)}
  </code>{' '}
  <code class="flex-none text-sm whitespace-normal mr-2 bg-black text-white border p-1 ">
    {post.tag}
  </code>
  <a href={'/' + post.url + '/'}>{post.title}</a>
</li>

To fix this, I added the self-start class to the code blocks which in Tailwind CSS applies the CSS align-self: start;

After

Lessons in this unit:

0: Introduction
1: Align rows or columns
2: Vertical and horizontal alignment
3: Wrap
4: Moving items before / after another one using order
5: Vertical alignment using align-self
6: Grow or shrink an item if necessary
7: Create a layout using Flexbox
8: ▶︎ How to have a flex child not fill entire height