clear Property - Javascript CSS Style Property

Javascript examples for CSS Style Property:clear

Description

The clear property sets or gets the position of the element relative to floating objects.

Property Values

Value Description
leftclear left floats.
right clear right floats.
bothclear both left and right floats.
autoDoesn't clear any floated elements. This is default.
initial Sets this property to its default value.
inherit take the value of its parent element clear property.

Technical Details

Item Value
Default Value: none
Return Value: A String, representing the position of an element relative to floating objects
CSS VersionCSS1

Get the clear value of a <p> element:

Demo Code

ResultView the demo in separate window

<!DOCTYPE html>
<html>
<body>

<img style="float:left;" src="http://java2s.com/resources/c.png" width="100" height="132">

<p id="myP" style="clear:left;">This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.</p>

<button type="button" onclick="myFunction()">Return the value of the clear property</button>

<script>
function myFunction() {/* ww  w.j  a  va  2 s.com*/
    console.log(document.getElementById("myP").style.clear);
}
</script>

</body>
</html>

Related Tutorials