Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

182
Views
HTML Buttons has different margin between placing on HTML and being created by JavaScript

I has problem when I place buttons in HTML directly, they display extra margin. But when I create them with JavaScript code, they display without margin.

const div = document.createElement("div");
   const doneBtn = document.createElement("button");
   doneBtn.innerText = "Done";
   const delBtn = document.createElement("button");
   delBtn.innerText = "Delete";
   div.append(doneBtn);
   div.append(delBtn);
   document.body.append(div);
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Minimal Todo List</title>
  </head>
  <body>
    <div>
      <button>Done</button>
      <button>Delete</button>
    </div>
  </body>
</html>

How can I make the output consistently the same. (Setting "margin:0" won't work)

about 4 years ago · Santiago Trujillo
1 answers
Answer question

0

You need to replace whitespaces in HTML or use proper CSS to remove the extra spaces. In JS, there are no extra spaces between buttons.

about 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!