Front-end Tutorials

Front-end Tutorials

HTMLCSSSassJavaScriptReactJS
CMS Tutorials

CMS Tutorials

WordPress
Tutorials expand

CSS Properties

CSS grid-column-start Property

Posted in CSS Tutorial
Updated on Oct 03, 2024
By Mari Selvan
👁️ 26 - Views
⏳ 4 mins
💬 1 Comment
CSS grid-column-start Property

Photo Credit to CodeToFun

🙋 Introduction

The grid-column-start property in CSS is used in the context of CSS Grid Layout. It specifies the starting position of a grid item within a grid container by determining which grid line the item should start on.

This property is essential for placing grid items precisely within a grid layout.

💡 Syntax

The syntax for the grid-column-start property is simple and can be defined using a grid line number, a named grid line, or special keywords.

Syntax
Copied
Copy To Clipboard
element {
  grid-column-start: value;
}

🎛️ Default Value

The default value of the grid-column-start property is auto. This means the grid item will be placed automatically by the grid's auto-placement algorithm.

🏠 Property Values

ValueDescription
autoPlaces the item automatically based on the layout algorithm.
line numberSpecifies the grid line number where the item should start.
spanIndicates how many columns the item should span. For example, span 2 starts the item two columns away from the start.
named grid lineUses a named grid line to determine the starting position.

📄 Example

In this example, we'll create a simple grid layout and use the grid-column-start property to position grid items.

index.html
Copied
Copy To Clipboard
<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>CSS grid-column-start Example</title>
  <style>
    .grid-container {
      display: grid;
      grid-template-columns: 100px 100px 100px;
      grid-template-rows: 100px 100px;
      gap: 10px;
    }
    .item1 {
      background-color: lightblue;
      grid-column-start: 2;
    }
    .item2 {
      background-color: lightgreen;
      grid-column-start: span 2;
    }
    .item3 {
      background-color: lightcoral;
    }
  </style>
</head>
<body>
  <h1>Grid Layout with grid-column-start</h1>
  <div class="grid-container">
    <div class="item1">Item 1</div>
    <div class="item2">Item 2</div>
    <div class="item3">Item 3</div>
  </div>
</body>
</html>

🖥️ Browser Compatibility

The grid-column-start property is supported in all modern browsers, including the latest versions of Chrome, Firefox, Safari, Edge, and Opera. Ensure your browser is up-to-date to use this feature.

🎉 Conclusion

The grid-column-start property is a powerful feature in CSS Grid Layout, allowing precise control over the placement of grid items.

By mastering this property, you can create complex and responsive grid layouts with ease. Experiment with different values to see how this property can enhance your web designs.

👨‍💻 Join our Community:

To get interesting news and instant updates on Front-End, Back-End, CMS and other Frameworks. Please Join the Telegram Channel:

Author

author
👋 Hey, I'm Mari Selvan

For over eight years, I worked as a full-stack web developer. Now, I have chosen my profession as a full-time blogger at codetofun.com.

Buy me a coffee to make codetofun.com free for everyone.

Buy me a Coffee

Share Your Findings to All

Subscribe
Notify of
guest
1 Comment
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
We make use of cookies to improve our user experience. By using this website, you agree with our Cookies Policy
AgreeCookie Policy