I was wondering what the logic was behind the CSS attributes for top
, left
bottom
and right
.
for exa
The float
properties are relative to other elements in your document. The top
, right
, left,
and bottom
properties are relative to the edge of that element. They add margin of that amount to the specified side of the element.
float: left;
says "I'm going to float to the left of other elements next to me.
right: 5px;
says "The closest element has to be 5px away from me when on the right side.
It's a matter of selflessness vs. selfishness. See the W3C Wiki for more information.
Also, keep in mind that top
, right
, left
, and bottom
properties only work when position
is set.