You can do this with the function is_html_output() from the knitr package. There is also is_latex_output() if you want to allow for that option as well.
```{r}
library(knitr)
if(is_html_output()) {
kable(cars)
} else {
cars
}
```
If you want chunk evaluation to depend on document type, you could do:
```{r eval=is_html_output()}
kable(cars)
```