# pct()

Helper for providing a CSS length value as a percentage.

Usage

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

``` python
pct(x)
```

A percentage value acts as a length value that is relative to an initial state. For instance an 80% value for something will size the target to 80% the size of its 'previous' value. This type of sizing is useful for sizing up or down a length value with an intuitive measure. This helper function can be used for the setting of font sizes (e.g., in [`style.text()`](../reference/style.text.md#great_tables.style.text)) and for widths (e.g., `table_width=` in [`tab_options()`](../reference/GT.tab_options.md#great_tables.GT.tab_options)). Should a more exact definition of size be required, the analogous helper function [`px()`](../reference/px.md#great_tables.px) will be more useful.

## Parameters

`x: float`  
The integer or float value to format as a string-based percentage value for some arguments that can take percentage values.

## Returns

`str`  
The value as a CSS percentage (e.g., `"80%"`).

## Examples

The [pct()](../reference/pct.md#great_tables.pct) helper turns a number into a CSS percentage.

``` python
from great_tables import pct

pct(80)
```

    '80%'

Here, [pct()](../reference/pct.md#great_tables.pct) sets the table's width to 60% of the width of its container, and the font size of the `char` column's values to 80% of the size they'd otherwise have.

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

(
    GT(exibble[["num", "char"]].head(3))
    .tab_options(table_width=pct(60))
    .tab_style(style=style.text(size=pct(80)), locations=loc.body(columns="char"))
)
```

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