Setting top of one control on the height of another

on window load function
i get the height of a control in a variable say 300px
i have another DIV control below the first control and i wish to specify its TOP position depending on the height of the first control
like
document.getElementById('div1").style.top=htvariable+‘5’
but i am not able to get it to add it
how to d oit

Instead of:

document.getElementById('div1").style.top=htvariable+‘5’

Try:

document.getElementById('div1").style.top=htvariable+‘5px’

i had done the sme by still getting error

I don’t know, but does JS “top” etc settings work on elements who aren’t positioned first?

In CSS you can’t get “top” or any others to do anything unless the element’s first “positioned” (either postion: absolute or position: relative). I ask because top is part of “style” there.