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 =
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 =
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 =
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 =
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 =
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 =
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:

Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape,
GeeksforGeeks Courses are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out -
check it out now!
Last Updated :
23 Mar, 2022
Like Article
Save Article