You can calculate the angle and distance between the points and use CSS Transforms to display the line you want. Here's the jsfiddle . This is a little rude, but I think you get this idea.
var startPoint=[200,200], endPoint=[300,300], rise=endPoint[1]-startPoint[1], run=endPoint[0]-startPoint[0], slope=rise/run, DEGREES=57.2957795, width=Math.sqrt((rise*rise)+(run*run)); var line=document.getElementById('line'); line.style.top=startPoint[0]+'px'; line.style.left=startPoint[1]+'px'; line.style.width=width+"px"; line.style.transform= "rotate("+(Math.atan(slope)*DEGREES)+"deg)"; line.style.transformOrigin= "0 0";
ryanb source share