Toggle navigation
☰
HTML
CSS
Scripting
Database
<!doctype html> <html> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Tailwind CSS Equal Height Columns</title> <script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4.2.1"></script> </head> <body class="antialiased"> <div class="bg-slate-50 dark:bg-slate-900 min-h-screen p-8 flex items-center justify-center"> <div class="max-w-5xl mx-auto grid grid-cols-1 md:grid-cols-3 gap-6 items-stretch"> <div class="bg-white dark:bg-slate-800 p-6 rounded-xl shadow-md flex flex-col"> <h3 class="text-xl font-bold mb-3 text-slate-800 dark:text-white">Basic Column</h3> <p class="text-slate-600 dark:text-slate-400 mb-6 flex-grow">This column has some basic content. It will stretch to match the height of the tallest column in this grid row. flex-grow pushes the button to the bottom.</p> <button class="w-full bg-slate-100 hover:bg-slate-200 dark:bg-slate-700 dark:hover:bg-slate-600 text-slate-800 dark:text-white py-2 rounded-lg font-medium transition-colors">Action</button> </div> <div class="bg-white dark:bg-slate-800 p-6 rounded-xl shadow-md border-2 border-indigo-500 relative flex flex-col"> <div class="absolute -top-3 left-1/2 -translate-x-1/2 bg-indigo-500 text-white px-3 py-1 rounded-full text-xs font-bold uppercase tracking-wider">Tallest Content</div> <h3 class="text-xl font-bold mb-3 text-slate-800 dark:text-white pt-2">Featured Column</h3> <p class="text-slate-600 dark:text-slate-400 mb-6 flex-grow">This column contains the most content, which naturally expands its height. Thanks to the grid items-stretch property (which is default for grid rows), all other columns automatically expand to match this one's exact height, ensuring a perfectly aligned UI regardless of content length.</p> <button class="w-full bg-indigo-600 hover:bg-indigo-700 text-white py-2 rounded-lg font-medium transition-colors">Primary Action</button> </div> <div class="bg-white dark:bg-slate-800 p-6 rounded-xl shadow-md flex flex-col"> <h3 class="text-xl font-bold mb-3 text-slate-800 dark:text-white">Short Column</h3> <p class="text-slate-600 dark:text-slate-400 mb-6 flex-grow">Brief content.</p> <button class="w-full bg-slate-100 hover:bg-slate-200 dark:bg-slate-700 dark:hover:bg-slate-600 text-slate-800 dark:text-white py-2 rounded-lg font-medium transition-colors">Action</button> </div> </div> </div> </body> </html>