Display and position

Block, inline, relative, absolute, fixed and sticky explained.

Display

ValueBehaviour
blockStarts on a new line and fills the width, like <div> and <p>
inlineSits in the text flow and ignores width and height, like <span>
inline-blockSits in the flow but accepts width and height
noneRemoved from the page completely
flex / gridLays out the children. See the next two lessons

Position

ValueBehaviour
staticThe default: normal page flow
relativeStays in the flow, can be nudged, and anchors absolute children
absoluteLeaves the flow and is placed against the nearest positioned ancestor
fixedPlaced against the screen, so it stays put as you scroll
stickyScrolls normally, then sticks once it reaches an edge
Edit the CSS
Preview
โ† Text and fontsFlexbox โ†’