October DealsAmazon USOctober deal check: compare before you payAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix NowOctober DealsAmazon USDeal season is back - check today's better picksAmazon US: current deals, useful picks and tech finds.See Picks×
Skip to content
World desk8 min

CSS Website Layouts: Common Patterns and How to Build Them

Build practical website layouts with semantic HTML, CSS Grid for page structure, Flexbox for components, and content-led responsive breakpoints.
Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Build a website layout by starting with meaningful HTML and normal flow, then choosing the CSS tool that matches the relationship between elements: use Grid for rows-and-columns page structure, Flexbox for one-dimensional arrangements such as navigation, and positioning only when you intentionally need overlap or a fixed layer. The examples below combine those methods into a responsive page shell and card listing.

Start with meaningful HTML and normal flow

Normal flow is the browser’s default way of laying out content: block elements follow one another in the block direction, while inline content runs along a line and wraps as needed. It gives the document a useful reading order before any layout rules are added. MDN’s guidance is to begin with a well-structured document that remains readable in normal flow.

Use elements for their meaning, not just their default appearance. A page might have a <header>, a primary <nav>, a <main>, an optional <aside>, and a <footer>. Put the main content in a sensible order in the HTML; CSS can rearrange its visual placement without making that order harder to understand.

Choose Grid or Flexbox by the relationship you need

Need Good starting point Why
Coordinate regions across rows and columns, such as a header, sidebar, main area, and footer CSS Grid Grid is two-dimensional: you can define tracks in both rows and columns and place regions into them.
Arrange items along one direction, such as a horizontal navigation row or the contents of one card Flexbox Flexbox lays items out along a row or column and can distribute available space between them.
Let repeated items form as many columns as fit Grid with auto-placement Flexible track sizing lets the browser create a changing number of columns without assigning each item a position.
Layer an item over another or keep a control in a chosen viewport position Positioning, when intentional Positioned elements can leave normal flow, so surrounding content does not necessarily reserve their usual space.
Let text wrap beside an image or other item Float Floats are useful for text wrapping, rather than as a general-purpose multi-column page system.

Grid and Flexbox are complementary, not competing page-wide choices. A common arrangement is Grid for the page shell, Flexbox for the navigation inside the header, and Flexbox again for the internal content of each card.

Free tools Windows power users keep installed

One-click scans. No signup required.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
#1 Best Overall
Elebase USB to USB C Adapter for iPhone 18 Pro Max,USBC Car Charger Adapter
  • Read Before You Buy — No Video Output: These adapters support charging and USB 2.0 data transfer, but cannot transmit video signals. Except for standard USB webcams (which use USB data only), they are not compatible with HDMI/DisplayPort cables, video-capable USB-C hubs, or docking stations with video output.
  • Convert USB-A Ports to USB-C: Designed to connect USB-C earphones, cables, flash drives, card readers, and other USB-C accessories to standard USB-A ports. Plug-and-play with no drivers or software required.
  • Aluminum Alloy Housing: Built with a sturdy aluminum alloy shell that aids in heat dissipation and protects against daily wear and scratches. Designed to maintain a stable and secure connection.
  • Compact & Travel-Friendly: The ultra-compact design allows the adapter to stay plugged into your device without blocking adjacent ports or adding bulk, reducing wear and tear on your original USB ports.
  • 12-Month Warranty: Backed by a 12-month manufacturer warranty for peace of mind. Designed to meet strict quality control standards for reliable everyday performance.

Build a responsive page shell with named Grid areas

Named areas make a shell easier to reason about when the relationships among regions matter more than the individual items’ order in a row. Start with one column for narrow screens, then introduce a sidebar and more columns when the actual content fits comfortably.

<div class="site-layout">
  <header class="site-header">
    <a class="brand" href="/">Field Notes</a>
    <nav class="site-nav" aria-label="Primary">
      <a href="/articles/">Articles</a>
      <a href="/guides/">Guides</a>
      <a href="/about/">About</a>
    </nav>
  </header>
  <main class="site-main">
    <h1>Latest articles</h1>
    <p>Updates and practical guides.</p>
  </main>
  <aside class="site-sidebar">
    <h2>Topics</h2>
    <ul><li>Design</li><li>Development</li></ul>
  </aside>
  <footer class="site-footer">About this site</footer>
</div>
* {
  box-sizing: border-box;
}

.site-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr);
  grid-template-areas:
    "header"
    "main"
    "sidebar"
    "footer";
  gap: 1.5rem;
  max-width: 72rem;
  margin-inline: auto;
  padding: 1.25rem;
}

