Suppose that is because of line break characters after each closing tag. Those are handled as spaces in HTML. Try to remove them. Here are few demos:
http://jsfiddle.net/eeRFC/ - with spaces
test
test
test
http://jsfiddle.net/eeRFC/1/ - with no spaces
test
test
test
And common CSS:
div {
border:solid 1px black;
display:inline-block;
}