In
Cascading Style Sheets, CSS grid layout or CSS grid creates complex
responsive web design grid
Grid, The Grid, or GRID may refer to:
Common usage
* Cattle grid or stock grid, a type of obstacle is used to prevent livestock from crossing the road
* Grid reference, used to define a location on a map
Arts, entertainment, and media
* News ...
layouts more easily and consistently across browsers. Historically, there have been other methods for controlling web page layout methods, such as
tables
Table may refer to:
* Table (furniture), a piece of furniture with a flat surface and one or more legs
* Table (landform), a flat area of land
* Table (information), a data arrangement with rows and columns
* Table (database), how the table d ...
,
floats, and more recently,
CSS Flexible Box Layout (flexbox). CSS grid is currently not an official standard (it is a
W3C Candidate Recommendation) although it has been adopted by the recent versions of all current major browsers.
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.
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.
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
Phil Cupp at
Microsoft
Microsoft Corporation is an American multinational technology corporation producing computer software, consumer electronics, personal computers, and related services headquartered at the Microsoft Redmond campus located in Redmond, Washin ...
in 2011 and implemented in
Internet Explorer 10
Internet Explorer 10 (IE10) is the tenth, and by now, discontinued, version of the Internet Explorer web browser and the successor to Internet Explorer 9, released by Microsoft on September 4, 2012, shortly after the completion of Windows Serv ...
behind a
-ms-
vendor prefix
Cascading Style Sheets (CSS) is a style sheet language used for describing the presentation of a document written in a markup language such as HTML or XML (including XML dialects such as SVG, MathML or XHTML). CSS is a cornerstone techno ...
. The syntax was restructured and further refined through several interations in the
CSS Working Group, led primarily by
Elika Etemad and
Tab Atkins Jr. The feature was widely adopted by
web developers after
evangelism led primarily by
Rachel Andrew and
Jen Simmons.
Browser support
As of October 2017, Chrome, Firefox, Safari and Edge all support CSS grid without vendor prefixes. IE 10 and 11 support CSS grid but with an outdated specification. On mobile, all modern browsers support CSS grid except for Opera Mini and Baidu Browser. Web developers targeting older browsers can utilize
Modernizr 3.5.0 to detect and gracefully degrade the webpage as needed.
Utilization in frameworks
Tailwind CSS incorporates CSS grid into its utilities for controlling how elements are sized and placed. However many other current web frameworks do not incorporate CSS grid, such as
Bootstrap 4 and
Foundation
Foundation may refer to:
* Foundation (nonprofit), a type of charitable organization
** Foundation (United States law), a type of charitable organization in the U.S.
** Private foundation, a charitable organization that, while serving a good cause ...
6.
the fr unit
The "fr" unit is often used with CSS grid layout.
The "fr" unit, part of the CSS grid layout specification, represents a fraction of the leftover space in the grid container.
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
External links
CSS Grid Layout Module Level 1CSS Grid vs Flexbox
{{W3C Standards
Cascading Style Sheets
World Wide Web Consortium standards
Web design