Tillitsdone
down Scroll to discover

CSS place-content Simplify Alignment in Flexbox and Grid

Learn how to use the CSS place-content property to align items in Flexbox and Grid layouts.

Explore available options like center, start, end, and distribute space.
thumbnail

Syntax

The place-content CSS property simplifies aligning content both vertically (block direction) and horizontally (inline direction). Its syntax is straightforward:

place-content: <align-content> <justify-content>;
  • <align-content>: Sets the vertical alignment.
  • <justify-content>: Sets the horizontal alignment.

Example Usage

/* Positional alignment */
place-content: center start;
place-content: start center;
place-content: end left;
place-content: flex-start center;
place-content: flex-end center;
/* Baseline alignment */
place-content: baseline center;
place-content: first baseline space-evenly;
place-content: last baseline right;
/* Distributed alignment */
place-content: space-between space-evenly;
place-content: space-around space-evenly;
place-content: space-evenly stretch;
place-content: stretch space-evenly;
/* Global values */
place-content: inherit;
place-content: initial;
place-content: revert;
place-content: revert-layer;
place-content: unset;

Values

The place-content property accepts various values, which can be categorized into positional alignment, baseline alignment, distributed alignment, and global values.

Positional Alignment Values

  • start: Aligns items to the start of the container.
  • end: Aligns items to the end of the container.
  • flex-start: Aligns items to the start of the flex container.
  • flex-end: Aligns items to the end of the flex container.
  • center: Centers items within the container.
  • left: Aligns items to the left edge of the container.
  • right: Aligns items to the right edge of the container.

Baseline Alignment Values

  • baseline: Aligns items based on their first or last baseline.
  • first baseline: Aligns items to the first baseline of the container.
  • last baseline: Aligns items to the last baseline of the container.

Distributed Alignment Values

  • space-between: Distributes items evenly with equal space between them.
  • space-around: Distributes items evenly with half-sized spaces at the edges.
  • space-evenly: Distributes items evenly with equal space between them and at the edges.
  • stretch: Stretches items to fill the container, respecting max-height and max-width constraints.

Global Values

  • inherit: Inherits the value from the parent element.
  • initial: Sets the value to its initial default.
  • revert: Reverts the value to the user-agent default.
  • revert-layer: Reverts the value to the user-agent default for the specific layer.
  • unset: Resets the value to its inherited value if it is inheritable, or to its initial value if not.

Formal Definition

PropertyValue
Initial valuealign-content: normal, justify-content: normal
Applies toMulti-line flex containers
InheritedNo
Computed valueAs specified for each constituent property
Animation typeDiscrete

Formal Syntax

place-content = <align-content> [<justify-content>]?

Where:

  • <align-content> can be any valid value for the align-content property.
  • <justify-content> can be any valid value for the justify-content property.

Constituent Properties

The place-content property is a shorthand for:

  • [align-content]WebsiteUrl
  • [justify-content]WebsiteUrl

Examples

Positional Alignment

place-content: center start;
place-content: start center;
place-content: end left;
place-content: flex-start center;
place-content: flex-end center;

Baseline Alignment

place-content: baseline center;
place-content: first baseline space-evenly;
place-content: last baseline right;

Distributed Alignment

place-content: space-between space-evenly;
place-content: space-around space-evenly;
place-content: space-evenly stretch;
place-content: stretch space-evenly;

Global Values

place-content: inherit;
place-content: initial;
place-content: revert;
place-content: revert-layer;
place-content: unset;

Important Notes

  • The first value corresponds to the align-content property, and the second value corresponds to the justify-content property.
  • If only one value is provided, it will be used for both align-content and justify-content, provided it is valid for both properties. If the value is not valid for either property, the entire value will be invalid.

Example Usage

HTML

<div id="container">
<div class="small">Lorem</div>
<div class="small">Lorem<br />ipsum</div>
<div class="large">Lorem</div>
<div class="large">Lorem<br />ipsum</div>
<div class="large"></div>
<div class="large"></div>
</div>

CSS

#container {
display: flex;
height: 240px;
width: 240px;
flex-wrap: wrap;
background-color: #8c8c8c;
place-content: flex-end center; /* Adjust this value to see different alignments */
}
div > div {
border: 2px solid #8c8c8c;
width: 50px;
background-color: #a0c8ff;
}
.small {
font-size: 12px;
height: 40px;
}
.large {
font-size: 14px;
height: 50px;
}

