Margins behaviour
Learn JS Fundamentals to jQuery & Pure DOM Scripting DOM Layout & Positioning
Vertical margins collapse, horizontal margins add up (
box-sizing: content-box;
)
Horizontal dimensions are calculated first then vertical
.offsetHeight
and offsetWidth
is from border to border (outside).clientWidth
and .clientHeight
is content + paddingno property for just the content's width/height!
jQuery can calculate that and it gives:
width()
-> just the content's width without padding, etc.innerWidth()
-> basically same asclientHEight
outerWidth()
->.offsetHeight
outerWidth(true)
-> with thetrue
parameter it includes the margin into the calculation