The independent file on technology, travel & lifeFrom Pakistan, for everywhere
Huzi Blogs.
The ArchiveSectionsSearch

Planning a trip? HTG Travels — flights, visas, hotels & Umrah, handled properly.

WhatsApp +92 317 5054959
Huzi Blogs.

An independent file on technology, travel and life — long-form guides written plainly, from Pakistan, for everywhere.

ShopMeet the Creator

Sections

  • Travel
  • Technology
  • Lifestyle
  • Programming
  • Sports
  • Linux
  • All sections

The Desk

  • The Archive
  • Search the file
  • Disclaimer & Data Privacy Policy
  • A project of huzi.pk

© 2026 blogs.huzi.pk — All rights reserved.

Set in Playfair Display & Inter

    HomeCSSStory
    CSS

    CSS Grid vs. Flexbox: Which One Should You Use in 2026?

    H

    By Huzi

    File #112 · 3 min read

    Juniors rarely ask how Grid or Flexbox works — the docs cover that. They ask which one to reach for right now, on this component. That decision is the entire subject of this post, and it comes down to one honest question.

    The quick answer: A line of items negotiating space between them is Flexbox; a structure of rows and columns drawn before the content arrives is Grid. Mature codebases use both at once — grid for the skeleton, flex for the life inside each cell.

    One dimension or two?

    Sketch the layout. If it is a line of items negotiating space between them — a row of links, a stack of buttons — that is Flexbox. If it is a structure of rows and columns that exists before the content arrives — a page shell, a dashboard, a gallery with a featured tile — that is Grid.

    Flexbox is content-first: the items' sizes shape the layout. Grid is layout-first: you draw the tracks, the items fill them.

    Choose Flexbox when the content should decide

    Navbars, toolbars, chip rows, card headers — anywhere a few items should share space gracefully:

    .toolbar {
      display: flex;
      align-items: center;
      gap: var(--space-2);
      justify-content: space-between;
    }
    

    If the answer to "who decides the width?" is "the content", flex is the honest tool.

    Pro tip: Sketch the layout on paper before writing a line of CSS — if you can name the regions, Grid should hold the pen; if the items must negotiate space, stay with flex.

    Choose Grid when the structure should decide

    The moment you can name the regions, name them in the CSS:

    .gallery {
      display: grid;
      grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
      gap: var(--space-2);
    }
    
    .tile-featured {
      grid-column: span 2;
      grid-row: span 2;
    }
    

    One declaration gives a responsive grid with no media queries; one rule promotes the featured tile without touching the markup. And when cards inside the grid must align their internals — title, price, button — subgrid lets them inherit the parent's tracks, which is a Grid answer to a Grid problem.

    Layout thinking travels well, too: plans re-flow on the road the way layouts re-flow at a breakpoint — one delayed flight re-arranging the whole week. We draft itineraries with that slack at HTG Travel.

    The tie-breakers

    Content-driven or structure-driven: the primary question, always. When the sketch leaves you genuinely undecided, break the tie:

    The use case The honest tool
    Navbar, toolbar, chip row, card header Flexbox — the content decides the widths
    Page shell, dashboard, gallery with a featured tile Grid — the structure exists first
    Unknown item count, like a tag list Flexbox, wrapping happily without a plan
    An element pinned to a specific cell Grid — only grid places by coordinates
    Alignment across many items on both axes Grid, with subgrid for the nested cases

    Together, not versus

    The working pattern on every mature codebase: grid draws the page skeleton, flex arranges the life inside each cell. A two-dimensional decision, followed by one-dimensional details.

    Structure should serve the people living inside it — Palestine's oldest structures, the family, the terrace and the town square, have outlasted every plan drawn over their heads. Sudan's families redraw their arrangements after every flight — structure that bends without breaking; may theirs hold still at last.

    We draft itineraries the same way: days as rows, options as columns, one couple's honeymoon gridded and another family's trip flexed. Give HTG Travel the shape of your journey — dates, budget, must-sees — and we place every element where it belongs. Ring or message +92 317 5054959 when standup ends and wanderlust begins.

    Presented by

    HTG Travels — Plan the Trip, Skip the Runaround

    Flights, visas, Umrah packages and Hunza–Skardu tours, handled end to end from our licensed Sialkot desk. Real fares, hotel names in writing, and a human who answers — before you pay a rupee.

    Flights & rebooking Visa files Umrah 2026–27 Northern tours
    Visit huzi.pkWhatsApp +92 317 5054959

    Sialkot, Pakistan · Licensed agency · Fast quotes on WhatsApp


    You Might Also Like

    Rechargeable Lint Remover – 6-Blade Fabric Shaver, USB-C, 60 min Run

    Rechargeable Lint Remover – 6-Blade Fabric Shaver, USB-C, 60 min Run

    PKR 2270

    Unstitched 3-Piece Embroidered Lawn Suit | Sunflower Print, Digital Silk Dupatta (EID Collection)

    Unstitched 3-Piece Embroidered Lawn Suit | Sunflower Print, Digital Silk Dupatta (EID Collection)

    PKR 3800

    All-Over Print Embroidered EID Lawn Suit 3-Pc | Heavy Sleeves Patches & Chiffon Dupatta (2025)

    All-Over Print Embroidered EID Lawn Suit 3-Pc | Heavy Sleeves Patches & Chiffon Dupatta (2025)

    PKR 4800

    Digital Floral Print 2-Piece Lawn Suit | Unstitched Casual Shirt & Trouser (Summer)

    Digital Floral Print 2-Piece Lawn Suit | Unstitched Casual Shirt & Trouser (Summer)

    PKR 2700

    90/70 Quality Schiffli Embroidered Lawn Suit 3-Pc | 4-Side Border Chiffon Dupatta (2025)

    90/70 Quality Schiffli Embroidered Lawn Suit 3-Pc | 4-Side Border Chiffon Dupatta (2025)

    PKR 4950

    Keep reading

    Related files

    CSS
    English

    A Practical Guide to CSS Variables and @property in 2026

    A working order for theming real projects with custom properties: raw tokens under semantic names, subtree overrides, light-dark() for dark mode that respects the OS, and @property for animatable gradients — plus the fallback habit that saves layouts.

    By HuziFile #113

    Read
    CSS
    English

    5 Common CSS Mistakes and How to Fix Them in 2026

    The five CSS bugs waiting in every code review — !important wars, magic numbers, selector arms races, missing resets, page-level-only responsiveness — and the modern fix for each: cascade layers, spacing scales, flat selectors, and container queries.

    By HuziFile #100

    Read
    Programming
    English

    Mastering Modern Layouts: A Deep Dive into CSS Flexbox and Grid (2026)

    Flexbox distributes along one axis, Grid draws two dimensions, Subgrid aligns card contents, and one auto-fit line builds responsive grids with no media queries at all.

    By HuziFile #111

    Read
    Travel
    English

    Which Pakistani Airport Should Your Family Fly Umrah From (2026-2027)

    Pakistani families often spend weeks choosing the hotel and minutes choosing the airport — accepting whatever city the default package quotes from. The direct-flight map of 2026-2027 says that is backwards. AirSial now flies Sialkot to Jeddah nonstop roughly six days a week on A320s, with PIA operating its own Sialkot–Jeddah nonstops alongside; PIA announced twenty-eight additional weekly flights to Saudi Arabia for the autumn 2026 season, beginning from Lahore and Islamabad; flyadeal launched twice-weekly Madinah–Karachi flights; Saudia and PIA carry the Jeddah and Madinah load from the big metros; and Peshawar and Multan hold their own Saudi connections, with Peshawar–Madinah routings priced in the market. The decision this file builds: the nearest airport with a nonstop beats a distant hub with a stopover for a family of five with suitcases and a grandmother, unless the fare gap pays for the drive twice over. It walks the drive-or-fly arithmetic — motorway hours, tolls, a hotel near the hub and a 3 AM check-in against the fare difference multiplied by every seat — the open-jaw logic of entering at Jeddah and leaving from Madinah, and the booking-window discipline that makes any of it affordable. Yeh faisla sirf ticket ka nahi hai — yeh faisla poore safar ka hai.

    By HuziFile #871

    Read
    Travel
    English

    Which Floor for Tawaf? (2026–2027): The Levels File — Ground Mataf, First and Second Floors, and the Roof

    The question every pilgrim asks at the Haram gate is not 'how do I do tawaf' — it is 'which floor do I do it on,' and the wrong answer in peak season costs an hour of shoving and a lost count. The levels file: the ground Mataf's closeness and its crowd truth, the first and second floors where wheelchair and electric-cart tawaf is actually designated (the carts are barred from the Mataf courtyard itself), the roof's space and its sightline trade-off, the ramps and wide lifts that connect every level, and the match of level to pilgrim — energy, mobility, count discipline, and the group that cannot agree and splits on purpose.

    By HuziFile #1183

    Read
    Technology
    English

    Samsung Galaxy S25 Ultra vs iPhone 16 Pro Max — Which Should You Buy in Pakistan?

    Rupee prices for both flagships, PTA-approved versus gray-market math, the camera and battery verdicts, and which one still commands a price on Hall Road a year later.

    By HuziFile #351

    Read
    Back to the archive