CSS grid layout
improve it by defining technical terminology, and by adding examples. (October 2017) |
CSS Grid Layout Module Level 1 | |
CSS floats. | |
Abbreviation | Grid, grid layout |
---|---|
Native name | CSS Grid Layout Module Level 1 |
Status | W3C Candidate Recommendation Draft |
First published | April 7, 2007[1] |
Latest version | Level 1 December 18, 2020[2] |
Preview version | Level 2 March 14, 2023[3] |
Organization | W3C |
Committee | CSS Working Group |
Editors | |
Base standards | CSS |
Domain | CSS |
Website | www |
Cascading Style Sheets |
---|
Concepts |
Philosophies |
Tools |
|
Comparisons |
In
Motivation
CSS grid can create more robust and flexible layouts than the previous options like CSS floats. It also allows for more standardized code that works across browsers. This is in contrast to relying on specific browser hacks or complicated workarounds.[2]
One issue with exploiting floats in CSS is that if content gets added to one portion of the page it could disrupt the flow of the page and break the layout. This is due to the varying heights for layout elements.[2] Though flexbox supports flexible layouts and provides the flexibility of creating complex layouts, it fails when the need for creating responsive layouts in 2-dimensional space arises.
History
The first comprehensive draft of a grid layout for CSS was created by
Browser support
As of October 2017, Chrome, Firefox, Safari and Edge all support CSS grid without vendor prefixes.[9][10][11] IE 10 and 11 support CSS grid but with an outdated specification. On mobile, all modern browsers support CSS grid except for Opera Mini.[12] Web developers targeting older browsers can utilize Modernizr 3.5.0 to detect and gracefully degrade the webpage as needed.[13]
Utilization in frameworks
Tailwind CSS incorporates CSS grid into its utilities for controlling how elements are sized and placed.[14] However many other current web frameworks do not incorporate CSS grid, such as Bootstrap 4 and Foundation 6.[15]
the fr unit
The "fr" unit is often used with CSS grid layout.[16][17][18] The "fr" unit, part of the CSS grid layout specification, represents a fraction of the leftover space in the grid container.[2]
Examples
"Holy grail" layout
The following is an example of the "holy grail" layout:
Table of values
The following is an example of a table of values:
References
- ^ "CSS Grid Layout Module Level 1 Publication History - W3C". W3C. n.d. Retrieved 2021-04-09.
- ^ a b c d Atkins Jr., Tab; J. Etemad, Elika; Atanassov, Rossen; Brufau, Oriol; Mogilevsky, Alex; Cupp, Phil; Mielke, Markus, eds. (2021-12-18). "CSS Grid Layout Module Level 1". W3C. W3C Working Group. Retrieved 2021-04-09.
- ^ a b Atkins Jr., Tab; J. Etemad, Elika; Atanassov, Rossen, eds. (2023-03-14). "CSS Grid Layout Module Level 2". W3C. CSS Working Group. Retrieved 2023-03-26.
- ^ Mogilevsky, Alex; Cupp, Phil; Mielke, Markus; Glazman, Daniel, eds. (2011-04-07). "Grid Layout". W3C. CSS Working Group. Retrieved 2021-04-09.
- ^ Mogilevsky, Alex; Mielke, Markus, eds. (2007-09-05). "CSS Grid Positioning Module Level 3". W3C. CSS Working Group. Retrieved 2021-04-09.
- ^ "CSS Grid – Table layout is back. Be there and be square". Google Developers. January 2017. Retrieved 2021-04-09.
- ^ "CSS Grid Layout (level 1) | Can I use... Support tables for HTML5, CSS3, etc". caniuse.com. Retrieved 2022-01-12.
- ^ Gustafson, Aaron (2017-10-19). "The Story of CSS Grid, from Its Creators". A List Apart. Retrieved 2022-01-12.
- ^ Anderson, Kareem (13 September 2017). "Microsoft's newest browser gets a significant boost with EdgeHTML 16". Retrieved 7 October 2017.
- ^ Protalinski, Emil (9 March 2017). "Chrome 57 arrives with CSS Grid Layout and API improvements | VentureBeat". VentureBeat. Retrieved 7 October 2017.
- ^ "CSS Grid Layout". Can I Use. n.d. Retrieved 2021-04-09.
- ^ ""grid" | Can I use... Support tables for HTML5, CSS3, etc".
- ^ Ateş, Faruk (2017-04-13). "Modernizr 3.5.0". Modernizr News. Retrieved 2021-04-09.
- ^ "Grid Column Start / End - Tailwind CSS". Retrieved 2021-04-13.
- ^ Goetter, Raphael (2017-02-16). "Flexbox grids and frameworks". GitHub Gist. Archived from the original on 2017-02-16. Retrieved 2021-04-09.
- ^ Alligator.io (2020-09-03). "CSS Grid Layout: The Fr Unit". DigitalOcean. DigitalOcean. Retrieved 2021-04-09.
- ^ Marcotte, Ethan (2018-07-18). "Fractional. — Ethan Marcotte". Ethan Marcotte. Retrieved 2021-04-09.
- ^ Rendle, Robin (2017-06-12). "An Introduction to the 'fr' CSS unit". CSS-Tricks. Retrieved 2021-04-09.