Reputation: 15787
Please see the HTML below:
<!doctype html>
<html>
<head>
<link rel="stylesheet" href="styles.css" />
</head>
<body>
<span class="child">
<input type="text" name="submit" id="submit">
<input type="text" name="search" id="search">
</span>
</body>
</html>
and the css below:
#search
{
display:inline;
margin:100px;
}
It does seem to be respecting the top and bottom margin as shown below:
Why are the top and bottom margins respected? This question seems to suggest that inline elements should not respect the top and bottom margins: Why margin top and bottom is missing?
Also, I am tring to understand when to use a div and when to use a span and have come up with this:
Upvotes: 0
Views: 152
Reputation: 272703
From the specification
These properties have no effect on non-replaced inline elements.
input
is a replaced inline element (https://html.spec.whatwg.org/multipage/rendering.html#replaced-elements)
I am tring to understand when to use a
div
and when to use aspan
There is no generic rule, the only rule you need to know is to never put block
element inside inline
element. This will lead to some unexpected and non intuitive behavior
Upvotes: 2