.site-header { grid-area: header; }
.site-main { grid-area: main; min-width: 0; }
.site-sidebar { grid-area: sidebar; }
.site-footer { grid-area: footer; }

.site-nav {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem 1.25rem;
}

@media (min-width: 52rem) {
  .site-layout {
    grid-template-columns: minmax(0, 2fr) minmax(14rem, 1fr);
    grid-template-areas:
      "header header"
      "main sidebar"
      "footer footer";
  }
}

@media (min-width: 72rem) {
  .site-layout { padding: 2rem; }
}

The first breakpoint is an example, not a universal device threshold. Check the rendered content: add the sidebar column at the width where the main text, sidebar, and gap can all remain readable. The minmax(0, 1fr) track helps the main column shrink within the grid rather than being forced wider by its contents.

Give navigation its own one-dimensional layout

The header can be a Grid area while its links are a Flexbox row. flex-wrap: wrap allows links to move onto another line if the available width is tight; gap controls spacing without adding margins to each link. If the brand and navigation need to sit at opposite ends, place them in a flex container:

Rank #2
Anker USB-C Hub, 5-in-1 USB Hub for Laptops, 4K HDMI Multiport Adapter
  • 5-in-1 USB-C Hub: Experience comprehensive connectivity featuring a Power Delivery input, two USB-A 2.0 ports, a USB-A 3.0 port, and an HDMI port. (Note: The USB-C power delivery input port is only for connecting an external wall charger to power your laptop and cannot power peripheral devices.)
  • 90W Pass-Through Charging: Achieve optimal charging with 90W pass-through power to your laptop, supported by a total input of 100W, with the hub reserving 10W for operational efficiency. (Note: Wall charger not included.)
  • Quick Data Transfers: Accelerate your productivity with rapid data transfers using a high-speed 5Gbps USB 3.0 port and two 480Mbps USB 2.0 ports.
  • 4K HDMI Display: Enhance your visual experience with a hub capable of delivering 4K resolution at 30Hz in both mirror and extend modes. Please note that this hub is compatible with MacBook (macOS 12 and newer), Windows 10 and 11, ChromeOS, and laptops equipped with DP Alt Mode and Power Delivery. Note: This device is not compatible with Linux.
  • What You Get: Anker USB-C Hub (5-in-1, 4K HDMI), welcome guide, 18-month warranty, and our friendly customer service.
.site-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
}

Make a card listing that adapts to available width

For repeated cards, use Grid auto-placement and a flexible minimum track size. The browser can then create as many columns as fit, rather than requiring a separate rule for every device size.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
<section class="card-grid" aria-label="Articles">
  <article class="card">
    <h2>A practical guide</h2>
    <p>A short description of the guide and what it helps you do.</p>
    <a href="/guides/practical/">Read the guide</a>
  </article>
  <article class="card">
    <h2>Another article</h2>
    <p>A second description with a similar content structure.</p>
    <a href="/articles/another/">Read the article</a>
  </article>
  <article class="card">
    <h2>A third item</h2>
    <p>Add more items; Grid will place them into available tracks.</p>
    <a href="/articles/third/">Read the article</a>
  </article>
</section>
.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(min(100%, 16rem), 1fr));
  gap: 1.25rem;
}

.card {
  display: flex;
  flex-direction: column;
  min-width: 0;
  padding: 1.25rem;
  border: 1px solid #cbd5e1;
  border-radius: 0.5rem;
}

.card a {
  align-self: flex-start;
  margin-top: auto;
}

repeat() and minmax() define repeating tracks with a minimum and flexible maximum. auto-fit allows the available tracks to expand into the grid’s space; auto-fill can be used when you want the grid to retain empty tracks rather than collapsing them. Each card is independently a Flexbox column, so margin-top: auto can push its link toward the bottom when cards in a row have differing text lengths.

How do I make a responsive CSS layout?

  1. Start with the narrow arrangement. Keep the shell in one column and make sure the source order reads naturally.
  2. Use flexible sizing before adding many breakpoints. Grid tracks using fractions and minimums, and Flexbox wrapping, can adapt across a range of widths.
  3. Inspect where the content stops fitting. Add a media query when a navigation row becomes awkward, a sidebar crowds the main column, or cards become too narrow to read.
  4. Change the structure only where it helps. At a suitable width, update grid-template-columns and grid-template-areas to introduce or reposition regions.
  5. Check the intermediate widths too. A layout that works at a narrow and a wide viewport can still have an uncomfortable range between them.

