Instead of setting the properties like: ele.style.position = 'relative'; ele.style.top = '10px'; ele.style.left = '25px'; You can set all in one line: and thereby also avoid the number of actions that the browser has to take on the element. ele.setAttribute('style','position:relative;top:10px;left:25px;');