Introduction to compound CSS grids.
Tags: cssgrids, compoundgrids, webdev, webdesign
Published: 2023-05-15 08:30:15

### Introduction
Grids are a system for organizing and aligning content layouts on a page. Grids originated in print design. Now they are used in web design.

In this article, the reader will learn about common grid types and how to create compound grids and their benefits.

Responsive web design is complex, and user attention is limited. Grids help solve these problems. Compound grids can be a powerful tool for creating responsive and accessible websites.

## Contents
1. A brief look at grids.
2. What is a compound grid?
3. How to create a compound grid?
4. Benefits of compound grids.
5. Example of a compound grid.
6. Conclusion.
7. Further reading.

## A brief look at grids.
Grids have several parts: (1) Margin. (2) Content. (3) Spatial zones. (4) Rows. (5) Columns, and (6) Gutters.


![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/bqkiovx25cctr41ulnln.png)
                  _Anatomy of a grid layout_

Most web designers use traditional 12 or 16-column grids. There are four common grid types: column, modular, hierarchical, and manuscript grids. Each grid type has a different purpose.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/afa8tgcvsjs4cd4rde6w.png)

## What is a compound grid?
Compound grids are a combination of two or more grids combined into a single grid layout. 

Grids are laid on top of each other to form a compound grid. Columns for each grid type should be the same size. Gutters must be equal size.

See the example of a 2-column + 3-column grid below. The resulting grid is a 6-column compound grid.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/tl6ktl2mxca0oekmpd8q.png)

You can use equally sized columns and rows to create a consistent layout. 

The interplay between two or more grids produces a rhythmic pattern. The pattern alters the visual aspect and mental model of using grids. For example:
2 + 3 columns result in pattern 2 1 1 2.
3 + 4 columns result in pattern 3 1 2 2 1 3.
4 + 5 columns result in pattern 6 1 4 3 3 4 1 6.
and so on. 

The pattern represents each column's proportion in relation to the total available space excluding column gutters.

## Example of a compound CSS grid.
Below is a real-world example of a desktop user interface created using a compound CSS grid. If you look closely, you can see six columns that form a 3 1 2 2 1 3 layout pattern.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/8gb32wsmryqfsv2bftxv.png)
        _Example of a 3 1 2 2 1 grid layout pattern_

The pattern layout is ideal for wide screens. The `body` element is wrapped inside a media query and is the target element for the CSS grid layout. This help to switch between wide and narrow screens. The fractional unit `fr` simplifies creating CSS compound grid layouts.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/2cqbuvgb5kn23b98jph5.png)

For narrow screens, the `body` element is a flex-box container.

![Image description](https://dev-to-uploads.s3.amazonaws.com/uploads/articles/o2z0drhal3vi627jynlq.png)


## Benefits of compound grids.
Compound grids combine multiple grid types into a single design layout. They provide a flexible design with a clear hierarchy. This results in an accessible and easy-to-use web page. 
 
Compound grids give you much control over the layout, which makes your design decision-making process fast. With compound grids, you can design complex responsive layouts that adapt to different screen sizes and browsers.

## Conclusion
As we have seen in this article, compound grids can be a powerful tool for creating responsive and accessible websites and applications.

## Further Reading.
1.[Grids in Graphic Design](https://juliannakunstler.com/vislit_grids.html)
2.[Using a 4 + 5 Compound Grid](https://stuffandnonsense.co.uk/blog/using-a-4-5-compound-grid)
3.[Inspired Design Decisions](https://stuffandnonsense.co.uk/blog/using-a-4-5-compound-grid)