Example 1: Flex-Start Center

Using place-content: flex-start center; to align content.

HTML

<!DOCTYPE html>
<html>
<head>
<title>CSS place-content Property</title>
<style>
h1 {
color: green;
}
#container {
display: flex;
height: 200px;
width: 460px;
flex-wrap: wrap;
background-color: gray;
place-content: flex-start center;
}
div > div {
border: 2px solid black;
width: 60px;
background-color: green;
color: white;
}
.short {
font-size: 12px;
height: 30px;
}
.tall {
font-size: 14px;
height: 40px;
}
</style>
</head>
<body>
<center>
<h1>Website</h1>
<b>CSS place-content Property</b>
<div id="container">
<div class="short">Geeks</div>
<div class="short">Computer<br />Science</div>
<div class="tall">Geeks<br />for</div>
<div class="tall">Portal<br />for</div>
<div class="tall"></div>
</div>
</center>
</body>
</html>

Example 2: Flex-Start Start

Using place-content: flex-start start; to align content.

HTML

<!DOCTYPE html>
<html>
<head>
<title>CSS place-content Property</title>
<style>
h1 {
color: green;
}
#container {
display: flex;
height: 100px;
width: 460px;
flex-wrap: wrap;
background-color: gray;
place-content: flex-start start;
}
div > div {
border: 2px solid black;
width: 60px;
background-color: green;
color: white;
}
.short {
font-size: 12px;
height: 30px;
}
.tall {
font-size: 14px;
height: 40px;
}
</style>
</head>
<body>
<center>
<h1>Website</h1>
<b>CSS place-content Property</b>
<div id="container">
<div class="short">Geeks</div>
<div class="short">Computer<br />Science</div>
<div class="tall">Geeks<br />for</div>
<div class="tall">Portal<br />for</div>
<div class="tall"></div>
</div>
</center>
</body>
</html>

Example 3: Flex-End End

Using place-content: flex-end end; to align content.

HTML

<!DOCTYPE html>
<html>
<head>
<title>CSS place-content Property</title>
<style>
h1 {
color: green;
}
#container {
display: flex;
height: 100px;
width: 460px;
flex-wrap: wrap;
background-color: gray;
place-content: flex-end end;
}
div > div {
border: 2px solid black;
width: 60px;
background-color: green;
color: white;
}
.short {
font-size: 12px;
height: 30px;
}
.tall {
font-size: 14px;
height: 40px;
}
</style>
</head>
<body>
<center>
<h1>Website</h1>
<b>CSS place-content Property</b>
<div id="container">
<div class="short">Geeks</div>
<div class="short">Computer<br />Science</div>
<div class="tall">Geeks<br />for</div>
<div class="tall">Portal<br />for</div>
<div class="tall"></div>
</div>
</center>
</body>
</html>

Browser Compatibility

The place-content property is widely supported across modern web browsers. Here’s a quick summary:

BrowserVersion
Google Chrome59+
Microsoft Edge79+
Mozilla Firefox45+
Opera46+
Safari9+

Using the place-content Property

Before using the place-content property, make sure to test your website across different browsers to ensure consistent behavior. Although most modern browsers support it, some older ones might not. In those cases, you might need to provide fallbacks or alternative solutions.

Conclusion

The place-content property is a powerful tool for aligning content within a container, making it essential for modern web development. Its wide browser support ensures you can use it confidently in your projects, creating well-structured and visually appealing layouts that work seamlessly across different devices and platforms.

For more detailed information on browser compatibility, you can refer to MDN Web Docs or Can I Use.

See Also

To enhance your understanding and usage of the place-content property, you might find the following related resources and properties helpful:

  • [align-content]WebsiteUrl: Specifies how lines inside a flexible container are aligned when items don’t use all the available space.
  • [justify-content]WebsiteUrl: Defines how the browser distributes space between and around content items along the inline direction.
  • [Basic concepts of flexbox]WebsiteUrl: A comprehensive guide on the fundamentals of flexbox, essential for understanding how the place-content property works within this layout system.
  • [Aligning items in a flex container]WebsiteUrl: Detailed information on how to align items within a flex container using various CSS properties, including place-content.
  • [Box alignment in CSS grid layouts]WebsiteUrl: An in-depth look at how to align boxes within a grid layout, another context where the place-content property can be applied.
  • [CSS box alignment module]WebsiteUrl: A module dedicated to the alignment of boxes in CSS, which includes properties like place-content.

