I do some tests on float and inline-block , and I noticed that there is a difference between them.
As you can see from THIS EXAMPLE that if I use display:inline-block , the div has a small margin between them, but if I use float:left , it works as expected.
Please note that I am using Eric Meyer Reset CSS v2.0.
This is because I am doing something wrong or this is how the inline-block behaves (in this case it is not very reliable).
HTML
<!DOCTYPE html> <html> <head> <title>How padding/margin affect floats</title> <link rel="stylesheet" href="css/reset.css"> <link rel="stylesheet" href="css/style.css"> </head> <body> <div id="wrap"> <div class="square"></div> <div class="square"></div> <div class="square"></div> <div class="square"></div> <div class="square"></div> </div> </body> </html>
CSS (no reset)
#wrap{ width: 600px; margin:auto; } .square{ width: 200px; height: 200px; background: red; margin-bottom: 10px; float:left; }
html css css-float
Tomer
source share