Skip to content
Learn Measure Blog Case studies About
  • Home
  • All patterns
  • Layout patterns

Content Center

Jun 1, 2022

A centering technique that is only a few lines of CSS, works great for many elements, but has the side effect of making children match the width of the widest element.

See the full article for many more details about this technique and when it's efficient.

Full article · Video on YouTube · Source on Github

<article class="content-center">
  <h1>Content Center</h1>
</article>
.content-center {
  display: grid;
  place-content: center;
  gap: 1ch;
}
Open demo
Last updated: Jun 1, 2022 — Improve article
Share
subscribe

Contribute

  • File a bug
  • View source

Related content

  • developer.chrome.com
  • Chrome updates
  • Web Fundamentals
  • Case studies
  • Podcasts
  • Shows

Connect

  • Twitter
  • YouTube
  • Google Developers
  • Chrome
  • Firebase
  • Google Cloud Platform
  • All products
  • Terms & Privacy
  • Community Guidelines

Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies.