Sets or retrieves the top position of the object in the units specified by the cascading style sheets (CSS) top attribute.
Syntax
HTML N/A Scripting object.style.posTop [ = iTop ]
Possible Values
iTop Integer that specifies any valid floating-point number that uses the same length units as the top attribute. The property is read/write with no default value.
Expressions can be used in place of the preceding value(s), as of Microsoft® Internet Explorer 5. For more information, see Dynamic Properties.
Remarks
This property reflects the value of the CSS top attribute for positioned items. This property always returns 0 for nonpositioned items, because "top" has meaning only when the object is positioned. Use the offsetTop property to calculate actual positions within the document area.
Setting this property changes the value of the top position, but leaves the units designator for the property unchanged.
Unlike the top property, the posTop property value is a floating-point number, not a string.
For more information about how to access the dimension and location of objects on the page through the document object model, see Measuring Element Dimension and Location.
Example
This example uses the posTop property to move the first IMG object up by 10 units.
Sample Code
<SCRIPT LANGUAGE="JScript"> document.all.tags("IMG").item(0).style.posTop -= 10; </SCRIPT>This example uses a timer to move the posTop property in increments of 10.
Sample Code
<SCRIPT LANGUAGE="JScript"> function moveThis() { : if (sphere.style.posLeft<900) { sphere.style.posTop += 2; sphere.style.posLeft += 2; window.setTimeout("moveThis();", 1); } } : </SCRIPT>
Applies To
A, ACRONYM, ADDRESS, APPLET, AREA, B, BASE, BASEFONT, BIG, BLOCKQUOTE, BODY, BR, BUTTON, CAPTION, CENTER, CITE, CODE, COL, COLGROUP, COMMENT, custom, DD, DEL, DFN, DIR, DIV, DL, DT, EM, EMBED, FIELDSET, FONT, FORM, FRAME, FRAMESET, HEAD, 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, INS, KBD, LABEL, LEGEND, LI, LINK, LISTING, MAP, MARQUEE, MENU, META, NEXTID, NOBR, OBJECT, OL, OPTION, P, PLAINTEXT, PRE, Q, RT, RUBY, runtimeStyle, S, SAMP, SCRIPT, SELECT, SMALL, SPAN, STRIKE, STRONG, style, SUB, SUP, TABLE, TBODY, TD, TEXTAREA, TFOOT, TH, THEAD, TITLE, TR, TT, U, UL, VAR, XMP
See Also