Responsive design is about adapting to available space and content fit, not matching a breakpoint to every named device. MDN’s responsive-design guidance recommends flexible layouts and content-led decisions.

Rank #3
Sale
Anker USB C Hub, 7in1 Multi-Port USB Adapter, 4K@60Hz USBC to HDMI Splitter
  • Sleek 7-in-1 USB-C Hub: Features an HDMI port, two USB-A 3.0 ports, and a USB-C data port, each providing 5Gbps transfer speeds. It also includes a USB-C PD input port for charging up to 100W and dual SD and TF card slots, all in a compact design.
  • Flawless 4K@60Hz Video with HDMI: Delivers exceptional clarity and smoothness with its 4K@60Hz HDMI port, making it ideal for high-definition presentations and entertainment. (Note: Only the HDMI port supports video projection; the USB-C port is for data transfer only.)
  • Double Up on Efficiency: The two USB-A 3.0 ports and a USB-C port support a fast 5Gbps data rate, significantly boosting your transfer speeds and improving productivity.
  • Fast and Reliable 85W Charging: Offers high-capacity, speedy charging for laptops up to 85W, so you spend less time tethered to an outlet and more time being productive.
  • What You Get: Anker USB-C Hub (7-in-1), welcome guide, 18-month warranty, and our friendly customer service.

When should positioning or floats be used?

Position for deliberate overlap or viewport placement

Positioning is appropriate for cases such as a badge placed over an image or a control deliberately fixed to a viewport edge. An absolutely positioned box is taken out of normal flow; the surrounding layout does not automatically leave a slot for it. Fixed positioning also places an element relative to the viewport in common use, so consider whether it can obscure content, especially on a narrow screen. Use Grid or Flexbox for the surrounding page structure instead of using absolute coordinates to build its columns.

Float for text wrapping

A floated image can let article text flow beside it. This is different from placing a sidebar beside the main page content: use Grid or Flexbox for that larger structural relationship. Floats alter how inline content wraps, so keep their use tied to that wrapping behavior.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Troubleshoot common layout problems

  • A grid column refuses to shrink. A long word, URL, or other wide child may establish a larger minimum size. Try minmax(0, 1fr) for the track and min-width: 0 on the grid child; also check whether the content itself needs wrapping or overflow handling.
  • Cards are too narrow or too wide. Adjust the minimum track size in minmax() to reflect the content’s needs, then inspect the available container width. Do not choose a breakpoint solely because a device model has a particular screen size.
  • Navigation spills off the screen. Allow the flex container to wrap, reduce excessive gaps, or change its arrangement when the content no longer fits on one line.
  • Grid areas do not line up. Check that every name used in grid-template-areas corresponds to an element assigned with grid-area, and that each row in the template has the same number of columns.
  • An overlapping element covers important content. Remember that an out-of-flow element does not reserve its normal space. Add room in the layout or choose an in-flow solution if the overlap is not essential.
  • A card link is not aligned consistently. Make the card a flex column and use an auto top margin on the link, rather than forcing a fixed card height that may clip longer text.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Performance, reliability, and maintainability

Grid and Flexbox are layout systems, not a promise of a particular speed advantage. The guidance here supports choosing by dimensional relationship and content behavior; it does not establish that one method is universally faster. For maintainability, keep the page shell’s Grid rules together, use Flexbox for local arrangements, and make each media query solve a visible fit problem. Test with the content that will actually appear, including long headings and variable-length descriptions.

Rank #4
Sale
UGREEN USB to USB C Adapter Combo 4-Pack, 10Gbps USB C Converter Space Gray
  • Dual Converters, Infinite Potential:Includes 2× USB C male to USB A female adapters and 2× USB A male to USB C female adapters. Perfect for a wide range of uses—tablets with Bluetooth keyboards, expand USB ports on macbook, and more. Two different converters for all your daily needs
  • Next-Level 10Gbps & 3A Charging: No more slow 480Mbps, this usb to usb c adapter has a transfer speed of up to 10Gbps, allowing you to do more transferring in less time. This usb adapter fits both USB A and USB C charger, supporting up to 3A fast charging
  • Upgraded Exquisite Craftsmanship: With an aluminum alloy housing and metal connector, the usbc to usb adapter is extremely durable and sturdy. Rigorously tested to withstand more than 10,000 times of plugging and unplugging, ensuring long-lasting performance
  • Broad Compatible: The usb c to usb adapter widely supports all USB C/ USB A devices like laptops, tablets, cellphones, car chargers, and phone chargers. Such as compatible with MacBook Pro/Air 2023/2022, Thunderbolt 4/3 Devices,Apple MagSafe Watch 9/8/7/SE/Ultra, iPad Pro 2022/2021, Samsung Galaxy S23/S20/S10, and iPhone 17/16/15 Pro. Plug and play
  • Please Note: To reach 10Gbps speed, keep the cable under 3.3 ft. For USB A Male to USB C adapters, try flipping the USB C connector. USB C Male to USB A adapters support bidirectional 10Gbps transfer within 3.3 ft

