HTML | DOM Style clear Property
The DOM Style clear property in HTML is used to set or get the position of the specific element relative to floating objects.
Syntax
- To set clear property:
object.style.clear = "none|left|right|both|initial|inherit"
- To get clear property:
object.style.clear
Properties Value:
| value | description |
|---|---|
| left | Does not allow floating entities on the left of the element |
| right | Does not allow floating entities on the right of the element |
| both | Does not allow floating entities on the left or right of the element |
| none | Allows floating entities on the left of the element as well as on the right of the element.This is default |
| initial | Sets the value of the property to its default value. |
| inherit | Inherits the value of this property i.e sets the value same as that of the parent |
Return Value: It returns a string representing the position of an element relative to floating objects.
Example-1:
<!DOCTYPE html> <html> <head> <style> img { float: left; } </style> </head> <body> <img src= width="150" height="150"> <p id="P" style="color:green"> GEEKSFORGEEKS PARAGRAPH HERE GEEKSFORGEEKS PARAGRAPH HERE GEEKSFORGEEKS PARAGRAPH HERE GEEKSFORGEEKS PARAGRAPH HERE GEEKSFORGEEKS PARAGRAPH HERE GEEKSFORGEEKS PARAGRAPH HERE GEEKSFORGEEKS PARAGRAPH HERE GEEKSFORGEEKS PARAGRAPH HERE GEEKSFORGEEKS PARAGRAPH HERE</p> <button type="button" onclick="myFunction()"> Clear left side of text</button> <script> function myFunction() { document.getElementById( "P").style.clear = "left"; } </script> </body> </html> |
chevron_right
filter_none
Output:
- Before Click:
- After Click:
- Before Click:
- After Click:
- Before Click:
- After Click:
- Google Chrome
- Mozilla Firefox
- Edge
- Safari
- Opera
- HTML | DOM Style top Property
- HTML | DOM Style right Property
- HTML | DOM Style borderRadius Property
- HTML | DOM Style width Property
- HTML DOM | Style paddingRight Property
- HTML DOM | Style pageBreakBefore Property
- HTML | DOM Style overflow Property
- HTML | DOM Style outlineStyle Property
- HTML | DOM Style padding Property
- HTML | DOM Style columnCount Property
- HTML | DOM Style textIndent Property
- HTML | DOM Style columnRuleColor Property
- HTML | DOM Style paddingLeft Property
- HTML | DOM Style outlineOffset Property
- HTML | DOM Style userSelect Property
Example-2:
<!DOCTYPE html> <html> <head> <style> img { float: right; } </style> </head> <body> <img src= width="150" height="150"> <p id="P" style="color:green"> GEEKSFORGEEKS PARAGRAPH HERE GEEKSFORGEEKS PARAGRAPH HERE GEEKSFORGEEKS PARAGRAPH HERE GEEKSFORGEEKS PARAGRAPH HERE GEEKSFORGEEKS PARAGRAPH HERE GEEKSFORGEEKS PARAGRAPH HERE GEEKSFORGEEKS PARAGRAPH HERE GEEKSFORGEEKS PARAGRAPH HERE GEEKSFORGEEKS PARAGRAPH HERE</p> <button type="button" onclick="myFunction()"> Clear right side of text</button> <script> function myFunction() { document.getElementById( "P").style.clear = "right"; } </script> </body> </html> |
chevron_right
filter_none
Output:
Example-3:
<!DOCTYPE html> <html> <head> <style> img { float: right; } #i { float: left; } </style> </head> <body> <img src= width="150" height="150"> <img id="i" src= width="150" height="150"> <p id="P" style="color:green"> GEEKSFORGEEKS PARAGRAPH HERE GEEKSFORGEEKS PARAGRAPH HERE </p> <button type="button" onclick="myFunction()"> Clear left and right side of text </button> <script> function myFunction() { document.getElementById( "P").style.clear = "both"; } </script> </body> </html> |
chevron_right
filter_none
Output:
Supported Browsers:
Recommended Posts:
If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.
Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.



