gt table — as_raw_html" />

Get the HTML content from a gt_tbl object as a single-element character vector. By default, the generated HTML will have inlined styles, where CSS styles (that were previously contained in CSS rule sets external to the <table> element) are included as style attributes in the HTML table's tags. This option is preferable when using the output HTML table in an emailing context.

as_raw_html(data, inline_css = TRUE)



a table object that is created using the gt() function.


an option to supply styles to table elements as inlined CSS styles.

See also

Other table export functions: as_latex, as_rtf, extract_summary


# 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()
#> <!--gt table start--> #> <table style="font-family:-apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, 'Helvetica Neue', 'Fira Sans', 'Droid Sans', Arial, sans-serif;display:table;border-collapse:collapse;margin-left:auto;margin-right:auto;color:#000000;font-size:16px;background-color:#FFFFFF;width:auto;border-top-style:solid;border-top-width:2px;border-top-color:#A8A8A8;"> #> <thead> #> <tr> #> <th colspan='3' style="background-color:#FFFFFF;border-bottom-color:#FFFFFF;color:#000000;font-size:125%;padding-top:4px;padding-bottom:1px;border-bottom-width:0;text-align:center;font-weight:normal;" >Data listing from <strong>gtcars</strong></th> #> </tr> #> <tr> #> <th colspan='3' style="