Back to CSS Notes
Topic #105

CSS Units

CSS units measure everything — px, %, em, rem, vw — each with a purpose. Choosing the right units makes layouts scale correctly.


CSS Units

CSS units are used to define the length and size of several properties.

Several CSS properties take "length" values, such as font-size, width, margin, padding, border, etc.

CSS has two types of units:

  • Absolute units
  • Relative units

CSS Absolute Units

Absolute units are fixed, and the length expressed in any of these will appear exactly that size.

Absolute units do NOT change when the screen size change, and are not recommended for websites. However, they can be used if the output medium is known, such as for print layout.

The most used absolute unit is px (pixels).


CSS Relative Units

Relative units specify a length relative to another length property (like parent element, root element, or viewport).

Relative length units scale better between different screen sizes, making them ideal for responsive web design.

The two most used relative units are em and rem.

Tip: The em and rem units are perfect for creating scalable and responsive websites!

Want to go beyond the notes?

Join Coding Now Tech Institute's CSS course — live mentorship, real projects, and 100% placement support.

Enroll Now — Free Demo Available

CSS Units – FAQs

Quick answers about learning CSS Units in CSS.

This free note from Coding Now Tech Institute explains CSS Units in CSS — concept, syntax and worked code examples you can copy, run and revise before interviews.
Yes. Every CSS topic on Coding Now Tech Institute, including CSS Units, is 100% free with no signup required.
With focused practice, most students grasp CSS Units in 1–3 days from these notes; pairing it with Coding Now Tech Institute's mentor-led course takes you to job-ready depth faster.
Use the code examples in this note, then ask doubts for free on the Coding Now Tech Institute Community (/community) — expert instructors answer within 24 hours.
Call NowEnroll Now