Skip to content
geeksforgeeks
  • Courses
    • DSA to Development
    • Get IBM Certification
    • Newly Launched!
      • Master Django Framework
      • Become AWS Certified
    • For Working Professionals
      • Interview 101: DSA & System Design
      • Data Science Training Program
      • JAVA Backend Development (Live)
      • DevOps Engineering (LIVE)
      • Data Structures & Algorithms in Python
    • For Students
      • Placement Preparation Course
      • Data Science (Live)
      • Data Structure & Algorithm-Self Paced (C++/JAVA)
      • Master Competitive Programming (Live)
      • Full Stack Development with React & Node JS (Live)
    • Full Stack Development
    • Data Science Program
    • All Courses
  • Tutorials
    • Data Structures & Algorithms
    • ML & Data Science
    • Interview Corner
    • Programming Languages
    • Web Development
    • CS Subjects
    • DevOps And Linux
    • School Learning
  • Practice
    • Build your AI Agent
    • GfG 160
    • Problem of the Day
    • Practice Coding Problems
    • GfG SDE Sheet
  • Contests
    • Accenture Hackathon (Ending Soon!)
    • GfG Weekly [Rated Contest]
    • Job-A-Thon Hiring Challenge
    • All Contests and Events
  • Bootstrap
  • Tailwind
  • Bulma
  • Foundation
  • Primer
  • Spectre
  • Onsen UI
  • Semantic UI
  • Pure CSS
  • Materialize
  • SASS
  • LESS
  • Blaze UI
  • CSS Frameworks
  • Color Picker
  • CSS
  • CSS Formatter
  • Web Technology
Open In App
Next Article:
Primer CSS Spacing Scale
Next article icon

Primer CSS Spacing

Last Updated : 15 Jun, 2022
Comments
Improve
Suggest changes
Like Article
Like
Report

Primer CSS is a free open-source CSS framework that is built with the GitHub design system to provide support to the broad spectrum of Github websites. It creates the foundation of the basic style elements such as spacing, typography, and color. This systematic method makes sure our patterns are steady and interoperable with every other. Its approach to CSS is influenced by Object-Oriented CSS principles, functional CSS, and BEM architecture. It is a highly reusable model.

Primer CSS Spacing can be utilized to provide the indentation around the element by implementing the defined classes i.e. it is used to provide the spacing within the components such as buttons, form elements, etc. It is primarily used to achieve a bigger vertical as well as horizontal spacing between the sections.

Primer CSS Spacing Components:

  • Spacing scale: It is a predefined range of values that is used to specify the amount of the utilities like margin, padding, etc. It is used in Primer CSS is a base-8 scale, using it is extremely flexible because we can multiply or divide the eight as many times as we want and we will end up with whole numbers.
  • Extended spacing scale: It adds six more options to the existing spacing scale. That means the scale which had the range of 0-6 is now increased to 7-12. But this extended range doesn’t work for every utility class in every direction. We can use extended class is in margin and padding. The extended range i.e., 7-12 doesn’t work on the x-axis but does work on the left and right sides individually for margin and padding. But for margin, we cannot use that 7-12 range for the complete x-axis neither together nor individually. Unlike the Basic Scaling Scale in the Extended part, the value increases by 16px instead of 8px.
  • Em-based spacing: It is mainly used to provide the spacing between the components, having the values in em, for which the value combined with typography, line-height, or the total height becomes sensible numbers.

Syntax:

<div class="Primer-CSS-SpacingClasses">     ...  </div>

We can provide spacing around the element in 2 ways, i.e. by using the padding & margin that will create space around the elements. 

Please refer to the Primer CSS Padding & Primer CSS Margin articles for a detailed description.

Example 1: This example describes the Primer CSS Spacing by demonstrating the uniform padding utilities using the required classes in it.

HTML




<!DOCTYPE html>
<html>
  
<head>
    <meta charset="UTF-8" />
    <meta name="viewport" 
          content="width=device-width,
                   initial-scale=1.0" />
    <title>Primer CSS Spacing</title>
    <link href=
"https://unpkg.com/@primer/css@^19.0.0/dist/primer.css" 
          rel="stylesheet" />
</head>
  
