CSS Float - inherit Property



Description

The floated state of an element can be inherited from its parent element. This means that if the parent element is floated, then the child elements will also be floated.

Possible Values

  • inherit − Inherits the float property value from its parent element.

Applies to

All the HTML elements.

DOM Syntax

float: inherit;

Example

Here is the example which shows effect of this property −

<html>
<head>
<style>
   .parent {
      float: left;
      border: 2px solid #f0610e;
      padding: 5px;
      height: 160px;
      background-color: #86f00e;
   }
   .tutimg {
      float: inherit;
      border: 3px solid #f0610e;
      margin-right: 10px;
   }
</style>
</head>
<body>
   <div class="parent">
      <img class="tutimg" src="images/tutimg.png" width="150" height="150" />
      There are many variations of passages of Lorem Ipsum available, but the majority have suffered alteration in
      some form, by injected humour, or randomised words which don't look even slightly believable. If you are
      going to use a passage of Lorem Ipsum, you need to be sure there isn't anything embarrassing hidden in the middle
      of text. All the Lorem Ipsum generators on the Internet tend to repeat predefined chunks as necessary, making
      this the first true generator on the Internet.
   </div>
</body>
</html>
Advertisements