# px()

Helper for providing a CSS length value in pixels.

Usage

[Source](https://github.com/posit-dev/great-tables/blob/main/great_tables/_helpers.py#L249-L296)

``` python
px(x)
```

For certain parameters, a length value is required. Examples include the setting of font sizes (e.g., in [`style.text()`](../reference/style.text.md#great_tables.style.text)) and thicknesses of lines (e.g., in [`style.borders()`](../reference/style.borders.md#great_tables.style.borders)). Setting a length in pixels with [px()](../reference/px.md#great_tables.px) allows for an absolute definition of size as opposed to the analogous helper function [`pct()`](../reference/pct.md#great_tables.pct).

## Parameters

`x: float`  
The integer or float value to format as a string (e.g., `"12px"`) for some arguments that can take values as units of pixels.

## Returns

`str`  
The value as a CSS length in pixels (e.g., `"12px"`).

## Examples

The [px()](../reference/px.md#great_tables.px) helper turns a number into a CSS length in pixels.

``` python
from great_tables import px

px(12)
```

    '12px'

Here, [px()](../reference/px.md#great_tables.px) gives the font size of the `num` column's values and the thickness of the line under the `char` column's values.

``` python
from great_tables import GT, exibble, loc, style

(
    GT(exibble[["num", "char"]].head(3))
    .tab_style(style=style.text(size=px(18)), locations=loc.body(columns="num"))
    .tab_style(
        style=style.borders(sides="bottom", color="steelblue", weight=px(3)),
        locations=loc.body(columns="char"),
    )
)
```

| num    | char    |
|--------|---------|
| 0.1111 | apricot |
| 2.222  | banana  |
| 33.33  | coconut |
