Page 1 of 1

offsetLeft vs left

Posted: Sat Jan 13, 2007 10:02 pm
by JellyFish
What's the diference between element.style.left and element.offsetLeft?

Posted: Sat Jan 13, 2007 10:32 pm
by feyd
One is CSS, the other is the actual position.

Posted: Sat Jan 13, 2007 11:27 pm
by JellyFish
Aren't they both actual positions? I meant what diferent uses do they have? Why is there two of the same properties?

Posted: Sun Jan 14, 2007 12:11 am
by feyd
They aren't the same. As I've already said, one is CSS, the other is the actual position.

Posted: Sun Jan 14, 2007 12:35 am
by JellyFish
*sigh*... What diference do they have programmaticly?

Edit: Man, do you not get what I'm asking? Yeah ones CSS and the other isn't. But what does that tell me?

Edit2: I noticed that CSS' left is 0 even if the element is centered in the screen because the attribute was not set. I assume offsetLeft is not the same in that way?

Posted: Sun Jan 14, 2007 8:51 am
by Kieran Huggins
"One is CSS left" means the amount that was specified as "left" in "CSS". Not usually that useful.

The other is problematic at best. If it's important to have a cross-browser solution that works, use prototype. (or at least learn from the offset code they use)