📏 CSS Size Properties (Width, Height & Units)

Last Updated: November 2025


CSS size properties define how big an element appears — its width, height, and limits like min-width or max-height.

🗣 Hinglish Tip: Yeh decide karta hai element kitna bada/ chhota dikhega — fixed ho ya responsive.


Size Properties

PropertyDescription
widthHorizontal size
heightVertical size
min-width / min-heightMinimum size limit
max-width / max-heightMaximum size limit

🎯 CSS Unit Types

Below is the proper table format you want ⬇️

📐 CSS Size Units Summary

UnitExampleDescription
pxwidth: 200pxFixed pixel size (not responsive)
%width: 50%Relative to parent element
vwwidth: 100vw1vw = 1% of viewport width
vhheight: 100vh1vh = 1% of viewport height
remfont-size: 2remRelative to root (HTML) font-size (default 16px)
emfont-size: 2emRelative to parent element’s font-size
chwidth: 20chWidth of ~20 characters (0 width of "0")
exheight: 2exHeight relative to lowercase “x”
vminwidth: 50vmin1% of smaller viewport dimension
vmaxheight: 50vmax1% of larger viewport dimension
autowidth: autoAutomatically adjusts based on content
fit-contentwidth: fit-contentAdjusts size based on content limits

📝 Examples of Each Unit

.box {
  width: 200px;
  height: 80px;
  background: lightblue;
}

.child {
  width: 50%;
  height: 100px;
  background: coral;
}

html {
  font-size: 16px; /* 1rem = 16px */
}

.parent {
  font-size: 20px; /* 1em = 20px in this element */
}

.child {
  font-size: 2rem; /* = 32px */
  width: 10em; /* = 200px because parent font-size is 20px */
}

.hero {
  width: 100vw;
  height: 100vh;
  background: lightgreen;
}

.card {
  width: fit-content;
  padding: 10px;
  background: #ffeaa7;
}
Use CaseBest UnitDescription
TextremBest for typography, scales with root font-size
Component spacingrem / emConsistent spacing that adapts to font-size
Fluid layouts%Adapts to parent container size
Fullscreen sectionsvh / vwMatches viewport height/width
Buttons / Chipsfit-contentShrinks or expands exactly to content size
Minimal responsive blocksclamp()Sets min, ideal, and max size for smooth responsiveness