Author -  Sai gowtham

Css remove whitespace between inline-block elements

In this tutorial, we are going to learn about how to remove white space between inline-block elements.

Consider we have html elements like this.

<ul>
    <li>First Item</li>
    <li>Second Item</li>
    <li>Third Item</li>
</ul>

Now, if we style these elements using css display:inline-block property we will see a white-space between list-item elements.

ul li{
  display:inline-block;
  background-color:yellow;
  color:black;
  padding:.5rem;
  font-size:1rem;
  margin-left:0;
}

white space css

Here are some ways to remove white space between these elements.

Removing white space using flex-box

In CSS3 we have a flex-box layout by using that we can place our elements in a horizontal line without having any white space.

Example:

ul{
  display:flex;
}

ul li{
  background-color:yellow;
  color:black;
  padding:.5rem;
  margin-left:0;
}

By adding a parent container display:flex all elements inside the parent are placed in a horizontal line.

Remove white space using font-size

We can also remove white space by setting parent element font-size to 0 and child elements font-size to 17px.

ul{
 font-size:0;
}

ul li{
  display:inline-block;
  background-color:yellow;
  color:black;
  padding:.5rem;
  font-size:17px;
  margin-left:0;
}

Here first, we removed font-size and again we set it back according to our visibility size.

Css Tutorials & Demos

How rotate an image continuously in CSS

In this demo, we are going to learn about how to rotate an image continuously using the css animations.

How to create a Instagram login Page

In this demo, i will show you how to create a instagram login page using html and css.

How to create a pulse animation in CSS

In this demo, i will show you how to create a pulse animation using css.

Creating a snowfall animation using css and JavaScript

In this demo, i will show you how to create a snow fall animation using css and JavaScript.

Top Udemy Courses

JavaScript - The Complete Guide 2023 (Beginner + Advanced)
JavaScript - The Complete Guide 2023 (Beginner + Advanced)
116,648 students enrolled
52 hours of video content
$14.99 FROM UDEMY
React - The Complete Guide (incl Hooks, React Router, Redux)
React - The Complete Guide (incl Hooks, React Router, Redux)
631,582 students enrolled
49 hours of video content
$24.99 FROM UDEMY
Vue - The Complete Guide (w/ Router, Vuex, Composition API)
Vue - The Complete Guide (w/ Router, Vuex, Composition API)
203,937 students enrolled
31.5 hours of video content
$14.99 FROM UDEMY