Reputation: 193
Maybe this is just a stupid browser related issue, but ...
I generate some colored tables in a HTML file via Rmarkdown
using the tableHTML
package (colors are generated by the RColorBrewer
package):
```{r Init, include=FALSE}
knitr::opts_chunk$set(echo = TRUE)
require(magrittr, quietly = TRUE)
require(tableHTML)
test <- data.frame(A=123, B=456, C=789)
```
...
```{r Test, echo=FALSE, results="asis"}
tableHTML(test) %>%
add_css_thead(css = list('background-color', '#4DAF4A')) %>%
add_css_table(css = list('border', '#4DAF4A'))
```
The colors of the borders look fine in the `Rstudio' viewer:
But the borders are colored different, when opening in Safari or Firefox:
What is the problem with table border colors?
Upvotes: 2
Views: 69
Reputation: 6813
Thank you very much for your question!
With add_css_table
, the style is applied to the table
-tag and with add_css-thead
, it is applied to the thead
tag. But I think to get the effect you are looking for, you can apply the styles to the th
and td
tags via the functions add_css_header
and add_css_column
:
tableHTML(test) %>%
add_css_header(css = list(c("background-color", "border"),
c("#4DAF4A", "1px solid #4DAF4A")),
headers = 0:4) %>%
add_css_column(css = list("border", "1px solid #4DAF4A"),
columns = c("rownames", names(test)))
In RStudio, it looks like this:
In Firefox:
And in Chrome:
Upvotes: 2
Reputation: 26705
According to https://www.colorhexa.com/4daf4a the closest websafe colour to "#4daf4a" is "#669933". Does changing the border to #669933 solve your problem?
Upvotes: 0