# NOT RUN {
# Use `gtcars` to create a gt table;
# add a header and then export as
# HTML code with CSS inlined
tab_html <-
  gtcars %>%
  dplyr::select(mfr, model, msrp) %>%
  dplyr::slice(1:5) %>%
  gt() %>%
  tab_header(
    title = md("Data listing from **gtcars**"),
    subtitle = md("`gtcars` is an R dataset")
  ) %>%
  as_raw_html()
# `tab_html` is a single-element vector
# containing inlined HTML for the table;
# it has only the `<table>...</table>` part
# so it's not a complete HTML document but
# rather an HTML fragment
tab_html %>%
  substr(1, 700) %>%
  cat()
# }
Run the code above in your browser using DataLab