<body>
    <center>
        <h1 class="color-fg-open">
              GeeksforGeeks
          </h1>
        <h3>Primer CSS Spacing</h3> 
    </center> 
    <strong>p-0:</strong>
        <div class="p-0 color-bg-success">
            GeeksforGeeks 
        </div> 
    <strong>p-1:</strong>
        <div class="p-1 color-bg-success">
            GeeksforGeeks 
        </div> 
    <strong>p-2:</strong>
        <div class="p-2 color-bg-success">
            GeeksforGeeks 
        </div> 
    <strong>p-3:</strong>
        <div class="p-3 color-bg-success">
            GeeksforGeeks 
        </div> 
    <strong>p-4:</strong>
        <div class="p-4 color-bg-success">
            GeeksforGeeks 
        </div> 
    <strong>p-5:</strong>
        <div class="p-5 color-bg-success">
            GeeksforGeeks 
        </div> 
    <strong>p-6:</strong>
        <div class="p-6 color-bg-success">
            GeeksforGeeks 
        </div>
</body>
</html>
 
 

Output:

 

Example 2: This example describes the Primer CSS Spacing by demonstrating the uniform margin utilities using the required classes in it.

HTML




<!DOCTYPE html>
<html lang="en">
  
<head>
    <meta charset="UTF-8" />
    <meta name="viewport" 
          content="width=device-width,
                   initial-scale=1.0" />
    <title>Primer CSS Spacing</title>
    <link href=
"https://unpkg.com/@primer/css@^19.0.0/dist/primer.css" 
          rel="stylesheet" />
</head>
  
<body>
    <div class="m-4">
        <h1 class="color-fg-success">
            GeeksforGeeks
        </h1>
        <h2>Primer CSS Spacing</h2> 
    </div>
    <div class="d-flex flex-items-baseline flex-justify-around">
        <div class="color-bg-success">
            <div class="m-0 p-1 color-bg-success-emphasis">
                .m-0 
            </div>
        </div>
        <div class="color-bg-success">
            <div class="m-1 p-1 color-bg-success-emphasis">
                .m-1 
            </div>
        </div>
        <div class="color-bg-success">
            <div class="m-2 p-1 color-bg-success-emphasis">
                .m-2 
            </div>
        </div>
        <div class="color-bg-success">
            <div class="m-3 p-1 color-bg-success-emphasis">
                .m-3 
            </div>
        </div>
        <div class="color-bg-success">
            <div class="m-4 p-1 color-bg-success-emphasis">
                .m-4 
            </div>
        </div>
        <div class="color-bg-success">
            <div class="m-5 p-1 color-bg-success-emphasis">
                .m-5 
            </div>
        </div>
        <div class="color-bg-success">
            <div class="m-6 p-1 color-bg-success-emphasis">
                .m-6 
            </div>
        </div>
    </div>
</body>
</html>
 
 

Output: 

 

Reference: https://primer.style/css/support/spacing



Next Article
Primer CSS Spacing Scale

P

pall58183
Improve
Article Tags :
  • CSS
  • Web Technologies
  • Primer-CSS
  • Primer-CSS Support

Similar Reads

  • Primer CSS Spacing Scale
    Primer CSS is a free open-source CSS framework based on technologies that provide insights into important style aspects like space, font, and color. This meticulous methodology ensures that its patterns are both stable and compatible. It's mostly practical and adaptable. It was created using the Git
    3 min read
  • Primer CSS Em-based Spacing
    Primer CSS Spacing contains Em-based Spacing which is mainly used to provide the spacing between the components, having the values in em, for which the value combined with typography, line height, or the total height becomes sensible numbers. GitHub's body font size is 14px which is difficult to wor
    2 min read
  • Primer CSS Theming
    Primer CSS is a free open-source CSS framework that is built upon systems that create the foundation of the basic style elements such as spacing, typography, and colour. This systematic method makes sure our patterns are steady and interoperable with every other. Its approach to CSS is influenced by
    3 min read
  • CSS word-spacing Property
    The word-spacing property adjusts the white space between words, increasing or decreasing. This CSS property can be set to normal or a specific length (positive or negative), improving readability and text formatting. Syntaxword-spacing: normal|length|initial|inherit;Property valuesNormalDefines the
    2 min read
  • Primer CSS Subhead
    Primer CSS is a free open-source CSS framework that is built upon systems that create the foundation of the basic style elements such as spacing, typography, and color. This systematic method makes sure our patterns are steady and interoperable with every other. Its approach to CSS is influenced by
    2 min read
  • Primer CSS Extended Spacing Scale
    Primer CSS is a free open-source CSS framework built on technologies that provide insights into key design elements like space, typeface, and color. This methodical approach guarantees that the patterns are both consistent and compatible. It's primarily useful and adaptable. It was made with the hel
    3 min read
  • CSS border-spacing Property
    The border-spacing Property is used to set the distance between the borders of neighboring cells in the Table. This property works only when the border-collapse property is set to no-collapse separate. Default Value: 2px Syntax: border-spacing: length|initial|inherit; Property values: length-length:
    2 min read
  • Primer CSS Tables
    Primer CSS is a free open-source CSS framework that is built upon systems that create the foundation of the basic style elements such as spacing, typography, and color. This systematic method makes sure our patterns are steady and interoperable with every other. Its approach to CSS is influenced by
    2 min read
  • Primer CSS Variables
    Primer CSS is a free open-source CSS framework built with the GitHub design system to support the broad spectrum of Github websites. It creates the foundation of the basic style elements such as spacing, typography, and color. This systematic method ensures our patterns are steady and interoperable
    10 min read
  • CSS white-space Property
    The white-space property in CSS is used to control text wrapping and white-space handling within elements. It allows developers to specify how whitespace inside an element is managed, impacting the layout and readability of the content. Several values can be used with this property to achieve differ
    7 min read
