Open In App

Primer CSS Typographic Utilities

Primer CSS is a free open-source CSS framework based on principles that lay the groundwork for basic design components including spacing, font, and color. This strategy ensures that our patterns are consistent and compatible with one another. Object-Oriented CSS principles, functional CSS, and BEM architecture all affect its CSS approach. It is extremely reusable and adaptable. It was made using the GitHub design system. Primer CSS is Obvious and transparent.

In this article, we are going to discuss the typographic utilities that are provided in Primer CSS. Typography is one of the most important aspects of a web page’s appearance. A good choice of typography style and sizes can change the whole aspect of a webpage.  



Primer CSS Typographic Utilities and Used Classes:

Heading Utilities: Mainly used to style and customize the headings as we want.



Even if we add an “h2” class to an h3 element, the h3 element will act and look like an h2 element. 

Syntax:

<p class="h1">. . . .</p>

Line Height Utilities:  The usage of these utility classes is mainly used to specify the amount of space between the lines of an element.

Syntax:

<p class="lh-condensed">. . . .</p>

Typographic Styles Utilities: This is used to customize the texts on the webpage.

Syntax:

<p class="text-underline">. . . .</p>

Word-break: The two word-break utility classes are used to specify how the line will break when the words meet the end.

Syntax:

<p class="wb-break-all">. . . .</p>

Align Utilities: This utility is used to align the text.

Syntax:

<p class="text-center">. . . .</p>

Example 1: In the code below the heading is underlined and is in italic using the h2, text-italic, and text-underline.




<!DOCTYPE html>
<html>
  
<head>
    <title>Primer CSS Typographic Utilities</title>
    <link rel="stylesheet" href=
"https://unpkg.com/@primer/css@^18.0.0/dist/primer.css" />
</head>
  
<body>
    <div class="ml-2">
        <h1 class="color-fg-success">
            GeeksforGeeks
        </h1>
          
        <h3>
            Primer CSS Typographic Utilities
        </h3> <br />
    </div>
  
    <p class="h2 text-italic text-underline m-4 ">
        GeeksforGeeks
    </p>
  
</body>
  
</html>

Output:
 

 

Example 2: This example demonstrates the implementation of Primer CSS Typographic Utilities.




<!DOCTYPE html>
<html>
  
<head>
    <title>Primer CSS Typographic Utilities</title>
    <link rel="stylesheet" href=
"https://unpkg.com/@primer/css@^18.0.0/dist/primer.css" />
</head>
  
<body>
    <div class="ml-2">
        <h1 class="color-fg-success">
            GeeksforGeeks
        </h1>
        <h3>
            Primer CSS Typographic Utilities
        </h3><br />
    </div>
  
    <p class="lh-condensed text-semibold 
              text-uppercase text-center m-4 ">
        A Computer Science portal for geeks.
        It contains well written, well thought
        and well explained computer science and
        programming articles.
    </p>
  
</body>
  
</html>

Output:

 

 
Reference: https://primer.style/css/utilities/typography/


Article Tags :