• Skip to main content
  • Skip to primary sidebar

Web Development Archive

  • Archive
You are here: Home / CSS / CSS Grid Template Area

CSS Grid Template Area

grid-template-areas
/* ===================================================================== 
    Practice CSS Grid Layout
 ======================================================================== */
 /* 
   Target each grid item. 
   Give each selector a grid area name.
 */
 header {
   grid-area: head;
 }
 main {
   grid-area: main;
 }
 .about {
   grid-area: about;
 }
 .news {
   grid-area: news;
 }
 .links {
   grid-area: links;
 }
 .ads {
   grid-area: ads;
 }
 footer {
   grid-area: foot;
 }
 .grid {
   height: 100vh;
   display: grid;
 /* Set only the top row to 100px */
   grid-template-rows: 100px;
 /* 
     Declare 3 flexible column tracks
      - The first track should take up two fractions of the available space
      - The second and third tracks should take up one fraction of the space
   */
   grid-template-columns: 2fr 1fr 1fr;  
 /* Apply a 10px gutter between rows and columns */
   grid-gap: 10px;
 /*  
     Place items on the grid using their grid area names
       - Use the image 'grid-template-areas.png' as a reference
   */
   grid-template-areas: 
     "head head head"
     "main about news"
     "main links ads"
     "main foot foot";
 }

Filed Under: CSS Tagged With: Grid

About Gabor Flamich

I'm a web developer and designer based in Budapest, Hungary. In recent years, I've documented hundreds of solutions I came across during development. This site is an archive for useful code snippets on WordPress, Genesis Framework and WooCommerce. If You have any questions related to WordPress development, get in touch!

Primary Sidebar

  • angular.io
© 2026 WP Flames - All Right Reserved