These resources provide a deeper dive into the concepts and practices related to the place-content property, helping you make the most of this powerful CSS tool in your web development and design projects. By understanding the related properties and concepts, you can create more dynamic, responsive, and visually appealing web designs.

icons/logo-tid.svg Latest Blogs
Discover our top articles, selected to support the growth of your business.
https://imgproxy-landing-page.tillitsdone.com/sig/rs:fit:1200:630/plain/https%3A%2F%2Fcms-r2.tillitsdone.com%2Fwp-content-prod%2Fuploads%2F2025%2F07%2FTill-its-done_SEO_R18_June_1440x697.jpg@webp Web Developers āļ„āļ·āļ­āļ­āļ°āđ„āļĢ? āļŠāļģāļ„āļąāļāđāļ„āđˆāđ„āļŦāļ™ Web Developer āļ„āļ·āļ­āļ­āļēāļŠāļĩāļžāļ—āļĩāđˆāļĄāļĩāļ—āļąāļāļĐāļ°āļ”āđ‰āļēāļ™āđ‚āļ›āļĢāđāļāļĢāļĄāļĄāļīāđˆāļ‡ āđāļĨāļ°āļĄāļĩāļāļēāļĢāđ€āļĢāļĩāļĒāļ™āļĢāļđāđ‰āđƒāļ™āđ€āļ—āļ„āđ‚āļ™āđ‚āļĨāļĒāļĩāđƒāļŦāļĄāđˆ āđ† āđ€āļžāļ·āđˆāļ­āļžāļąāļ’āļ™āļēāļ‡āļēāļ™āļ­āļĒāđˆāļēāļ‡āļ•āđˆāļ­āđ€āļ™āļ·āđˆāļ­āļ‡ āđāļĨāļ°āļĄāļĩāļ„āļ§āļēāļĄāļŠāļģāļ„āļąāļāļāļąāļšāļ˜āļļāļĢāļāļīāļˆāđƒāļ™āļĒāļļāļ„āļ”āļīāļˆāļīāļ•āļąāļĨāđāļšāļšāļ™āļĩāđ‰āđ€āļ›āđ‡āļ™āļ­āļĒāđˆāļēāļ‡āļĄāļēāļ https://imgproxy-landing-page.tillitsdone.com/sig/rs:fit:1200:630/plain/https%3A%2F%2Fcms-r2.tillitsdone.com%2Fwp-content-prod%2Fuploads%2F2025%2F07%2FTill-its-done_SEO_R16_June_1440x697-1.jpg@webp āļˆāļļāļ”āđ€āļ”āđˆāļ™āļ‚āļ­āļ‡ React JS āļ„āļ·āļ­ āļ”āļĩāļĒāļąāļ‡āđ„āļ‡āļāļąāļšāļāļēāļĢāļ—āļģ Mobile App React JS āđ€āļ›āđ‡āļ™āđ„āļĨāļšāļĢāļēāļĢāļĩāļ—āļĩāđˆāļŠāļ™āļąāļšāļŠāļ™āļļāļ™āļāļēāļĢāļžāļąāļ’āļ™āļēāđāļ­āļ›āļžāļĨāļīāđ€āļ„āļŠāļąāļ™āđāļšāļš Single Page āļžāļĢāđ‰āļ­āļĄāļĢāļ­āļ‡āļĢāļąāļšāļāļēāļĢāļŠāļĢāđ‰āļēāļ‡āđāļ­āļ›āļšāļ™āļĄāļ·āļ­āļ–āļ·āļ­āļ”āđ‰āļ§āļĒ React Native āđāļ•āđˆāļ—āļģāļ­āļĒāđˆāļēāļ‡āđ„āļĢ āļĄāļēāļ”āļđāļāļąāļ™āļ„āļĢāļąāļš https://imgproxy-landing-page.tillitsdone.com/sig/rs:fit:1200:630/plain/https%3A%2F%2Fcms-r2.tillitsdone.com%2Fwp-content-prod%2Fuploads%2F2025%2F06%2FTill-its-done_SEO_R14_may_1440x697.jpg@webp Flutter āļ„āļ·āļ­āļ­āļ°āđ„āļĢ āļŸāļĢāļĩāļĄāļąāđ‰āļĒ āļāļēāļĢāļžāļąāļ’āļ™āļēāđāļ­āļ›āļžāļĨāļīāđ€āļ„āļŠāļąāļ™āđƒāļ™āļĒāļļāļ„āļ”āļīāļˆāļīāļ—āļąāļĨāļ™āļĩāđ‰ Flutter āđ„āļ”āđ‰āļāļĨāļēāļĒāđ€āļ›āđ‡āļ™āļŦāļ™āļķāđˆāļ‡āđƒāļ™āđ€āļ„āļĢāļ·āđˆāļ­āļ‡āļĄāļ·āļ­āļ—āļĩāđˆāđ„āļ”āđ‰āļĢāļąāļšāļ„āļ§āļēāļĄāļ™āļīāļĒāļĄāļ­āļĒāđˆāļēāļ‡āļĄāļēāļāđƒāļ™āļ§āļ‡āļāļēāļĢ āđāļĨāđ‰āļ§ Flutter āļ„āļ·āļ­āļ­āļ°āđ„āļĢ āđāļĨāđ‰āļ§āđƒāļŠāđ‰āļ‡āļēāļ™āļŸāļĢāļĩāļŦāļĢāļ·āļ­āđ„āļĄāđˆ? https://imgproxy-landing-page.tillitsdone.com/sig/rs:fit:1200:630/plain/https%3A%2F%2Fcms-r2.tillitsdone.com%2Fwp-content-prod%2Fuploads%2F2025%2F06%2FTill-its-done_SEO_R12_may_1440x697.jpg@webp āļ­āļĒāļēāļāļŠāļĢāđ‰āļēāļ‡ Mobile App āļˆāļ°āđ€āļĨāļ·āļ­āļāđƒāļŠāđ‰āđ‚āļ›āļĢāđāļāļĢāļĄāđ€āļ‚āļĩāļĒāļ™ Mobile App āļāļēāļĢāđ€āļĨāļ·āļ­āļāđ‚āļ›āļĢāđāļāļĢāļĄāđ€āļ‚āļĩāļĒāļ™ Mobile App āļĄāļĩāđ€āļ„āļĢāļ·āđˆāļ­āļ‡āļĄāļ·āļ­āļāļąāļšāļ āļēāļĐāļēāļ­āļ°āđ„āļĢāđƒāļŦāđ‰āđ€āļĨāļ·āļ­āļāđƒāļŠāđ‰āļ‡āļēāļ™āļāļąāļ™āļĄāļēāļāļĄāļēāļĒ āļ„āļ§āļĢāļžāļīāļˆāļēāļĢāļ“āļēāļ­āļĒāđˆāļēāļ‡āđ„āļĢāđ€āļžāļ·āđˆāļ­āđƒāļŦāđ‰āļĄāļĩāļ›āļĢāļ°āļŠāļīāļ—āļ˜āļīāļ āļēāļžāđāļĨāļ°āļ•āļĢāļ‡āļ•āļēāļĄāļ„āļ§āļēāļĄāļ•āđ‰āļ­āļ‡āļāļēāļĢāļ‚āļ­āļ‡āđ‚āļ›āļĢāđ€āļˆāļāļ•āđŒ https://imgproxy-landing-page.tillitsdone.com/sig/rs:fit:1200:630/plain/https%3A%2F%2Fcms-r2.tillitsdone.com%2Fwp-content-prod%2Fuploads%2F2025%2F06%2FTill-its-done_SEO_R11_may_1440x697.jpg@webp Next.js āļ„āļ·āļ­āļ­āļ°āđ„āļĢ? āļĄāļēāđ€āļĢāļīāđˆāļĄāđ€āļ‚āļĩāļĒāļ™āđ€āļ§āđ‡āļšāļ”āđ‰āļ§āļĒ Next.js āļāļąāļ™āļ”āļĩāļāļ§āđˆāļē Next.js āđ€āļ›āđ‡āļ™ Framework āļŠāļģāļŦāļĢāļąāļšāļŠāļĢāđ‰āļēāļ‡āđ€āļ§āđ‡āļšāđ„āļ‹āļ•āđŒāļ”āđ‰āļ§āļĒ React āļ—āļĩāđˆāļŠāđˆāļ§āļĒāđƒāļŦāđ‰āļŠāļēāļĄāļēāļĢāļ–āļŠāļĢāđ‰āļēāļ‡āđ€āļ§āđ‡āļšāđ„āļ‹āļ•āđŒāļ—āļĩāđˆāļĄāļĩāļ›āļĢāļ°āļŠāļīāļ—āļ˜āļīāļ āļēāļžāđāļĨāļ°āđƒāļŠāđ‰āļ‡āļēāļ™āđ„āļ”āđ‰āļˆāļĢāļīāļ‡ āđāļĨāļ°āļĢāļ­āļ‡āļĢāļąāļš SEO āđ„āļ”āđ‰āļ”āļĩāļ‚āļķāđ‰āļ™āļ­āļĩāļāļ”āđ‰āļ§āļĒ https://imgproxy-landing-page.tillitsdone.com/sig/rs:fit:1200:630/plain/https%3A%2F%2Fcms-r2.tillitsdone.com%2Fwp-content-prod%2Fuploads%2F2025%2F05%2FTill-its-done_SEO_R08_apr_1440x697.jpg@webp āļĢāļđāđ‰āļˆāļąāļāļāļąāļš āļšāļĢāļīāļĐāļąāļ— Software House āļ„āļ·āļ­āļ­āļ°āđ„āļĢ āļ—āļģāļ­āļ°āđ„āļĢāļšāđ‰āļēāļ‡ Software House āļ„āļ·āļ­āļĻāļđāļ™āļĒāđŒāļšāļĢāļīāļāļēāļĢāļ—āļĩāđˆāļ„āļĢāļšāļ§āļ‡āļˆāļĢāđƒāļ™āļāļēāļĢāļžāļąāļ’āļ™āļēāđ€āļ—āļ„āđ‚āļ™āđ‚āļĨāļĒāļĩ āļŠāđˆāļ§āļĒāļŠāļ™āļąāļšāļŠāļ™āļļāļ™āļ˜āļļāļĢāļāļīāļˆāđƒāļ™āļĒāļļāļ„ 4.0 āđāļĨāļ°āļŠāļĢāđ‰āļēāļ‡āđ‚āļ­āļāļēāļŠāđƒāļŦāļĄāđˆ āđ† āđƒāļ™āļ•āļĨāļēāļ”āļāļēāļĢāđāļ‚āđˆāļ‡āļ‚āļąāļ™āļ—āļĩāđˆāļĄāļĩāļāļēāļĢāđ€āļ›āļĨāļĩāđˆāļĒāļ™āđāļ›āļĨāļ‡āļ­āļĒāđˆāļēāļ‡āļĢāļ§āļ”āđ€āļĢāđ‡āļ§
icons/logo-tid.svg

