HOME

TheInfoList



OR:

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 g ...
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 data ...
, 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 Phil may refer to: * Phil (given name), a shortened version of masculine and feminine names * Phill, a given name also spelled "Phil" * Phil, Kentucky, United States * ''Phil'' (film), a 2019 film * -phil-, a lexical fragment, used as a root te ...
at
Microsoft Microsoft Corporation is an American multinational corporation, multinational technology company, technology corporation producing Software, computer software, consumer electronics, personal computers, and related services headquartered at th ...
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. The syntax was restructured and further refined through several interations in the CSS Working Group, led primarily by
Elika Etemad Elika or Alika or Ileka ( fa, اليكا, also Romanized as Ālīkā; also known as Īlīkā and Īlkā) is a village in Owzrud Rural District, Baladeh District, Nur County, Mazandaran Province, Iran on the road from Tehran to the Caspian Sea ( C ...
and Tab Atkins Jr. The feature was widely adopted by
web developer A web developer is a programmer who develops World Wide Web applications using a client–server model. The applications typically use HTML, CSS, and JavaScript in the client, and any general-purpose programming language in the server. is used ...
s 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 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