Bootstrap 4 | Typography

Typography is a feature of Bootstrap for styling and formatting the text content. It is used to create customized headings, inline subheadings, lists, paragraphs, aligning, adding more design-oriented font styles and much more. Bootstrap support global settings for the font stack, Headings and Link styles to be used in the web app for every type of OS and Device to deliver the best user interface.

Typography can be used to create:

  • Headings
  • Subheadings
  • Text and Paragraph font color, font type and alignment
  • Lists
  • Other inline elements

Tags and class to implement typography feature in bootstrap:



  • display headings: It is used to create better headings (larger font-size and lighter font-weight). There are four classes exists in display headings which are .display-1, .display-2, .display-3, and .display-4.
  • lead: It is used to make a paragraph stand out i.e. visually better.
  • mark: It is used to highlight the text content.
  • initialism: It is used to render abbreviation in slightly small text size.
  • blockquote: It is used to quote the text content.
  • blockquote-footer: It is used to add the footer details for identifying the source of the Quote.
  • text-center: It is used to align the text to the center.
  • list-inline: It is used to make the element of list inline.
  • text-truncate: It is used to shorten the longer text by truncating with an ellipsis.
  • text-muted: It is used for text color, text-muted fades the text i.e. text greyed out.
  • text-uppercase: It is used to transform text into uppercase.
  • text-lowercase: It is used to transform text into lowercase.
  • text-capitalize: It is used to transform text to capitalize first letter of each word leaving other letters in lowercase.
  • .font-weight-bold: It sets the font weight to bold. It is used to display the importance of text.
  • .font-weight-bolder: It sets the font weight to deep bold. It is used to display the importance of text.
  • .font-italic: It sets the font style to italic.
  • .font-weight-light: It sets the font weight to light.
  • .font-weight-lighter: It sets the lighter font weight.
  • .font-weight-normal: It sets the normal font size and weight.
  • .lead: It makes the paragraph stand out.
  • .small: It is used to create secondary subheadings.
  • .text-left: It sets the left alignment of text.
  • .text-*-left: It sets the left alignment of text on all screens (small, medium, large or xlarge).
  • .text-break: It breaks the long string text into short text substrings.

Example 1: This example uses heading class to display the heading.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html lang="en">
      
<head>
    <title>
        Bootstrap Typography example
    </title>
    
    <meta charset="utf-8">
    
    <meta name="viewport" 
        content="width=device-width, initial-scale=1">
      
    <link rel="stylesheet" href=
    <script src=
    </script>
    <script src=
    </script>
    <script src=
    </script>
</head>
  
<body>
    <div class="container">
        <h1>Heading Lists</h1>
        <h1 class="display-1">GeeksforGeeks</h1>
        <h1 class="display-2">GeeksforGeeks</h1>
        <h1 class="display-3">GeeksforGeeks</h1>
        <h1 class="display-4">GeeksforGeeks</h1>
    </div>
  
</body>
</html>

chevron_right


Output:

Example 2: This example uses <mark> tag to display the importance of text.

filter_none

edit
close

play_arrow

link
brightness_4
code

<!DOCTYPE html>
<html lang="en">
      
<head>
    <title>
        Bootstrap Typography example
    </title>
    
    <meta charset="utf-8">
    
    <meta name="viewport" 
        content="width=device-width, initial-scale=1">
      
    <link rel="stylesheet" href=
    <script src=
    </script>
    <script src=
    </script>
    <script src=
    </script>
</head>
  
<body>
    <div class="container">
        <h1>GeeksforGeeks</h1>    
        <p>A <mark>computer science</mark> portal for geeks</p>
    </div>
</body>
</html>

chevron_right


Output:



My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.




Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.