Talk with CEO

Ready to bring your web/app to life or boost your team with expert Thai developers?
Contact us today to discuss your needs, and let’s create tailored solutions to achieve your goals. We’re here to help at every step!
🖐ïļ Contact us
down Explore our best articles, cover a wide variety of technologies
Our knowledge base
Let's keep in Touch
Thank you for your interest in Tillitsdone! Whether you have a question about our services, want to discuss a potential project, or simply want to say hello, we're here and ready to assist you.
We'll be right here with you every step of the way.
Contact Information
rick@tillitsdone.com+66824564755
Find All the Ways to Get in Touch with Tillitsdone - We're Just a Click, Call, or Message Away. We'll Be Right Here, Ready to Respond and Start a Conversation About Your Needs.
Address
9 Phahonyothin Rd, Khlong Nueng, Khlong Luang District, Pathum Thani, Bangkok Thailand
Visit Tillitsdone at Our Physical Location - We'd Love to Welcome You to Our Creative Space. We'll Be Right Here, Ready to Show You Around and Discuss Your Ideas in Person.
Social media
FacebookInstagramLinkedIn
Connect with Tillitsdone on Various Social Platforms - Stay Updated and Engage with Our Latest Projects and Insights. We'll Be Right Here, Sharing Our Journey and Ready to Interact with You.
We anticipate your communication and look forward to discussing how we can contribute to your business's success.
We'll be here, prepared to commence this promising collaboration.
Frequently Asked Questions
Explore frequently asked questions about our products and services.
Whether you're curious about features, warranties, or shopping policies, we provide comprehensive answers to assist you.