I have an HTML code like this:
<div id="user-nav">
<button class="btn btn-primary btn-sm">Subscribe Now</button>
<button class="btn btn-primary btn-sm">Log In</button>
</div>
And then I tried to create the same thing with JavaScript:
// usernav - subscribe, login, settings
var subbtn = document.createElement("button");
subbtn.className = "btn btn-primary btn-sm";
subbtn.textContent = "Subscribe Now";
usernav.appendChild(subbtn);
var loginbtn = document.createElement("button");
loginbtn.className = "btn btn-primary btn-sm";
loginbtn.textContent = "Log In";
usernav.appendChild(loginbtn);
My JavaScript code works perfectly fine.
However, there is a minor difference in that, the buttons produced by JavaScript are touching each other, whereas when I just coded in HTML, there is a small gap between the two buttons.
When I inspect the element of two pages, the code is the same.
Why does this happen, and how can I produce the exact same result on JavaScript?