This repository contains the starter files for the CSS Grid Intro coding exercise in Web Design 1.
This exercise is your first introduction to CSS Grid. CSS Grid is a layout system that lets you arrange content into rows and columns. It is especially useful when you want to divide a page into larger layout areas, such as columns, sidebars, headers, footers, galleries, and other structured page sections.
In this exercise, the examples are intentionally simple. The goal is to understand the basic Grid concepts you will need before moving into more complete website layouts.
Canvas has the full assignment description, screencast videos, due date, and submission instructions.
This README is here to explain the project, remind you of the major concepts, and help you check your work before submitting.
Follow the Canvas instructions and watch the screencast videos in order.
This assignment uses a GitHub template repository. You are not downloading a ZIP file for this exercise.
Instead, you will:
- Create your own repository from the instructor’s template repository.
- Clone your copy to your computer using GitHub Desktop.
- Open the project folder in Visual Studio Code.
- Complete the CSS Grid Intro exercise.
- Commit your changes in GitHub Desktop.
- Push your changes to GitHub.
- Publish the site using GitHub Pages.
- Add the published GitHub Pages link to the About section of your repository.
- Submit the URL of your GitHub repository in Canvas.
The submitted Canvas link should be the repository URL, not the published GitHub Pages website URL.
CSS Grid is one of the main layout tools used in modern web design.
Earlier in the course, you learned how to create HTML structure, write basic CSS styles, and did a little Flexbox. Flex is useful when you want to arrange content in one direction, such as a single row or a single column.
Grid is especially useful when you want to think in both rows AND columns at the same time.
For example, Grid can help create:
- two-column page layouts
- sidebars
- card grids
- image galleries
- page sections
- complex website layouts
In this exercise, we will keep the examples simple so you can focus on the core ideas.
CSS Grid starts with a parent-child relationship.
The parent element becomes the grid container when you apply:
display: grid;
The direct children of that parent become grid items.
That means Grid is usually controlled from the parent container.
For example, if a <div> contains three sections, you usually turn the <div> into the grid container. The three sections inside it become the grid items.
This is one of the most important concepts in CSS Grid.
At the end of the exercise, you will complete a Grid challenge on your own.
The challenge asks you to create a simple page-layout-style grid with:
- a main content area
- a sidebar
- a full-width box below them
Your goals are:
- Turn the challenge area into a grid.
- Create three equal columns.
- Add a gap between the grid items.
- Make the main content area span two columns.
- Make the full-width box span across all three columns.
This challenge uses the same ideas from the demos, but combines them in a new way.
That is important. In coding, you do not really understand a concept until you can use it in a slightly different situation.
In this first Grid exercise, we are using the span method to make items stretch across columns.
Examples:
grid-column: span 2;grid-column: span 3;
This is easier to understand at the beginning because it reads almost like a sentence:
- “This item should span 2 columns.”
- “This item should span 3 columns.”
CSS Grid also allows you to place items using grid line numbers, such as:
grid-column: 1 / 4;
That method is powerful, but it requires understanding grid lines. For this first introduction, we are keeping the focus on columns, gaps, fractional units, and the span method.
This exercise focuses mostly on columns.
Grid can also control rows, and grid items can span rows too. However, for this first Grid introduction, we are focusing on column-based layouts because that is what you will need most immediately in the next website layout exercise.
You will see more advanced Grid techniques later.
For this exercise, you will publish the repository using GitHub Pages.
GitHub Pages turns your repository into a live website that can be viewed in a browser.
This is different from the repository itself.
The repository stores your code.
GitHub Pages displays the website created from that code.
After you publish the site, add the GitHub Pages link to the About section of your repository. That makes it easy to find the live version of your project when viewing the repo.
Remember: submit the repository URL in Canvas, not just the published site URL.
For this exercise, you will end up with two different URLs.
The repository URL shows your code on GitHub.
It will look something like this:
https://github.com/your-username/css-grid-intro
This is the URL you submit in Canvas.
The GitHub Pages URL shows the live published website.
It will look something like this:
https://your-username.github.io/css-grid-intro/
This is the URL you should add to the About section of your GitHub repository.
Do not submit only the GitHub Pages URL in Canvas. The published site is useful, but the repository is what your instructor needs to grade your code.
This assignment uses GitHub instead of a ZIP submission.
That means your work must be committed and pushed before your instructor can see it.
The basic workflow is:
- Make changes in VS Code.
- Save your files.
- Open GitHub Desktop.
- Review the changed files.
- Write a short commit message.
- Commit the changes.
- Push the changes to GitHub.
Saving updates the files on your computer.
Committing records a checkpoint in Git.
Pushing uploads that checkpoint to GitHub.com.
If you forget to push, the repository on GitHub may not show your latest work.
Before submitting your work in Canvas, check the following:
- You created your own repository from the instructor template
- You cloned your repository to your computer
- You opened the full project folder in VS Code
- You worked in
index.htmlandstyles.css - Demo 1 uses three equal columns
- Demo 2 uses unequal columns
- Demo 3 uses a grid gap
- Demo 4 has an item spanning all three columns
- Demo 5 previews a main content and sidebar layout
- The On Your Own Challenge is complete
- The challenge grid has three equal columns
- The challenge grid has a gap
- The challenge main content spans two columns
- The challenge full-width box spans all three columns
- The page looks correct when opened in a browser
- You committed your changes in GitHub Desktop
- You pushed your changes to GitHub
- You published the site with GitHub Pages
- You added the GitHub Pages link to the About section of your repository
- You are submitting the GitHub repository URL in Canvas
Submit the URL of your GitHub repository in Canvas.
Do not submit a ZIP file.
Do not submit only the GitHub Pages URL.
Your Canvas submission should look something like:
https://github.com/your-username/css-grid-intro
The GitHub Pages URL should be added to the About section of the repository, but the repository URL is what should be submitted in Canvas.
If something is not working, check these common issues first.
Check:
- Did you save the CSS file?
- Is the CSS file linked correctly in the HTML?
- Is the file name spelled correctly?
- Did you forget a semicolon?
- Did you forget a closing curly brace?
- Is your selector spelled correctly?
Check:
- Did you add
display: grid;to the parent container? - Did you use
grid-template-columns? - Are you styling the grid container, not the grid items?
- Did you save and refresh the browser?
Remember: the grid container controls the layout of its direct children.
Check:
- Did you add
gapto the grid container? - Did you turn on Grid with
display: grid;? - Did you save the file and refresh the browser?
Check:
- Did you add
grid-column: span 3;to the item that should span? - Is that item a direct child of the grid container?
- Did you spell the class name correctly in both HTML and CSS?
Check:
- Did you target the correct class?
- Did you use
grid-column: span 2;? - Is the main content box inside the challenge grid container?
Check GitHub Desktop.
You may have saved your files locally but forgotten to commit or push.
Remember:
- Save updates files on your computer.
- Commit creates a checkpoint.
- Push uploads the checkpoint to GitHub.com.
GitHub Pages may take a little time to rebuild after you push changes.
Wait a minute or two, then refresh the published site.
Also make sure your repository includes an index.html file at the correct location.
CSS Grid can feel strange at first because you are not just styling individual boxes. You are often styling the parent container and telling it how to arrange the boxes inside it.
The key pattern is:
- Find the parent container.
- Turn on Grid with
display: grid;. - Define the columns.
- Add a gap if needed.
- Make individual items span columns when needed.
Once that pattern starts to make sense, you will be ready to use Grid in more realistic page layouts.