CSS Property: clear
[this page | pdf | back links]
The CSS (CSS1) clear property indicates on which
sides of an element a floating element is not allowed to float.
Valid property values
(other than inherit
and initial) are:
Value
|
Description
|
both
|
Floating elements not
allowed on either left or right side
|
left
|
Floating elements not
allowed on left side
|
none
|
(default value). Allows
floating elements on both sides
|
right
|
Floating elements not
allowed on right side
|
Default Value:
|
none
|
JavaScript syntax:
|
e.g. object.style.clear="both"
|
Inherited:
|
No
|
Animatable:
|
No
|
EXAMPLE:
HTML USED IN THIS EXAMPLE:
<!DOCTYPE html>
<html> <!-- Copyright (c) Nematrian Limited 2018 -->
<head>
<style>
img.x1 {float: left;}
</style>
</head>
<body>
Element with default property:<br>
<img class="x1" src="Pictures/Shape1.jpg">
<p>Some text</p><br>
<p>Some more text</p>
Element with property set by HTML:<br>
<img class="x1" src="Pictures/Shape1.jpg">
<p>Some text</p><br>
<p style="clear: both;">Some more text</p>
Property set with JavaScript:<br>
<img id="x2" src="Pictures/Shape1.jpg">
<p>Some text</p><br>
<p id="x3">Some more text</p><br>
<script>
document.getElementById("x2").style.float = "left";
document.getElementById("x3").style.clear = "both";
</script>
</body>
</html>
|
FUNCTION THAT MAY ASSIST IN TESTING WHETHER FEATURE IS SUPPORTED:
function isSupportedCSSPropertyClear() {
var x = document.createElement("DIV"); x.style.clear = "both"; return (window.getComputedStyle(x, null).clear == "both");
} |
NAVIGATION LINKS
Contents | Prev | Next | CSS Properties