Please see the HTML code below:
#search
{
display:inline;
margin:100px;
}
<!doctype html>
<html>
<head>
<link rel="stylesheet" href="styles.css" />
</head>
<body>
<span class="child">
<input type="text" name="submit" id="submit">
</span>
<span class="child">
<input type="text" name="search" id="search">
</span>
</body>
</html>
If I change the two span elements to divs then I see this:
The div result (second screenshot) is what I would expect, however it involves nesting an inline element (input) inside a block level element (div), which I believe is illegal.
Why does the top margin of one element (id of: search) also affect another element (id of: submit) when using spans?
I have spent a few hours Googling this and understanding the difference between spans and divs, however I have not found an answer. There was another question on here similar with a comment from someone that just said: "collapse it".