This article may be written in a style that istoo abstract to be readily understandable bygeneral audiences. Pleaseimprove it by using words and phrases that have precise, specific meanings within a particular field, as well as by adding examples.(October 2017)
CSS Grid
CSS Grid Layout Module Level 1
A depiction of a typical webpage layout usingCSS floats.
InCascading Style Sheets,CSS grid layout orCSS grid creates complexresponsive web designgrid layouts more easily and consistently across browsers.[6] Historically, there have been other methods for controlling web page layout methods, such astables,floats, and more recently,CSS Flexible Box Layout (flexbox). CSS grid is currently not an official standard (it is aW3C Candidate Recommendation) although it has been adopted by the recent versions of all current major browsers.[7]
CSS grid can create more robust and flexible layouts than the previous options likeCSS 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.
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 forOpera Mini.[12] Web developers targeting older browsers can utilizeModernizr 3.5.0 to detect and gracefully degrade the webpage as needed.[13]
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 asBootstrap 4 andFoundation 6.[15]
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]