Units
Published by
sanya sanya
The CSS units are used to specify measurements in Cascading Style Sheets (CSS). They allow you to define the size, length, or position of elements on a web page.
CSS units can be categorized into two main types: absolute units and relative units.
Absolute Units
The Absolute Units in Cascading Style Sheets are mentioned below -
- Pixel (px) - The most common absolute unit, representing a single dot on a screen. It provides a fixed size regardless of the device's resolution.
- Point (pt) - Commonly used in print media, where 1 point is equal to 1/72nd of an inch.
- Inch (in) - Represents an inch measurement.
- Centimeter (cm) - Represents a centimeter measurement.
- Millimeter (mm) -Represents a millimeter measurement.
Relative Units
The Relative Units in Cascading Style Sheets are mentioned below -
- Percentage (%) - Represents a percentage of the parent element's size or the available space.
- Viewport Height (vh) - Represents a percentage of the viewport's height.
- Viewport Width (vw) - Represents a percentage of the viewport's width.
- Viewport Minimum (vmin) - Represents a percentage of the viewport's smaller dimension (height or width).
- Viewport Maximum (vmax) -Represents a percentage of the viewport's larger dimension (height or width).
- em - Represents the computed font size of the element. It's relative to the font size of its parent or, if used on the root element, to the browser's default font size. rem: Similar to em, but it's relative to the font size of the root element (usually the element).
- ch - Represents the width of the "0" character of the element's font.
- ex - Represents the height of the lowercase "x" character of the element's font.
- fr - Represents a fraction of the available space in a CSS grid or flex container. Used in grid-template-columns, grid-template-rows, and flex-basis.
Library
WEB DEVELOPMENT
Basic
HTML - Hyper Text Markup Language
CSS - Cascading Style Sheets
Cascading Style Sheets (CSS)
Selectors and Combinators
CSS Transforms
Units
CSS Icons and Colors
CSS Borders
CSS Margin
CSS Padding
CSS Dimensions
CSS Box Model
CSS Background
Pseudo Classes in CSS
CSS Positions
CSS Flexbox
Responsiveness in CSS
CSS Transitions
CSS Animations
Other CSS Properties
Var()
CSS Frameworks
CSS Grids
CSS Display Properties
JavaScript
Frontend
Backend
Interview Questions
FAANG QUESTIONS
On this page
Absolute Units
Relative Units

