CSS Block Formatting Contexts Using the overflow property with a value different to visible

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Extensions
> Step 2: And Like the video. BONUS: You can also share it!

Example

img{
  float:left;
  width:100px;
  margin:0 10px;
}
.div1{
  background:#f1f1f1;
  /* does not create block formatting context */
}
.div2{
  background:#f1f1f1;
  overflow:hidden;
  /* creates block formatting context */
}

enter image description here

https://jsfiddle.net/MadalinaTn/qkwwmu6m/2/

Using the overflow property with a value different to visible (its default) will create a new block formatting context. This is technically necessary — if a float intersected with the scrolling element it would forcibly rewrap the content.

This example that show how a number of paragraphs will interact with a floated image is similar to this example, on css-tricks.com.

2: https://developer.mozilla.org/en-US/docs/Web/CSS/overflow MDN



Got any CSS Question?