Possible duplicate:
Ignore spaces in HTML
I am creating a Dutch recipe site. The problem is a visual error that occurs when adding new form fields through Javascript.
In case of a problem
To describe all the necessary ingredients, I allow the user to add additional fields of the form of ingredients to the existing ones that are predefined HTML. You can add these new fields by clicking the "Add another ingredient" button. A javascript function called addIngredient () is called onclick (it is truncated for clarity, the full code can be found here ):
function addIngredient() { ingredientCount++; //define the elements that should be created var Group = document.createElement("span"); var Quantity = document.createElement("input"); var Unit = document.createElement("input"); var Type = document.createElement("input"); var lineBreak = document.createElement("br"); //set the attributes for each element Group.setAttribute("id", "ingredient_" + ingredientCount); Quantity.setAttribute("type", "text"); Unit.setAttribute("type", "text"); Type.setAttribute("type", "text"); //add the ingredient group span and linebreak to the ingredients div var ingredientList = document.getElementById("ingredienten"); ingredientList.appendChild(Group); ingredientList.appendChild(lineBreak); //add the ingredient form elements to the ingredient group span var addElements = document.getElementById("ingredient_" + ingredientCount); addElements.appendChild(Quantity); addElements.appendChild(Unit); addElements.appendChild(Type); }
What will happen
Input elements added via JavaScript have different spacing between them, created in advance using HTML. Here is a screen shot showing a visual error:

This excess distance disappears when I remove my results from HTML by defining input elements that were created in advance.
with return:
<span> <input> <input> <input> </span><br>
no refund:
<span> <input><input><input> </span><br>
This leads me to the conclusion that elements created using HTML actually affect the span or position by the way I write my code. Form elements created using Javascript, of course, are generated without any line breaks, so there are no such excess spaces.
My question
Honestly, I'm a little shocked that returning to my HTML seems to lead to some spacing on the web page. Itβs funny to me that formatting the code will add things to the page. I do not want to delete the returned data in my code so that this does not happen.
Is there any other way besides deleting the returned data from my code to make sure that these spaces between my form elements are not showing?