For a rendered check of a page you have built, ScreenshotNeo is a website screenshot API and MCP server. A screenshot can help inspect how a layout appears at a chosen viewport; it does not replace checking the page’s reading order or behavior directly.

Or skip the browser setup

To request a screenshot of a page you can access, make one GET request. The following cURL example saves a WebP image; the API also supports PNG, JPEG, or PDF output. See the ScreenshotNeo API documentation for request options.

curl -G "https://api.screenshotneo.com/v1/shot" -d access_key=YOUR_API_KEY --data-urlencode url=https://stripe.com -o shot.webp

ScreenshotNeo accepts cookie or consent banners like a visitor and removes more than 60 known consent platforms, newsletter popups, and chat widgets before capture; each of those steps can be turned off. Bot checks and CAPTCHAs, blank pages, timeouts, failed loads, and cache hits cost nothing, and response headers identify the page verdict and billing status. Its MCP server provides take_screenshot, get_page_info, and capture_pdf tools for AI agents and MCP clients. The free plan includes 1,000 shots per month with no card; paid plans start at $5 for 3,000 shots.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Sign up free for 1,000 screenshots a month with no card.

Best Value
Anker USB C Hub, 5-in-1 USBC to HDMI Splitter with 4K Display
  • 5-in-1 Connectivity: Equipped with a 4K HDMI port, a 5 Gbps USB-C data port, two 5 Gbps USB-A ports, and a USB C 100W PD-IN port. Note: The USB C 100W PD-IN port supports only charging and does not support data transfer devices such as headphones or speakers.
  • Powerful Pass-Through Charging: Supports up to 85W pass-through charging so you can power up your laptop while you use the hub. Note: Pass-through charging requires a charger (not included). Note: To achieve full power for iPad, we recommend using a 45W wall charger.
  • Transfer Files in Seconds: Move files to and from your laptop at speeds of up to 5 Gbps via the USB-C and USB-A data ports. Note: The USB C 5Gbps Data port does not support video output.
  • HD Display: Connect to the HDMI port to stream or mirror content to an external monitor in resolutions of up to 4K@30Hz. Note: The USB-C ports do not support video output.
  • What You Get: Anker 332 USB-C Hub (5-in-1), welcome guide, our worry-free 18-month warranty, and friendly customer service.

Frequently Asked Questions

Can I use Grid and Flexbox in the same component?

Yes. For example, Grid can place the page regions while Flexbox arranges the header links or the contents within each card.

Should every responsive layout have several breakpoints?

No. Add a breakpoint when the content no longer fits well; flexible tracks and wrapping may handle other widths without one.

Are floats obsolete?

Floats still suit text wrapping around an item, such as an image in an article. They are not the usual choice for a site-wide column layout.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

More from the Wire

  1. Shenzhen desk3 min
    HONOR Expands Beyond Smartphones With Humanoid Robot RevealHONOR said it unveiled its first humanoid robot at MWC 2026 and named shopping assistance, workplace inspections, and supportive companionship as intended uses. Later Robotics D1 claims and a reported…
  2. Cupertino desk5 min
    Apple Unveils AirPods Max 2: The Upgrade That Should Have Happened Years AgoAirPods Max 2 adds H2-powered audio features and Apple claims up to 1.5× more effective ANC, but its design, Smart Case, and 20-hour battery rating are unchanged. Wired lossless audio…
  3. Cupertino desk4 min
    Apple’s OLED Touch MacBooks Are Coming—but the Dynamic Island Is the Real GambleApple has not announced an OLED touchscreen MacBook, but reports point to high-end models arriving in late 2026 or early 2027. The reported Mac Dynamic Island could be useful, but…
Recommended PC Tool
Recommended PC Tool
Outdated Drivers Are Slowing You DownFree scan - exact matches
Windows Errors? Fix Them Before They SpreadFree repair scan

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.