0

so I would like to remove the spacing between these buttons. But removing the margin doesn't do it.

When I go into Inspect, it also says that there is nothing there, so I don't get why it does this.

HTML:

* {
  margin: 0px;
  padding: 0px;
}
<input class="button" type="button" value="1">
<input class="button" type="button" value="2">
<input class="button" type="button" value="3">
<input class="button" type="button" value="4">
tacoshy
  • 10,642
  • 5
  • 17
  • 34
Tobias H.
  • 426
  • 1
  • 6
  • 18

3 Answers3

-1

Solution 1:

Add display: flex; to parent div.

.parent {
  display: flex;
}
<div class="parent">
  <input class="button" type="button" value="1">
  <input class="button" type="button" value="2">
  <input class="button" type="button" value="3">
  <input class="button" type="button" value="4">
</div>

Solution 2: Don't break line on HTML.

<input class="button" type="button" value="1"><input class="button" type="button" value="2"><input class="button" type="button" value="3"><input class="button" type="button" value="4">
Tuan Dao
  • 2,647
  • 1
  • 10
  • 20
-2

The simplest way is to put them all on one line:

<input class="button" type="button" value="1"><input class="button" type="button" value="2"><input class="button" type="button" value="3"><input class="button" type="button" value="4">

Other options include using floats or flexbox.

-2

Browsers always add spaces between some elements, like buttons. To remove these, you need to set font-size to zero, in their parent container. Then, to restore text size inside buttons, set font-size in them. Here's a snippet:

* {
  margin: 0px;
}

#parent {
  font-size: 0;
}

.button {
  font-size: 14px;
}
<div id="parent">
  <input class="button" type="button" value="1">
  <input class="button" type="button" value="2">
  <input class="button" type="button" value="3">
  <input class="button" type="button" value="4">
</div>
Dharman
  • 30,962
  • 25
  • 85
  • 135
MonoWolfChrome
  • 218
  • 2
  • 15