Open In App

CSS place-items Property

The CSS place-items property is the shorthand of align-items and justify-items property. The shorthand properties mean in CSS, that you can set the multiple properties values in a single property. So here the place-items property can hold the value of the align-items and justify-items property values.   

Syntax:



place-items: align-items property value justify-items property value

Property Values: This property accepts all the possible combination values that can make by the align-items and justify-items property values.

Below examples illustrate the CSS place-items property:



Example 1: In this example, we will use star place-items: flex-start property value.




<!DOCTYPE html>
<html>
<head>
    <title>CSS place-items Property</title>
    <style>
        h1 {
            color: green;
        }
 
        #container {
            display: flex;
            height: 200px;
            width: 460px;
            flex-wrap: wrap;
            background-color: gray;
            /* place-items can be changed in the live sample */
            place-items: flex-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>GeeksforGeeks</h1>
        <b>CSS place-items 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>

Output:

Example 2: Here we will use place-items: flex-end property value.




<!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-items can be changed in the live sample */
            place-items: flex-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>GeeksforGeeks</h1>
        <b>CSS place-items 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>

Output:

Browser Versions:


Article Tags :