×

Tailwind CSS Padding

This class accepts a large number of values, and all of the properties are covered in class form. It's a replacement for the CSS Padding Property. This class is used to generate space inside any defined boundary around the element.

Different padding can be selected for each side (top, right, bottom, left). To implement padding properties, border properties must be included. CSS padding-top, CSS padding-bottom, CSS padding-right, CSS padding-left, and so on are all CSS padding properties.

Padding classes

  • p-0: The padding on all sides is defined by this class.
  • py-0: The padding-top and padding-bottom properties on the y-axis are defined by this class.
  • px-0: This class is used to specify x-axis padding, such as padding-left and padding-right.
  • pt-0: This class is used to provide padding to the top of the page.
  • pr-0: This class is used to add right-hand padding.
  • pb-0: This class is used to add padding to the bottom of the page.
  • pl-0: This class is used to add padding to the left side of the page.

Note: You can replace "0" with any of the allowed "rem" values.

p-0

The padding on all sides is defined by this class.

Syntax:

<element class="p-0">...</element>

Example:

<!DOCTYPE html>
<head>
    <link href=
"https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css"
          rel="stylesheet">
</head>
<body class="text-center">
    <h1 class="text-red-600 text-5xl font-bold">
        Tutorial and Example
    </h1>
    <b>Padding Class - Tailwind CSS </b>
    <div class="flex justify-center">
    <div class="p-4 bg-red-300 w-24 h-24">
        <div class="border-2 border-red-800
                    bg-red-600 w-16 h-16">
             
        </div>
    </div>
    </div>
</body>
</html>

Output:

Tailwind CSS Padding

py-0

The padding-top and padding-bottom properties on the y-axis are defined by this class.

Syntax:

<element class="py-0">...</element>

Example:

<!DOCTYPE html>
<head>
    <link href=
"https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css"
          rel="stylesheet">
</head>
<body class="text-center">
    <h1 class="text-red-600 text-5xl font-bold">
       Tutorial and Example
    </h1>
    <b>Padding Class - Tailwind CSS </b>
    <div class="flex justify-center">
    <div class="py-4 bg-red-300 w-24 h-24">
        <div class="border-2 border-red-800
                    bg-red-600 w-16 h-16">
             
        </div>
    </div>
    </div>
</body>
</html>

Output:

Tailwind CSS Padding

px-0

This class is used to specify x-axis padding, such as padding-left and padding-right.

Syntax:

<element class="px-0">...</element>

Example:

<!DOCTYPE html>
<head>
    <link href=
"https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css"
          rel="stylesheet">
</head>
<body class="text-center">
    <h1 class="text-red-600 text-5xl font-bold">
       Tutorial and Example
    </h1>
    <b>Padding Class - Tailwind CSS </b>
    <div class="flex justify-center">
    <div class="px-4 bg-red-300 w-24 h-24">
        <div class="border-2 border-red-800
                    bg-red-600 w-16 h-16">
             
        </div>
    </div>
    </div>
</body>
</html>

Output:

Tailwind CSS Padding

pt-0

This class is used to provide padding to the top of the page.

Syntax:

<element class="pt-0">...</element>

Example:

<!DOCTYPE html>
<head>
    <link href=
"https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css"
          rel="stylesheet">
</head>
<body class="text-center">
    <h1 class="text-red-600 text-5xl font-bold">
       Tutorial and Example
    </h1>
    <b>Padding Class - Tailwind CSS </b>
    <div class="flex justify-center">
    <div class="pt-4 bg-red-300 w-24 h-24">
        <div class="border-2 border-red-800
                    bg-red-600 w-16 h-16">
             
        </div>
    </div>
    </div>
</body>
</html>

Output:

Tailwind CSS Padding

pr-0

This class is used to add right-hand padding.

Syntax:

<element class="pr-0">...</element>

Example:

<!DOCTYPE html>
<head>
    <link href=
"https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css"
          rel="stylesheet">
</head>
<body class="text-center">
    <h1 class="text-red-600 text-5xl font-bold">
       Tutorial and Example
    </h1>
    <b>Padding Class - Tailwind CSS </b>
    <div class="flex justify-center">
    <div class="pr-4 bg-red-300 w-24 h-24">
        <div class="border-2 border-red-800
                    bg-red-600 w-16 h-16">
             
        </div>
    </div>
    </div>
</body>
</html>

Output:

Tailwind CSS Padding

pb-0

This class is used to add padding to the bottom of the page.

Syntax:

<element class="pb-0">...</element>

Example:

<!DOCTYPE html>
<head>
    <link href=
"https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css"
          rel="stylesheet">
</head>
<body class="text-center">
    <h1 class="text-red-600 text-5xl font-bold">
       Tutorial and Example
    </h1>
    <b>Padding Class - Tailwind CSS </b>
    <div class="flex justify-center">
    <div class="pb-4 bg-red-300 w-24 h-24">
        <div class="border-2 border-red-800
                    bg-red-600 w-16 h-16">
             
        </div>
    </div>
    </div>
