Tailwind CSS Space Between

23 Mar, 2022
This class accepts lots of values in tailwind CSS in which all the properties are covered as in class form. It is the alternative to the CSS Space Between property. This class is used for controlling the space between child elements.
Space Between classes:
space-y-0
space-y-reverse
-space-y-0
space-x-0
space-x-reverse
-space-x-0
Note: You can change the number “0” with the valid “rem” values.
space-y-0: This class is used to perform space on the y-axis.
Syntax:
<element class="space-y-0">...</element>
Example:
HTML
<!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-green-600 text-5xl font-bold">        GeeksforGeeks    </h1>     <b>Tailwind CSS Space Between Class</b>     <div class="mx-4 space-y-4">        <div class="bg-green-400 h-16 rounded-lg                     border-2 border-green-800">1</div>        <div class="bg-green-400 h-16 rounded-lg                     border-2 border-green-800">2</div>        <div class="bg-green-400 h-16 rounded-lg                     border-2 border-green-800">3</div>        <div class="bg-green-400 h-16 rounded-lg                     border-2 border-green-800">4</div>    </div></body>   </html>
Output:
space-y-reverse: This class is used to perform reverse spacing on the y-axis, but have to use the flex-reverse class before that.
Syntax:
<element class="space-y-reverse">...</element>
Example:
HTML
<!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-green-600 text-5xl font-bold">        GeeksforGeeks    </h1>     <b>Tailwind CSS Space Between Class</b>     <div class="mx-4 flex flex-col-reverse space-y-4                 space-y-reverse">        <div class="bg-green-400 h-16 rounded-lg">1</div>        <div class="bg-green-400 h-16 rounded-lg">2</div>        <div class="bg-green-400 h-16 rounded-lg">3</div>        <div class="bg-green-400 h-16 rounded-lg">4</div>    </div></body>   </html>
Output:
-space-y-0: This class is used for negative spacing on the x-axis. By using this class we can place one element inside another element.
Syntax:
<element class="-space-y-0">...</element>
Example:
HTML
<!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-green-600 text-5xl font-bold">        GeeksforGeeks    </h1>     <b>Tailwind CSS Space Between Class</b>     <div class="mx-4 -space-y-4">        <div class="bg-green-400 h-16 rounded-lg                     border-2 border-green-800">1</div>        <div class="bg-green-400 h-16 rounded-lg                     border-2 border-green-800">2</div>        <div class="bg-green-400 h-16 rounded-lg                     border-2 border-green-800">3</div>        <div class="bg-green-400 h-16 rounded-lg                     border-2 border-green-800">4</div>    </div></body>   </html>
Output:
space-x-0: This class is used to perform space on the x-axis.
Syntax:
<element class="space-y-0">...</element>
Example:
HTML
<!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-green-600 text-5xl font-bold">        GeeksforGeeks    </h1>     <b>Tailwind CSS Space Between Class</b>     <div class="ml-48 flex space-x-4">        <div class="bg-green-400 w-20 h-16 rounded-lg">1</div>        <div class="bg-green-400 w-20 h-16 rounded-lg">2</div>        <div class="bg-green-400 w-20 h-16 rounded-lg">3</div>        <div class="bg-green-400 w-20 h-16 rounded-lg">4</div>    </div></body>   </html>
Output:
space-x-reverse: This class is used to perform reverse spacing on the x-axis, but have to use the flex-reverse class before that.
Syntax:
<element class="space-y-reverse">...</element>
Example:
HTML
<!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-green-600 text-5xl font-bold">        GeeksforGeeks    </h1>     <b>Tailwind CSS Space Between Class</b>     <div class="ml-48 flex flex-row-reverse space-x-4                 space-x-reverse">        <div class="bg-green-400 w-20 h-16 rounded-lg">1</div>        <div class="bg-green-400 w-20 h-16 rounded-lg">2</div>        <div class="bg-green-400 w-20 h-16 rounded-lg">3</div>        <div class="bg-green-400 w-20 h-16 rounded-lg">4</div>    </div></body>   </html>
Output:
-space-x-0: This class is used for negative spacing on the x-axis by using this class we can place one element inside another element.
Syntax:
<element class="-space-y-0">...</element>
Example:
HTML
<!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-green-600 text-5xl font-bold">        GeeksforGeeks    </h1>     <b>Tailwind CSS Space Between Class</b>     <div class="ml-48 flex -space-x-4">        <div class="bg-green-400 w-20 h-16 rounded-lg                     border-2 border-green-800">1</div>        <div class="bg-green-400 w-20 h-16 rounded-lg                     border-2 border-green-800">2</div>        <div class="bg-green-400 w-20 h-16 rounded-lg                     border-2 border-green-800">3</div>        <div class="bg-green-400 w-20 h-16 rounded-lg                     border-2 border-green-800">4</div>    </div></body>   </html>
Output:
Tailwind CSS
Tailwind-Spacing
Web Technologies
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.