HTML DOM Style clear Property

HTMLWeb DevelopmentFront End Technology

The HTML DOM clear property is used for getting or setting the position of a floating element. It is used to specify whether an element should be moved below another floating element or not.

Following is the syntax for −

Setting the clear property −'none|left|right|both|initial|inherit'

The above properties are explained as follows −

leftElements are not floated on the left side.
rightElements are not floated on the right side
bothElements are not floated on neither left nor right side.
noneElements are floated on both sides and this is the default value.
inheritTo inherit the parent property value

Let us look at an example for the clear property −


 Live Demo

<!DOCTYPE html>
   img {
      margin: 5px;
      float: right;
      clear: both;
      border: 2px solid orange;
   function changeClear(){
      document.getElementById("Sample").innerHTML="The div clear property is changed to right from left ";
   <img src="">
   <div id="DIV1">This is sample text inside div. This is another line inside the div.Here is a div       containing some random english text. This div is created to demonstrate clear    property </div>
   <p>Change the above div clear property by clicking the below button</p>
   <button onclick="changeClear()">Change Clear</button>
   <p id="Sample"></p>


On clicking the “Change Clear” button −

Updated on 23-Oct-2019 07:47:23