I am using htmlTable package in my rmarkdown files. For setting cell padding I use this piece of code:
htmlTable(..., css.cell = "padding-left: .5em; padding-right: .2em;")
How can I do something similar on the header cells?
The key is to add the + 1
rows when specifying the css.cell
matrix argument. The default is to only affect the data-cells. Here's an example:
simple_output <- matrix(1:4, ncol = 2)
htmlTable(simple_output,
header = LETTERS[1:2],
css.cell = rbind(rep("background: lightgrey; font-size: 2em; padding-left: .5em; padding-right: .2em;",
times = ncol(simple_output)),
matrix("",
ncol = ncol(simple_output),
nrow = nrow(simple_output))))
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With