Include padding and borders in sizing deliberately
#With content-box, width describes the content box. border-box includes padding and border within the declared size; margins remain outside.
Fragment
Reference
Look up semantic HTML, forms, CSS layout, events, DOM operations and common browser APIs.
Modern browser platform examples, independent of a framework. HTML/CSS excerpts belong in the appropriate document/style context; DOM snippets assume a browser and named elements/data; TypeScript annotations clarify DOM types and need compilation or removal in plain JavaScript. Check target-browser support for newer features.
With content-box, width describes the content box. border-box includes padding and border within the declared size; margins remain outside.
Fragment
rem relates to root font size; em is context-dependent and commonly relates to an element/parent font size. Percentages depend on the property’s containing/reference box. dvh tracks dynamic viewport height.
Fragment
Viewport-unit and mobile-browser behavior varies; avoid locking all content into a height that cannot accommodate zoom/text growth.
Flexbox distributes items along a main axis. gap adds spacing; alignment properties operate on axes. min-width:0 can let a flexible child shrink below its intrinsic content width.
Fragment
Grid lays out rows and columns. minmax(0,1fr) permits a track to shrink rather than preserving an oversized min-content minimum.
Fragment
relative retains normal-flow space and establishes offsets. absolute leaves normal flow and uses its containing block. fixed and sticky have different containing/scroll relationships.
Fragment
Transforms and other properties can establish containing blocks/stacking contexts. Sticky positioning depends on scroll containers and available space.
z-index orders participating boxes within their stacking context; it cannot universally lift a child above an unrelated ancestor context. Opacity, transforms, isolation and other features can create contexts.
Fragment
Native dialog/popover top-layer behavior is distinct from ordinary z-index ordering.
Media queries test the environment/viewport. Container queries can test a declared query container’s size, letting a component adapt to its allocated space.
Fragment