MSK Institute LogoMSK.Institute
HomeCourses
Book Free Demo➔Sign In
Free Demo➔
MSK Institute LogoMSK.Institute

Leading computer training academy in Shikohabad for software engineering, Python, web development, and digital literacy.

ISO 9001:2015 Certified Center
Follow & Connect
4.9

Programs & Admissions

  • All CoursesCatalog
  • Learning PathsRoadmaps
  • Student ProjectsShowcase
  • Live Classes & ScheduleLive
  • Upcoming Batches
  • Campuses & LocationsHub
  • Verify Certificates
  • Book Free Demo Class

Resources & Tools

  • Free Online Mock TestsAll Tests
  • NIELIT CCC Mock TestFree
  • Course & Career FinderQuiz
  • Study Material Hub
  • All MSK ToolsHub
  • Keyboard ShortcutsNew
  • TypeQuest Speed LabTyping
  • MSK Code PlaygroundCode
  • Interactive Tutorials
  • Quick Cheatsheets

Institute & Contact

  • About MSK Institute
  • Careers & InternshipsHiring
  • Publications & Blogs
  • Gali No. 3, Near Gyan Jyoti Public School,
    Adarsh Nagar, Shikohabad, Uttar Pradesh 283135
  • +91 83930 42166
  • mskshikohabad@gmail.com
  • Hours:Mon – Sat: 8:00 AM – 7:00 PM | Sun: 10:00 AM – 2:00 PM
  • 4.9 ★(38 Google Reviews)
© 2026 MSK Institute. All rights reserved.•Privacy Policy•Terms of Service•Disclaimer•Contact Us

Shikohabad's Leading Computer & Coding Academy

Home
Courses
Live
Material
CSS Grid System: Template Columns, Rows, Col-Span & Gap0%
Study Materials
Tailwind CSSProgress 0%
1.1Why Tailwind CSS? Utility-First vs Traditional Semantic CSS1.2Installation via PostCSS, Vite & Next.js Framework Integration1.3Tailwind Core Spacing, Sizing, Padding & Margin Scales1.4Typography: Font Families, Sizes, Weights, Leading & Tracking
2.1Flexbox Architecture: Justify, Align, Direction, Wrap & Gap2.2CSS Grid System: Template Columns, Rows, Col-Span & Gap2.3Mobile-First Responsive Design with Breakpoint Prefixes (sm, md, lg, xl)2.4Positioning, Z-Index, Floats, Overflows & Aspect Ratio Utilities
HomeTutorialsTailwind CSSCSS Grid System: Template Columns, Rows, Col-Span & Gap
Mobile-First Responsive Design with Breakpoint Prefixes (sm, md, lg, xl)

CSS Grid System: Template Columns, Rows, Col-Span & Gap

Beginner12 min read•Updated: 2026-11-18•By Er. Sumit Kumar (MSK Institute)
Study MaterialsCheatsheet

While Flexbox is ideal for one-dimensional layouts (a row OR a column), CSS Grid is the gold standard for two-dimensional layouts (rows AND columns simultaneously). Tailwind CSS makes CSS Grid effortless with grid-cols-{n}, col-span-{n}, and gap utilities.


1. Creating a Standard Responsive Grid

1<!-- 1 column on mobile, 2 on tablet (md), 4 on desktop (lg) -->
2<div class="grid grid-cols-1 md:grid-cols-2 lg:grid-cols-4 gap-6">
3 <div class="p-6 bg-white rounded-xl shadow">Course 1</div>
4 <div class="p-6 bg-white rounded-xl shadow">Course 2</div>
5 <div class="p-6 bg-white rounded-xl shadow">Course 3</div>
6 <div class="p-6 bg-white rounded-xl shadow">Course 4</div>
7</div>

2. Spanning Columns and Rows (col-span & row-span)

Tailwind supports fractional spanning across a 12-column grid:

1<!-- Modern 12-Column Dashboard Layout -->
2<div class="grid grid-cols-12 gap-4">
3 <!-- Sidebar spans 3 columns -->
4 <aside class="col-span-12 lg:col-span-3 bg-slate-900 text-white p-4 rounded-xl">
5 Sidebar Menu
6 </aside>
7
8 <!-- Main Content spans 9 columns -->
9 <main class="col-span-12 lg:col-span-9 bg-white p-6 rounded-xl border">
10 Dashboard Analytics
11 </main>
12</div>

3. Asymmetrical Bento Grid Layout

Bento grids combine col-span and row-span for visual visual storytelling:

1<div class="grid grid-cols-1 md:grid-cols-3 grid-rows-2 gap-4 h-96">
2 <!-- Large Feature Card (spans 2 cols, 2 rows) -->
3 <div class="md:col-span-2 md:row-span-2 bg-gradient-to-br from-blue-600 to-indigo-700 text-white p-8 rounded-2xl">
4 <h3 class="text-2xl font-bold">Featured Full-Stack Program</h3>
5 </div>
6 
7 <!-- Top Right Card -->
8 <div class="bg-slate-100 p-6 rounded-2xl">
9 <h4>Online Certification</h4>
10 </div>
11 
12 <!-- Bottom Right Card -->
13 <div class="bg-amber-50 p-6 rounded-2xl">
14 <h4>Live Lab Sessions</h4>
15 </div>
16</div>

4. Grid Auto-Fit vs Auto-Fill with Arbitrary Values

When you want an automated responsive grid where cards wrap without media queries:

1<!-- Auto-filling cards with minimum 250px width each -->
2<div class="grid grid-cols-[repeat(auto-fit,minmax(250px,1fr))] gap-6">
3 <div class="bg-white p-4 shadow rounded-lg">Card A</div>
4 <div class="bg-white p-4 shadow rounded-lg">Card B</div>
5 <div class="bg-white p-4 shadow rounded-lg">Card C</div>
6</div>

Interactive Quiz• Knowledge Check

Multiple Choice Questions

Question 1
Which class establishes a 3-column equal-width grid container in Tailwind CSS?
Question 2
How do you make an element take up 4 columns inside a 12-column grid in Tailwind?
Question 3
What is the purpose of row-span-2 in a CSS grid?
Question 4
Which class specifies an independent 24px vertical row gap and 16px horizontal column gap?
Question 5
What happens if a developer uses col-span-2 inside a container that only has grid-cols-1?

Next Lesson

Mobile-First Responsive Design with Breakpoint Prefixes (sm, md, lg, xl)

Continue learning with hands-on practice, examples, and exercises in the upcoming topic.

Related Lessons

Previous LessonNext Lesson
Flexbox Architecture: Justify, Align, Direction, Wrap & GapMobile-First Responsive Design with Breakpoint Prefixes (sm, md, lg, xl)

Practice Quiz

Test your understanding of this lesson with 5 questions. Each question has one correct answer.

Mentor-Led Practical Training

Master Tailwind CSS with Hands-On Projects

Practice in live mentor-led sessions with real projects, mock tests, and verifiable certification at MSK Institute.

View Full CourseBook Free Demo
PreviousNext
PreviousPrevNext