A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://webplatform.github.io/docs/css/data_types/length below:

<length> · WebPlatform Docs

<length> Summary

A <length> is a CSS data type that is used to specify distance measurements using relative or absolute units. It consists of an integer or decimal number followed (without whitespace) by a unit abbreviation; the unit may be omitted if the number is zero (0).

In CSS, there are many properties that can take a length as a value — such as width, height, top and bottom — or at least part of their value, for example box-shadow, border, background-image and flex.

Length units specify a distance on the display screen or printed output. Pairs of length units are typically used to specify x/y screen coordinates or offsets. Several different kinds of length units are available:

Absolute lengths

Absolute does not mean that these units will be treated the same on every device, only that they do not depend on other style properties and that they have fixed conversion factors between them. In particular, the in and cm units will not always correspond to the “real-world” definitions of an inch or a centimeter. For devices which are usually viewed at a distance (TVs and projectors), the specifications define a reference pixel based on the expected angle it would cover in the user’s field of view; the other units should be mapped relative to this reference. The reference pixel (and therefore other units) of a screen device may also be affected by user settings. For print media, it is recommended (but not required) that normal physical inches or centimeters be used as the reference value.

Relative font lengths Relative viewport lengths

Note that percentages may refer to various length units, but for length specifies the height and width of an element, or the overall document window.

Also bear in mind that some properties accept negative values, while some don’t. So for example, you can’t specify negative padding, but you could use a negative margin to move a block in the direction of the negative margin’s side, and you can use negative units in box-shadow to move the box left and up rather than right and down.

Examples
.info {
    position: fixed;
    
    top: 0.5in;
    right: 2em;
    
    width: 25%;
    width: 25vw;
}
Related specifications
CSS Values and Units Module Level 3
Candidate Recommendation
CSS 2.1
W3C Recommendation

RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4