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
Tailwind Core Spacing, Sizing, Padding & Margin Scales0%
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
HomeTutorialsTailwind CSSTailwind Core Spacing, Sizing, Padding & Margin Scales
Typography: Font Families, Sizes, Weights, Leading & Tracking

Tailwind Core Spacing, Sizing, Padding & Margin Scales

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

Tailwind CSS employs a standardized, highly intuitive mathematical scale for managing spacing, margins, paddings, and dimensions. Rather than guessing pixel values, developers compose with a 4-pixel base unit grid ($1 \text{ unit} = 0.25\text{rem} = 4\text{px}$).


1. The 4-Pixel Mathematical Spacing Scale

Every numerical step in Tailwind's spacing scale corresponds to a multiple of 4px:

ClassCSS Value (rem)Equivalent PixelsUse Case
p-1 / m-10.25rem4pxTight micro-spacing, badges
p-2 / m-20.5rem8pxSmall button paddings
p-4 / m-41rem16pxStandard default container padding
p-6 / m-61.5rem24pxCard component padding
p-8 / m-82rem32pxSection margins
p-12 / m-123rem48pxHero section spacing
p-16 / m-164rem64pxPage breaks & layout dividers

2. Padding vs Margin Directions

Tailwind provides directional modifiers for precise spatial control:

1<!-- Padding examples -->
2<div class="p-6">Padding on all 4 sides (24px)</div>
3<div class="px-4">Horizontal padding (left and right: 16px)</div>
4<div class="py-2">Vertical padding (top and bottom: 8px)</div>
5<div class="pt-8 pr-4 pb-2 pl-6">Independent top, right, bottom, left</div>
6 
7<!-- Margin examples -->
8<div class="mt-10">Margin top (40px)</div>
9<div class="mx-auto">Center a block element horizontally (margin-left: auto; margin-right: auto)</div>
10<div class="-mt-4">Negative margin: pull element upward by 16px</div>

3. Sizing: Width & Height

1<!-- Fixed Sizing -->
2<div class="w-16 h-16 bg-blue-500">Fixed 64px by 64px avatar</div>
3 
4<!-- Fractional Widths (Fluid grids) -->
5<div class="flex">
6 <div class="w-1/2">50% width</div>
7 <div class="w-1/2">50% width</div>
8</div>
9 
10<div class="w-1/3">33.33%</div>
11<div class="w-2/3">66.66%</div>
12<div class="w-1/4">25%</div>
13 
14<!-- Viewport and Max/Min Sizing -->
15<div class="w-full max-w-4xl min-h-screen">
16 Takes full width up to 56rem (896px), and at least 100vh height!
17</div>

4. Arbitrary Spacing Values

When an exact pixel specification is required by an enterprise design system:

1<!-- Use square brackets for arbitrary JIT values -->
2<div class="p-[19px] w-[342px] min-h-[calc(100vh-80px)]">
3 Custom spacing compiled on-demand!
4</div>

Interactive Quiz• Knowledge Check

Multiple Choice Questions

Question 1
In Tailwind's standard spacing scale, what is the computed pixel equivalent of p-6?
Question 2
Which Tailwind utility class centers a block-level element horizontally within its parent container?
Question 3
How do you declare a negative top margin of 16px in Tailwind CSS?
Question 4
Which class sets an element's minimum height to equal 100% of the browser viewport height?
Question 5
What is the width of an element styled with w-3/4?

Next Lesson

Typography: Font Families, Sizes, Weights, Leading & Tracking

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

Related Lessons

Previous LessonNext Lesson
Installation via PostCSS, Vite & Next.js Framework IntegrationTypography: Font Families, Sizes, Weights, Leading & Tracking

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