The correct answer upstairs is because your line breaks are occupying space. Both inline and inline-block elements have this problem. After you use float: left, you have actually turned it into a block element. There are many solutions. You can read Zhang Xuxin’s old article http://www.zhangxinxu.com/wordpress/2012/04/inline-block-space-remove-%E5%8E%BB%E9%99%A4%E9%97% B4%E8%B7%9D/
Because the line break in the HTML code will also display a small space, there is no need to add float
if the following is written on one lineThe correct answer upstairs is because your line breaks are occupying space. Both inline and inline-block elements have this problem. After you use float: left, you have actually turned it into a block element. There are many solutions. You can read Zhang Xuxin’s old article http://www.zhangxinxu.com/wordpress/2012/04/inline-block-space-remove-%E5%8E%BB%E9%99%A4%E9%97% B4%E8%B7%9D/
There are spaces or line breaks between tags causing spacing between inline elements