The px unit

The absolute unit of measurement px represents a cell on the matrix of an electronic device. For example, if the width of a smartphone screen is 480px, this means that there are 480 cells on the screen, each of which is equal to 1px.

Example

Let's give the rectangle a width of 200px and a height of 100px:

html<div>
</div>
cssdiv {
  border: 1px solid black;
  width: 200px;
  height: 100px;
}

Результат:

Example

Let's give the paragraph text a font of 30 pixels:

html<p>
  text
</p>
cssp {
  font-size: 30px;
}

Результат:

See also

  • the em unit
    that specifies a size in em
  • the rem unit
    that specifies a size in rem
  • the fr unit
    that specifies a size in fr
  • the % unit
    that specifies a size in percentage
  • the vw unit
    that specifies a size in vw
  • the vh unit
    that specifies a size in vh
  • the vmax unit
    that specifies a size in vmax
  • the vmin unit
    that specifies a size in vmin