Prework
Proposal
When applying a style to an entire row of cells, each cell receives the style in the output HTML. This artificially inflates the HTML file size. One way to reduce this bloating is to identify common elements that exist across the entire row, and apply that style to the row -<tr> - rather than each cell - <td>.
Consider the following minimal example:
---
title: 'gt test'
output: html_document
date: "2026-06-08"
---
```{r include = FALSE}
library(tidyverse)
library(gt)
```
```{r echo = FALSE}
mtcars %>%
gt() %>%
tab_style(
style = cell_text(weight = 'bold'),
locations = cells_body(rows = 2:4)
)
```
Rows 2-4 have the same bold formatting. That style is applied to each cell as highlighted by the red arrow. However, I've manually edited row 6 with the style applied at the row level, as highlighted by the green arrow.
This enhancement might seem minimal when creating a couple of tables. However, in my practical example I'm creating an HTML that contains 100+ tables displayed in a nested {.tabset} arrangement. As such, only a single table is visible to the end user. All tables have the same structure, with only row formatting (no column-specific formatting). However, the 100+ tables result in a ~20Mb output. This file size could be reduced some pre-cleaning is done to apply column/cell styles common to an entire row at the row level.
Prework
Proposal
When applying a style to an entire row of cells, each cell receives the style in the output HTML. This artificially inflates the HTML file size. One way to reduce this bloating is to identify common elements that exist across the entire row, and apply that style to the row -
<tr>- rather than each cell -<td>.Consider the following minimal example:
Rows 2-4 have the same bold formatting. That style is applied to each cell as highlighted by the red arrow. However, I've manually edited row 6 with the style applied at the row level, as highlighted by the green arrow.
This enhancement might seem minimal when creating a couple of tables. However, in my practical example I'm creating an HTML that contains 100+ tables displayed in a nested
{.tabset}arrangement. As such, only a single table is visible to the end user. All tables have the same structure, with only row formatting (no column-specific formatting). However, the 100+ tables result in a ~20Mb output. This file size could be reduced some pre-cleaning is done to apply column/cell styles common to an entire row at the row level.