QuickDevGuide

Home › CSS

CSS Units & Math Functions — CSS

CSS units control size, spacing, and layout behavior. They fall into two categories. Absolute Units px (pixels) — fixed size, does not scale with user preferences. Best for borders, shadows, and fine-detail sizing. Avoid for font sizes and layout widths. Relative Units (Recommended for Responsive Design) em — relative to the parent's font size (1.5em = 1.5x parent). rem — relative to the root (html) font size (consistent, predictable — preferred for font sizes). % — relative to the parent element's size (great for widths). vw/vh — relative to the viewport width/height (100vw = full viewport width). fr — fractional unit used exclusively in CSS Grid to distribute available space. CSS Math Functions CSS Math Functions allow dynamic calculations directly in stylesheets: calc() performs…

Key Takeaways