There appears to be spacing between the Label and Button when created via HTML, but not when generated dynamically through JS. Surprisingly, the CSS in the browser remains unchanged.
https://i.sstatic.net/lIvWf.png
Could it be due to the HTML tags being on separate lines, creating a perceived 'space' between them? When placed on the same line, the result mirrors the outcome of the JavaScript equivalent.
So how can this be replicated using JavaScript? Using a br
element causes the button to shift to a new line, which is undesired in this context.
const label = document.createElement("label");
label.htmlFor = `cash3`;
label.textContent = `Week 3:`
const delBtn = document.createElement("button");
<label for="cash1">Week 1:</label>
<button>Del</button>