geeksforgeeks-footer-logo
Corporate & Communications Address:
A-143, 7th Floor, Sovereign Corporate Tower, Sector- 136, Noida, Uttar Pradesh (201305)
Registered Address:
K 061, Tower K, Gulshan Vivante Apartment, Sector 137, Noida, Gautam Buddh Nagar, Uttar Pradesh, 201305
GFG App on Play Store GFG App on App Store
Advertise with us
  • Company
  • About Us
  • Legal
  • Privacy Policy
  • In Media
  • Contact Us
  • Advertise with us
  • GFG Corporate Solution
  • Placement Training Program
  • Languages
  • Python
  • Java
  • C++
  • PHP
  • GoLang
  • SQL
  • R Language
  • Android Tutorial
  • Tutorials Archive
  • DSA
  • Data Structures
  • Algorithms
  • DSA for Beginners
  • Basic DSA Problems
  • DSA Roadmap
  • Top 100 DSA Interview Problems
  • DSA Roadmap by Sandeep Jain
  • All Cheat Sheets
  • Data Science & ML
  • Data Science With Python
  • Data Science For Beginner
  • Machine Learning
  • ML Maths
  • Data Visualisation
  • Pandas
  • NumPy
  • NLP
  • Deep Learning
  • Web Technologies
  • HTML
  • CSS
  • JavaScript
  • TypeScript
  • ReactJS
  • NextJS
  • Bootstrap
  • Web Design
  • Python Tutorial
  • Python Programming Examples
  • Python Projects
  • Python Tkinter
  • Python Web Scraping
  • OpenCV Tutorial
  • Python Interview Question
  • Django
  • Computer Science
  • Operating Systems
  • Computer Network
  • Database Management System
  • Software Engineering
  • Digital Logic Design
  • Engineering Maths
  • Software Development
  • Software Testing
  • DevOps
  • Git
  • Linux
  • AWS
  • Docker
  • Kubernetes
  • Azure
  • GCP
  • DevOps Roadmap
  • System Design
  • High Level Design
  • Low Level Design
  • UML Diagrams
  • Interview Guide
  • Design Patterns
  • OOAD
  • System Design Bootcamp
  • Interview Questions
  • Inteview Preparation
  • Competitive Programming
  • Top DS or Algo for CP
  • Company-Wise Recruitment Process
  • Company-Wise Preparation
  • Aptitude Preparation
  • Puzzles
  • School Subjects
  • Mathematics
  • Physics
  • Chemistry
  • Biology
  • Social Science
  • English Grammar
  • Commerce
  • World GK
  • GeeksforGeeks Videos
  • DSA
  • Python
  • Java
  • C++
  • Web Development
  • Data Science
  • CS Subjects
@GeeksforGeeks, Sanchhaya Education Private Limited, All rights reserved
We use cookies to ensure you have the best browsing experience on our website. By using our site, you acknowledge that you have read and understood our Cookie Policy & Privacy Policy
Lightbox
Improvement
Suggest Changes
Help us improve. Share your suggestions to enhance the article. Contribute your expertise and make a difference in the GeeksforGeeks portal.
geeksforgeeks-suggest-icon
Create Improvement
Enhance the article with your expertise. Contribute to the GeeksforGeeks community and help create better learning resources for all.
geeksforgeeks-improvement-icon
Suggest Changes
min 4 words, max Words Limit:1000

Thank You!

Your suggestions are valuable to us.

What kind of Experience do you want to share?

Interview Experiences
Admission Experiences
Career Journeys
Work Experiences
Campus Experiences
Competitive Exam Experiences