<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Zakariae El Mejdki on Medium]]></title>
        <description><![CDATA[Stories by Zakariae El Mejdki on Medium]]></description>
        <link>https://medium.com/@elmejdki.zakariae?source=rss-b3b50ef551e0------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*v52Ng8MX3m2z42vOoJFStw.jpeg</url>
            <title>Stories by Zakariae El Mejdki on Medium</title>
            <link>https://medium.com/@elmejdki.zakariae?source=rss-b3b50ef551e0------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Wed, 18 Nov 2026 03:41:54 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@elmejdki.zakariae/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[What Really Is a CSS Grid System? And How to Work With It?]]></title>
            <link>https://medium.com/swlh/what-really-is-a-css-grid-system-and-how-to-work-with-it-e44bc8bb0bcd?source=rss-b3b50ef551e0------2</link>
            <guid isPermaLink="false">https://medium.com/p/e44bc8bb0bcd</guid>
            <category><![CDATA[css-grid]]></category>
            <category><![CDATA[ux]]></category>
            <category><![CDATA[css]]></category>
            <category><![CDATA[ui]]></category>
            <dc:creator><![CDATA[Zakariae El Mejdki]]></dc:creator>
            <pubDate>Thu, 06 Feb 2020 22:42:29 GMT</pubDate>
            <atom:updated>2021-01-16T06:25:26.042Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*c02MqJcD2IiQFumGGUFSFw.png" /></figure><p>A lot of new web developers don’t understand CSS grids after their first experience with them. And that is the reason why I decided to write this article. Besides that, I also want to give a brief intro to CSS grid system and try to explain to people who are new to CSS, how to work with this amazing feature in the simplest way possible.</p><p>So let’s start with the question of why the CSS grid exists in the first place and what it is actually.</p><h3><strong>What really is CSS Grid?</strong></h3><p>When it comes to developing websites, I usually draw mock-ups on papers. Below is a mock-up that I was trying to do in different system views (what I mean by system view: Desktop view, Tablet view, and Mobile view).</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*tZ2I4SQQkYyhVi2_WJ354g.png" /></figure><p>As you can notice easily, in each view type there are some changes in orders of the elements inside the web page. For example, we see that in the mobile view we have an image, then the title, after that the meta content, and finally we have the content. But on the tablet view, we see that the title and the meta content come first before the image.</p><p>Before CSS grid, if we want to make this kind of layout, we would definitely need to use some JavaScript to reorder the DOM and create that order that we wanted for each view type. Nowadays this is easily doable with the CSS Grid which provides incredibly clean HTML code. Nowadays you don’t need to think about nesting div’s in order to float elements or displaying them in specific positions. You can easily create a grid system layout and then position your items in it as you wish, wherever you want and whenever you want.</p><p>Here is a definition of a CSS grid system:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/560/1*O9bAKOZdEAnWBUhQa4DgHw.png" /></figure><blockquote>CSS Grid Layout is a two-dimensional system, meaning it can handle both columns and rows, unlike flexbox which is largely a one-dimensional system (either in a column or a row). A core difference between CSS Grid and Flexbox is that — CSS Grid’s approach is layout-first while Flexbox’s approach is content-first.</blockquote><p>Enough of speaking about why and what a Grid system is. Let’s see how to work with in the CSS grid System.</p><h3><strong>How to work with CSS Grid?</strong></h3><p>From my point of view, the best and easiest way to work with the CSS grid is to use the magical grid property grid-template-areas<em>.</em> But before jumping into that, we need to understand first how the CSS grid is structured and get familiar with some technical words. Grid systems usually have a grid container and grid items. A grid container is the HTML element that has a display property of grid display: grid. A grid item is every element that a direct descendant of that element.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/690/1*oxh6y0GpRr3_hJLeG9UMfw.png" /></figure><h4><strong>Terminology:</strong></h4><p>There are a few bits of terminology that are introduced by the Grid Layout specification. I’ve explained them here as they will make the examples easier to follow.</p><h4><strong>Grid Line</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*jqnv_mKrmEwDTH2VFj7mdw.png" /></figure><p>Grid Lines are the lines that make up the grid. These can be horizontal or vertical. We can refer to them by number or by name.</p><h4><strong>Grid Tracks</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*r1kkzMS655bhFdsIUZWZ-Q.png" /></figure><p>A Grid Track is a space between two Grid Lines, either horizontal or vertical.</p><h4><strong>Grid Cell</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*QB0Y90CwdT0bj8anQuI0Sg.png" /></figure><p>A Grid Cell is a space between 4 Grid Lines. So it is the smallest unit in our grid that is available for us to place an item into. Conceptually it is just like a table cell.</p><h4><strong>Grid Area</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*x7JU8ZnNPK4Ttluekj80jA.png" /></figure><p>A Grid Area is any area on the Grid bound by four grid lines. It may contain a number of Grid Cells.</p><p>After these simple terminologies let’s see how we can work with this amazing layout.</p><h3><strong>Here is how:</strong></h3><p>Let’s return back to our magical property that I have mentioned before. To start with the CSS grid, we use display: grid, and we define our columns and rows. Then after that, we use that magical property to draw our areas as shown in the code below :</p><pre>.container {<br>     <em>display: grid;</em><br>     <em>gird-template-columns: repeat(6, 1fr);</em><br>     <em>grid-template-rows: repeat(3, 1fr) 100px;<br></em>    <em> grid-template-areas:</em><br>          <em>“header header header header header header”</em><br>          <em>“main main main . sidebar sidebar”</em><br>          <em>“main main main . sidebar sidebar”</em><br>          <em>“ . footer footer footer footer . “;</em><br>}</pre><p>With this property, we are drawing the grid areas by specifying for each grid cell what area it will take.</p><p>“I know, I know I got you, some of these properties are new to you I will explain don’t worry “</p><ul><li>repeat() is a CSS grid function that allows us to instead of repeating many values of columns and rows sizes, to just type in repeat n times that value. In other words, it makes sure that we don’t repeat ourselves, so instead of typing “300px 300px 300px” we can type “repeat(3, 300px)”.</li><li>There is a new unit of measure in CSS introduced with Grid called fraction (fr). This unit allows us to share space based on the extra space. Here is a <a href="https://www.youtube.com/watch?v=Ufeiz6a_2xA">YouTube video </a>that explains it.</li></ul><p>Let’s continue, so in grid-template-areas, we have defined some areas that we will be used later by the grid items in order to align there self’s in them. Now let’s see how a grid item should look like.</p><pre>.header {<br>     grid-area: header;<br>     background-color: blueviolet;<br>}</pre><pre>.main {<br>    grid-area: main;<br>    background-color: real;<br>}</pre><pre>...</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*R8IrHmR8yy9LRDzX0QAHnA.png" /></figure><p>Now, what if I want to change the order in the mobile version, I need only to add this @media query with this code in it:</p><pre>@media screen and ( max-width: 700px ) {<br>    .container {<br>         gird-template-columns: 1fr;<br>         grid-template-areas:<br>              &quot;header&quot;<br>              &quot;sidebar&quot;<br>              &quot;main&quot;<br>              &quot;footer&quot;<br>     }<br>}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/543/1*m-E0Bmm6XhbQpx1epTvNjA.png" /></figure><p>And that’s it, that’s how we align items inside a grid layout system.</p><h3>Summary</h3><p>That’s all friends.<br>I hope you’ve enjoyed this article and learned from my experience.<br>If you can like this post and share it, I will appreciate applause and sharing :-)</p><p>You can contact or follow me:<br><a href="https://twitter.com/0ca7848f87ab470">My Twitter</a><br><a href="https://www.facebook.com/zakaria.elmejdki">Facebook</a><br><a href="https://www.linkedin.com/in/zakariae-el-mejdki-644898139/">LinkedIn</a></p><h4>Some valuable external resources :</h4><ul><li><a href="https://cssgrid.io/">CSS Grid</a></li><li><a href="https://css-tricks.com/snippets/css/complete-guide-grid/">A Complete Guide to CSS Grid Layout | CSS-Tricks</a></li><li><a href="https://gridbyexample.com/">Grid by Example</a></li><li><a href="https://cssgridgarden.com/">Grid Garden</a></li></ul><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=e44bc8bb0bcd" width="1" height="1" alt=""><hr><p><a href="https://medium.com/swlh/what-really-is-a-css-grid-system-and-how-to-work-with-it-e44bc8bb0bcd">What Really Is a CSS Grid System? And How to Work With It?</a> was originally published in <a href="https://medium.com/swlh">The Startup</a> on Medium, where people are continuing the conversation by highlighting and responding to this story.</p>]]></content:encoded>
        </item>
    </channel>
</rss>