</body>
</html>

Output:

Tailwind CSS Padding

pl-0

This class is used to add padding to the left side of the page.

Syntax:

<element class="pl-0">...</element>

Example:

<!DOCTYPE html>
<head>
    <link href=
"https://unpkg.com/tailwindcss@^1.0/dist/tailwind.min.css"
          rel="stylesheet">
</head>
<body class="text-center">
    <h1 class="text-red-600 text-5xl font-bold">
       Tutorial and Example
    </h1>
    <b>Padding Class - Tailwind CSS </b>
    <div class="flex justify-center">
    <div class="pl-8 bg-red-300 w-24 h-24">
        <div class="border-2 border-red-800
                    bg-red-600 w-16 h-16">
             
        </div>
    </div>
    </div>
</body>
</html>

Output:

Tailwind CSS Padding

Related Topics

Tailwind CSS Place Content

This class accepts a wide range of values. It's a replacement for the CSS Place Content property. This class is used to manage how information is justified while still being...

5 minutes read.

Tailwind CSS Object Position

It acknowledges more than one value in tailwind CSS. Every one of the properties is covered as in class form. It is the option in contrast to the CSS object-position...

2 minutes read.

Tailwind CSS Clear

This class acknowledges more than one worth in tailwind CSS. Every one of the properties is canvassed as in class form. It is an option in contrast to the CSS...

5 minutes read.

Tailwind CSS Top / Right / Bottom / Left

In tailwind CSS, these classes take a variety of values and cover all of the characteristics in the class form. These are the CSS Top/Right/Bottom/Left properties' replacements. These classes are...

4 minutes read.

Tailwind CSS Grid Auto Flow

In tailwind CSS, this class accepts multiple values, and all of the properties are covered in class form. It is a CSS alternative. The grid-auto-flow property is used in Tailwind...

4 minutes read.

Tailwind CSS Installation

Here, we will discuss the installation method of Tailwind CSS using two strategies discussed as follows: Strategy 1: Install Tailwind through npm Step 1: npm init - y Step 2: npm install tailwindcss Step...

2 minutes read.

Tailwind CSS Grid Row Start / End

In tailwind CSS, this class takes several values. All of the attributes are covered in the form of a class. In CSS, it's an alternative to the grid-row attribute. It's...

4 minutes read.

Tailwind CSS Flex Direction

CSS flexbox is an important element for frontend development. CSS has four directions, therefore in tailwind CSS, all of the properties are covered in class form. It's a front-end development...

5 minutes read.

Tailwind CSS Object Fit

It acknowledges more than one value in tailwind CSS. Every one of its properties is covered as in class form. It is the option in contrast to the CSS object-fit...

4 minutes read.

Tailwind CSS Flex

CSS flexbox is an important component for frontend development. There are four flex options in Tailwind CSS, and all of the attributes are covered in class form. It's a front-end...

6 minutes read.

Tailwind CSS Min-Height

In tailwind CSS, this class accepts a large number of values, and all of the properties are covered in class form. It's a replacement for the CSS Min-Height Property. It...

2 minutes read.

Tailwind CSS Flex Grow

CSS flexbox is an important element for frontend development; there are two flex-grow options in Tailwind CSS, and all attributes are covered in class form. It is an alternative to...

3 minutes read.

Tailwind CSS Box Sizing

Tailwind CSS Box sizing class acknowledges more than one worth in tailwind CSS. Each property is shrouded as a class structure. It is an option in contrast to the CSS...

2 minutes read.

Tailwind CSS Grid Auto Rows

In tailwind CSS, this class takes multiple values and covers all of the properties in class form. It's a replacement for the grid-auto-rows CSS attribute. The size of the rows...

6 minutes read.

Tailwind CSS Gap

In tailwind CSS, this class accepts multiple values, and all of the properties are covered in class form. It's a replacement for the CSS gap attribute. This class is used...

4 minutes read.

Tailwind CSS Z-index

The tailwind CSS framework is a CSS utility framework that provides classes for managing HTML content with CSS. Tailwind CSS simplifies our design process and makes it responsive across numerous...

4 minutes read.

Tailwind CSS Min-Width

In tailwind CSS, this class accepts a large number of values, and all of the properties are covered in class form. It's a replacement for the CSS min-width property. This...

1 minute read.

Tailwind CSS Align Items

In tailwind CSS, this class accepts a wide range of values. It's a replacement for the CSS Align Items attribute. This class is used to align things within the flexible...

5 minutes read.

Tailwind CSS Flex Shrink

CSS flexbox is an important element for frontend development. There are two flex-shrink options in Tailwind CSS, and all properties are covered in class form. For quick front-end development, it's...

3 minutes read.

Tailwind CSS Stroke Width

In tailwind CSS, this class takes a large number of values and all of the properties are covered in the form. It is used to specify the width of an...

1 minute read.