0% completed
Absolute units provide fixed measurements for your elements and text. In CSS, the px
(pixel) unit is one of the most common absolute units. When you use pixels, the element's size does not change based on the screen size or resolution. This is useful when you need precise control over the layout.
selector { property: valuepx; }
Explanation:
px
gives you an exact size regardless of the device.In this example, a <div>
is set with a fixed width and height using pixels. The box will remain 300px wide and 200px tall on all devices.
Explanation:
<div>
has a width of 300px and height of 200px.In this example, a paragraph is styled with a fixed font size using pixels. The text remains the same size on every device.
Explanation:
These examples show how the px
unit is used to set exact dimensions and sizes. By using absolute units, you have clear and fixed control over how your elements appear on the page.
.....
.....
.....