Skip to content

How to have a flex child not fill entire height

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.


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(, 11)}
  </code>{' '}
  <code class="flex-none text-sm whitespace-normal mr-2 bg-black text-white border p-1 ">
  <a href={'/' + post.url + '/'}>{post.title}</a>

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


β†’ Download my free CSS Handbook!



You might be interested in those things I do:

  • Learn to code in THE VALLEY OF CODE, your your web development manual
  • Find a ton of Web Development projects to learn modern tech stacks in practice in THE VALLEY OF CODE PRO
  • I wrote 16 books for beginner software developers, DOWNLOAD THEM NOW
  • Every year I organize a hands-on cohort course coding BOOTCAMP to teach you how to build a complex, modern Web Application in practice (next edition February-March-April-May 2024)
  • Learn how to start a solopreneur business on the Internet with SOLO LAB (next edition in 2024)
  • Find me on X

Related posts that talk about css: