Element on same line not causing space to appear in between buttons CSS

Viewed 1726

Can anyone explain this odd behavior, why extra spacing is adding in between buttons.

Case -

Following is the HTML code which is adding extra space in between buttons if written like this -

<div class="wrapper">
        <button class="btn one">First long button with a long text length</button>
        <button class="btn two">Second long button with a long text length</button>
    </div>

Output -

Space Between Buttons

BUT if I am writing like this then no space is coming -

Code -

<div class="wrapper">
        <button class="btn one">First long button with a long text length</button><button class="btn two">Second long button with a long text length</button>
    </div>

Output -

No Space Button

CSS Code -

* {
  margin: 0;
  padding: 0;
}

.wrapper {
  padding: 10px;
}

.btn {
  font-size: 14px;
  line-height: 28px;
  background: #FFFFFF;
  border: 1px solid #C3C3C3;
  position: relative;
  padding: 10px;
  display: inline;
}

.btn:before {
  content: "";
  position: absolute;
  width: 4%;
  height: 5px;
  background: #FFF;
  right: 0px;
  top: -5px;
}

.two {
  display: inline;
}
3 Answers
Related