HTML Academy
Laying out a simple page: the sidebar
Introduction to Grid Layout26/32
Back to the list of tasks
  • 1. The grid item’s position: grid-row-start and grid-column-start
  • 2. The grid item’s position: grid-column-start and grid-column-end
  • 3. The grid item’s position: grid-row-start and grid-row-end
  • 4. Negative values for grid-column-start and grid-column-end
  • 5. Negative values for grid-row-start and grid-row-end
  • 6. Grid item overlay
  • 7. Overlaying grid items and the z-index property
  • 8. Summary of “Grids: positioning grid items”
  • 9. Test: Building bridges
  • 10. Named grid areas: the grid-template-areas property
  • 11. The grid-template-areas property and empty grid areas
  • 12. Automatic coordinates of the grid items: columns
  • 13. Automatic coordinates of elements in the grid: columns and rows
  • 14. Combining automatic and explicit coordinates
  • 15. Combining automatic and explicit coordinates, part 2
  • 16. Unfixed column width
  • 17. Unfixed column and row widths
  • 18. Grid spacing: the gap property
  • 19. Grid spacing: the row-gap and column-gap properties
  • 20. Summary of “Creating layouts using grids”
  • 21. Test: Laying out a park
  • 22. Laying out a simple page: creating a grid
  • 23. Laying out a simple page: the header
  • 24. Laying out a simple blog page: the promo block
  • 25. Laying out a simple page: the sidebar
  • 26. Laying out a simple blog page
  • 27. Laying out a simple page: the final step
  • 28. Laying out the online store catalog: creating an internal grid
  • 29. Laying out an online store catalog: the “Sort by” block
  • 30. Laying out an online store catalog: the filter block
  • 31. Laying out an online store catalog: the final step
  • 32. Test: The grid layout of a page
Laying out a simple page: the final step
  • Sign up
  • Log in

Loading…
Everything will be ready in few seconds

  • Theory
  • Theory
  • Comments

Laying out a simple blog page

Now it is time to order the element in the third row. We will place the article block as well as part of the review block in it.

As you may have already guessed, the article block, like the promo block, occupies the first two columns.

However, unlike the promo block, here we can’t establish fixed element sizes, since the height of both blocks, meaning the ones for the articles and reviews, should not be restricted. Why is that? You guessed it: because they both contain text content that is subject to change.

Please note that for a grid line whose size is automatically determined, the height is determined by the height of the highest grid item, and the remaining grid items that are also located on this grid line are stretched to match its height.

Let’s control how the third non-fixed row in our grid will be stretched if another blog article appears in the markup.

Please not that we didn’t add anything to the grid-template-rows since the sizes of the remaining rows are set automatically by default. However, this will suit us for the moment.

Comments

  • index.html
  • style.css
HTML
<!DOCTYPE html> <html lang="en"> <head> <meta charset="utf-8"> <title>Laying out a simple blog page</title> <link href="lopatkin.css" rel="stylesheet"> <link href="style.css" rel="stylesheet"> </head> <body> <div class="index-grid"> <header class="site-header"> <h1 class="visually-hidden">The Lopatkin Garden Accessories Store</h1> <nav class="site-nav"> <a class="logo"> <img src="logo.svg" width="40" height="40" alt=""> Lopatkin </a> <a href="#">About Us</a> <a href="#">Catalog</a> <a href="#">Blog</a> </nav> </header> <section class="promo"> <h2 class="visually-hidden">Promotions</h2> <img src="garden.jpg" width="360" height="200" alt="“2018 Garden Fashion” Collection"> <a class="button button--promo" href="#">Monthly promotions</a> </section> <section class="blog"> <article class="blog-item"> <h2>Where are the gnomes?</h2> <img src="gnomes.png" width="150" height="80" alt="Mature purple garden gnomes"> <p>Fill the backyard with gnomes.</p> <a class="button" href="#">Read</a> </article> <!-- <article class="blog-item"> <h2>Feng Shui: myths and reality</h2> <img src="pots.jpg" width="150" height="80" alt="Proper arrangement of pots"> <p>Arrange the pots according to the rules of Feng Shui.</p> <a class="button" href="#">Read</a> </article> --> </section> <aside class="sidebar"> <h2>Reviews</h2> <ul class="reviews"> <li class="review-item"> <p>I liked everything very much. Especially the shovel. Useful thing. I like it.</p> <cite>Oleg_</cite> </li> <li class="review-item"> <p>I managed to decorate my yard. Thanks for your great advice! The gnomes are cute.</p> <cite>Aristarch</cite> </li> <li class="review-item"> <p>The gnomes are very scary. I’m not certain how you can sell them at all!11</p> <cite>not_your_girl_79</cite> </li> </ul> </aside> <footer class="site-footer"> <a class="vkontakte" href="https://vk.com/htmlacademy">VK</a> <a class="facebook" href="https://www.facebook.com/htmlacademy">Facebook</a> <a class="instagram" href="https://instagram.com/htmlacademy">Instagram</a> </footer> </div> </body> </html>
CSS
.index-grid { display: grid; width: 550px; margin-left: auto; margin-right: auto; gap: 20px; grid-template-columns: 170px 170px 170px; grid-template-rows: auto 200px; } .site-header { grid-column-start: 1; grid-column-end: 4; } .promo { grid-column-start: 1; grid-column-end: 3; } .sidebar { grid-row-start: 2; grid-row-end: 4; grid-column-start: 3; grid-column-end: 4; }

What didn’t you like in this task?

Thanks! We’ll fix everything at once!

The code has changed, click “Refresh” or turn autorun on.

You’ve gone to a different page

Click inside the mini-browser to shift the focus onto this window.

100%
Goalscompleted
0
    1. Add the grid item coordinates for column grid lines 1 to 3 for the .blog block.
    2. Then uncomment another article in the .blog block in the markup and check how the grid layout now behaves.

    Cookies ∙ Privacy ∙ License Agreement ∙ About ∙ Contacts ∙ © HTML Academy OÜ, 2019−2025

    VISAMastercard

    Log in

    or

    Forgot your password?

    Sign up

    Sign up

    or
    Log in

    Restore access

    Have you forgotten your password or lost access to your profile? Enter your email connected to your profile and we will send you a link to restore access.

    Forgot to connect your email to the profile? Email us and we’ll help.