GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing www.w3schools.com — CSS Grid Tracks
❮
❯
CSS TutorialCSS HOME CSS Introduction CSS Syntax CSS Selectors CSS How To CSS Comments CSS Errors CSS Colors CSS Backgrounds
Background Color
Background Image
Background Repeat
Background Attachment
Background Shorthand
Code Challenge
CSS Borders
CSS Margins
CSS Padding
CSS Height / Width
CSS Box Model
CSS Outline
CSS Text
Text Color
Text Alignment
Text Decoration
Text Decoration Styles
Text Transformation
Text Spacing
Text Shadow
Code Challenge
CSS Fonts
Font Family
Font Web Safe
Font Fallbacks
Font Style
Font Size
Font Google
Font Pairings
Font Shorthand
Code Challenge
CSS Icons
CSS Links
CSS Lists
CSS Tables
CSS Display
CSS Max-width
CSS Position
CSS Position Offsets
CSS Z-index
CSS Overflow
CSS Float
CSS Inline-block
CSS Align
CSS Combinators
CSS Pseudo-classes
CSS Pseudo-elements
CSS Opacity
CSS Navigation Bars
CSS Dropdowns
CSS Image Gallery
CSS Image Sprites
CSS Attribute Selectors
CSS Forms
CSS Counters
CSS Units
CSS Inheritance
CSS Specificity
CSS !important
CSS Math Functions
CSS Optimization
CSS Accessibility
CSS Website Layout
CSS AdvancedCSS Rounded Corners CSS Border Images CSS Backgrounds CSS Colors CSS Gradients CSS Shadows CSS Text Effects CSS Custom Fonts CSS 2D Transforms CSS 3D Transforms CSS Transitions CSS Animations CSS Tooltips CSS Image Styling CSS Image Modal CSS Image Centering CSS Image Filters CSS Image Shapes CSS object-fit CSS object-position CSS Masking CSS Buttons CSS Pagination CSS Multiple Columns CSS User Interface CSS Variables CSS @property CSS Box Sizing CSS Functions CSS Media QueriesCSS FlexboxFlexbox Intro Flex Container Flex Items Flex ResponsiveCSS GridGrid Intro Grid Container Grid Items Grid 12-column Layout CSS @supportsCSS ResponsiveRWD Intro RWD Viewport RWD Grid View RWD Media Queries RWD Images RWD Videos RWD Frameworks RWD TemplatesCSS CertCSS CertificateCSS SASSSASS TutorialCSS ExamplesCSS Templates CSS Examples CSS Videos CSS Editor CSS Snippets CSS Quiz CSS Exercises CSS Code Challenges CSS Website CSS Syllabus CSS Study Plan CSS Interview PrepCSS ReferencesCSS Reference CSS Selectors CSS Combinators CSS Pseudo-classes CSS Pseudo-elements CSS At-rules CSS Functions CSS Reference Aural CSS Web Safe Fonts CSS Animatable CSS Units CSS PX-EM Converter CSS Colors CSS Color Values CSS Default Values CSS Browser SupportCSS Grid Tracks
Share
CSS Grid Tracks (Rows and Colums)Inside the grid container you define the number and size of the grid columns and rows. For this, we will use the following properties:
The CSS grid-template-columns PropertyThe The value is a space-separated-list, where each value defines the width of the respective column. Common values are:
CSS grid-template-columns: autoTo create a grid layout with 3 columns of equal width, use the "auto" keyword. ExampleCreate a grid with 3 columns of equal width:
.container {
display: grid; grid-template-columns: auto auto auto; } Result: 1
2
3
4
5
6
Grid Columns with Mixed WidthTo create a grid layout with 3 columns: 2 columns with a fixed width, and 1 column with size "auto". ExampleCreate a grid with a fixed size for column 1 and 2, and column 3 as auto size:
.container {
display: grid; grid-template-columns: 80px 200px auto; } Result: 1
2
3
4
5
6
Note: If you have more than 3 grid items in a 3 columns grid, the grid will automatically add new rows to put the items in. Grid Columns with the fr UnitThe 1fr will take 1 fraction of the available space, while 2fr will take 2 fractions of the available space. ExampleHere, each column will take up 33.3% of the container width, splitting it equally:
.container {
display: grid; grid-template-columns: 1fr 1fr 1fr; } Result: 1
2
3
4
5
6
ExampleHere, the second column will be twice as big as the others:
.container {
display: grid; grid-template-columns: 1fr 2fr 1fr; } Result: 1
2
3
4
5
6
Grid Columns with the repeat() FunctionThe CSS ExampleUse repeat() to create three equal-width columns in a grid:
.container {
display: grid; grid-template-columns: repeat(3, 1fr); } Result: 1
2
3
4
5
6
Grid Columns with the minmax() FunctionThe CSS ExampleUse minmax() to define that first column is at least 80px wide and can grow to 1fr:
.container {
display: grid; grid-template-columns: minmax(80px, 1fr) 150px 150px; } Result: 1
2
3
4
5
6
The CSS grid-template-rows PropertyThe The value is a space-separated-list, where each value defines the height of the respective row. Common values are:
ExampleSet the first row in the grid to 80px high, and the second row to 200px high:
.container {
display: grid; grid-template-rows: 80px 200px; } Result: 1
2
3
4
5
6
7
8
Notice that the first row in the grid above is 80px high and the second row is 200px high. The next rows will use auto as default. Free account Track your progress
XP earned 0
Day streak 0
Spaces 0
League —
New Learn in Adventure Mode W3Schools Adventure AppCoding fundamentals as bite-sized lessons and challenges.
×
Contact SalesIf you want to use W3Schools services as an educational institution, team or enterprise, send us an e-mail: Report ErrorIf you want to report an error, or if you want to make a suggestion, send us an e-mail: Top TutorialsHTML TutorialCSS Tutorial JavaScript Tutorial How To Tutorial SQL Tutorial Python Tutorial W3.CSS Tutorial Bootstrap Tutorial PHP Tutorial Java Tutorial C++ Tutorial jQuery Tutorial Top ReferencesHTML ReferenceCSS Reference JavaScript Reference SQL Reference Python Reference W3.CSS Reference Bootstrap Reference PHP Reference HTML Colors Java Reference AngularJS Reference jQuery Reference
W3Schools is optimized for learning and training. Examples might be simplified to improve reading and learning.
Tutorials, references, and examples are constantly reviewed to avoid errors, but we cannot warrant full correctness of all content. While using W3Schools, you agree to have read and accepted our terms of use, cookies and privacy policy. Copyright 1999-2026 by Refsnes Data. All Rights Reserved. W3Schools is Powered by W3.CSS. |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |