re: Which units of measure do you use and why in CSS? VIEW POST


I personally use em and rem a lot. But there are cases and cases.

Let's restrict to just length measures. I personally use:

  • px for border widths, specifically one pixel borders, which are always rendered crisply in most use cases;
  • em for typographical spaces: box padding, margins, borders radii and shadows (when they make sense, i.e. inline components), larger border widths, (usually minimum) widths of text content boxes;
  • rem for layout components (wrt sizes, margins, padding, border radii, box shadows);
  • percentages (including vw and vh) for precise layout displacement, or relative font sizing;
  • cm or mm for printing.
code of conduct - report abuse