Paul Rougieux
Paul Rougieux

Reputation: 11379

How to add cellspacing and cellpadding in HTML tables generated by xtable?

I would like to add spacing or padding to a html table generated by xtable. The print.xtable() parameter html.table.attributes doesn't work for me. Here an example chunk that can be pasted in a Rmd document.

```{r results='asis'}
library(xtable)
print(xtable(cars), type='html',
      html.table.attributes = 'cellspacing="5" cellpadding="5"',
          include.rownames = FALSE, include.colnames=FALSE,
          comment = FALSE)
```

It's a simple standalone example and I wouldn't like to create a css file for this: more details on the purpose.

Upvotes: 3

Views: 1153

Answers (1)

Michael Discenza
Michael Discenza

Reputation: 3330

You can add CSS rules to a style sheet in the R Markdown document with the style tags.

 <style>
   th,td{
     padding:2px 5px 2px 5px;
   }
 </style>

Upvotes: 3

Related Questions