#1 Data Analytics Program in India
₹2,499₹1,499Enroll Now
4 min read
Question 38 of 49hard

How Do CSS Shapes Work?

Understanding text wrapping around shapes.

What You'll Learn

  • shape-outside property
  • Shape functions
  • Text wrapping

shape-outside

styles.cssCSS
.float-element {
  float: left;
  width: 200px;
  height: 200px;
  shape-outside: circle(50%);
}

Shape Functions

styles.cssCSS
.element {
  /* Circle */
  shape-outside: circle(50%);

  /* Ellipse */
  shape-outside: ellipse(100px 50px);

  /* Polygon */
  shape-outside: polygon(0 0, 100% 0, 100% 100%);

  /* From image alpha */
  shape-outside: url(shape.png);
}

With shape-margin

styles.cssCSS
.element {
  float: left;
  shape-outside: circle(50%);
  shape-margin: 20px; /* Space between shape and text */
}

Example

styles.cssCSS
.circle-image {
  float: left;
  width: 200px;
  height: 200px;
  border-radius: 50%;
  shape-outside: circle(50%);
  margin-right: 20px;
}