clear Attribute | clear Property
Gets or sets whether the object allows floating objects on its left side, right side, or both, so that the next text displays past the floating objects.
Syntax
CSS { clear : sClear } Scripting [ sClear = ] object.style.clear [ = sClear ]
Possible Values
sClear String that specifies or receives one of the following values.
- none
- Default. Floating objects are allowed on both sides.
left- Object is moved below any floating object on the left side.
right- Object is moved below any floating object on the right side.
both- Object is moved below any floating object.
The property is read/write for all objects except the following, for which it is read-only: currentStyle. The property has a default value of none. The Cascading Style Sheets (CSS) attribute is not inherited.
DHTML expressions can be used in place of the preceding value(s). As of Internet Explorer 8, expressions are supported in IE7 Standards mode and IE5 (Quirks) mode only. For more information, see About Dynamic Properties and Defining Document Compatibility.
Remarks
The value of this property lists the sides where floating objects are not accepted.
Examples
The following examples use the clear attribute and the clear property to specify placement of text relative to floating objects.This example uses a call to an embedded (global) style sheet to move the text below the floating objects when italic text is encountered.
<STYLE> I { clear:left } </STYLE>Code example: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/clear_h.htm
This example changes the position of the paragraph relative to the floating object on its left side.
<HEAD> <SCRIPT> function fnClear(){ oClear.style.clear="left"; } function fnClear2(){ oClear.style.clear="none"; } </SCRIPT> </HEAD> <BODY> <img src="/workshop/graphics/sphere.jpg" style="float:left"> <SPAN ID="oClear"> <P>This is an example of the clear attribute.<P> </span> <P> <INPUT TYPE=button value="clear = left" onclick="fnClear()"> <INPUT TYPE=button value="clear = none" onclick="fnClear2()"> </P> </BODY>Code example: http://samples.msdn.microsoft.com/workshop/samples/author/dhtml/refs/clear_s.htm
Standards Information
This property is defined in Document Object Model (DOM) Level 1 and is defined in Cascading Style Sheets (CSS), Level 1 (CSS1).
Applies To
A, ADDRESS, APPLET, B, BIG, BLOCKQUOTE, BUTTON, CAPTION, CENTER, CITE, CODE, COL, COLGROUP, CSSStyleDeclaration, currentStyle, CUSTOM, DD, defaults, DFN, DIR, DIV, DL, DT, EM, EMBED, FIELDSET, FORM, hn, HR, I, IFRAME, IMG, INPUT type=button, INPUT type=checkbox, INPUT type=file, INPUT type=image, INPUT type=password, INPUT type=radio, INPUT type=reset, INPUT type=submit, INPUT type=text, ISINDEX, KBD, LABEL, LEGEND, LI, LISTING, MARQUEE, MENU, OBJECT, OL, OPTION, P, PLAINTEXT, PRE, runtimeStyle, S, SAMP, SELECT, SMALL, SPAN, STRIKE, STRONG, style, SUB, SUP, TABLE, TBODY, TD, TEXTAREA, TFOOT, TH, THEAD, TR, TT, U, UL, VAR, XMP, CSSCurrentStyleDeclaration Constructor, CSSRuleStyleDeclaration Constructor, CSSStyleDeclaration Constructor