-2

One doubt:

I give float:left for the div and put another block element such as h3 inside the div. Then it gives padding top and bottom. If i remove float: left it wont give padding.

html

<div class="one"><h3>Test with Float</h3></div>
<div class="clear">&nbsp;</div>
<div class="two"><h3>Test without Float</h3></div>

css

.one{
    background: grey;
    float:left;
    width: 100%;
}
.two{
    background: #DAD5C1;
      width: 100%;
}
.clear{
    clear: both;
}

http://jsfiddle.net/7yh3kuea/

rnrneverdies
  • 15,243
  • 9
  • 65
  • 95
Rahul
  • 35
  • 1

1 Answers1

0

It isn't padding but it is margin which is ignored in no-floated element.

More informations is here.

Community
  • 1
  • 1
marek094
  • 424
  • 2
  • 11