# random_id()

Helper for creating a random `id` for an output table.

Usage

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

``` python
random_id(n=10)
```

A table's `id` is the `id=` attribute of the HTML element that holds it, which CSS (as in [`opt_css()`](../reference/GT.opt_css.md#great_tables.GT.opt_css)) can use to target that table alone. Give one with `GT(id=)` or [`with_id()`](../reference/GT.with_id.md#great_tables.GT.with_id).

## Parameters

`n: int = 10`  
The number of lowercase letters to use in the random ID string. Defaults to 10.

## Returns

`str`  
A string that constitutes a random ID value.

## Examples

Each call gives a new string of random lowercase letters.

``` python
from great_tables import random_id

random_id(), random_id(n=5)
```

    ('dobgsiinah', 'tffgm')

Here, the table gets a random ID, which its CSS is then scoped to.

``` python
from great_tables import GT, exibble

GT(exibble[["num", "char"]].head(3)).with_id(random_id())
```

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