Reputation: 30487
<!DOCTYPE html>
<meta charset="utf-8">
<html>
<body>
<div style="padding:0; margin:0;border-style:solid; border-color:red;">
<span style="padding:0; margin:0;border-style:solid; border-color:green;">Hi</span>
<span style="display:inline-block;padding:0; margin:0;border-width:1px; border-style:solid; border-color:blue;">Hello</span>
</div>
</body>
</html>
Why there is a space between "Hi" and "Hello" spans?
Upvotes: 1
Views: 102
Reputation: 2126
Another solution is to add floats to your spans Fiddle Here
<!DOCTYPE html>
<meta charset="utf-8">
<html>
<style type="text/css">
*{margin:0;padding:0;}
span{
float:left;
}
</style>
<body>
<div style="border-style:solid; border-color:red;height:20px;">
<span>Hi</span>
<span style="display:inline-block;border-width:1px;">Hello</span>
</div>
</body>
</html>
Upvotes: 0
Reputation: 19072
Line break = space
Instead of this
<span style="padding:0; margin:0;border-style:solid; border-color:green;">Hi</span>
<span style="display:inline-block;padding:0; margin:0;border-width:1px; border-style:solid; border-color:blue;">Hello</span>
Do this
<span style="padding:0; margin:0;border-style:solid; border-color:green;">Hi</span><span style="display:inline-block;padding:0; margin:0;border-width:1px; border-style:solid; border-color:blue;">Hello</span>
Your fiddle updated
These two examples will generate one space
1
<span>Hi</span> <span>Hello</span>
2
<span>Hi</span>
<span>Hello</span>
This one will not generate any space
<span>Hi</span><span>Hello</span>
Upvotes: 11