GT.as_raw_html(self, make_page=False, all_important=False)
Get the HTML content of a GT object.
Get the HTML content from a GT object as a string. This function is useful for obtaining the HTML content of a GT object for use in other contexts.
Parameters
gt :
-
A GT object.
Returns
: str
-
An HTML fragment containing a table.
Examples:
Let’s use the row
column of exibble
dataset to create a table. With the as_raw_html()
method, we’re able to output the HTML content.
from great_tables import GT, exibble
GT(exibble[["row"]]).as_raw_html()
'<div id="tkecwprggm" style="padding-left:0px;padding-right:0px;padding-top:10px;padding-bottom:10px;overflow-x:auto;overflow-y:auto;width:auto;height:auto;">\n<style>\n#tkecwprggm table {\n font-family: -apple-system, BlinkMacSystemFont, \'Segoe UI\', Roboto, Oxygen, Ubuntu, Cantarell, \'Helvetica Neue\', \'Fira Sans\', \'Droid Sans\', Arial, sans-serif;\n -webkit-font-smoothing: antialiased;\n -moz-osx-font-smoothing: grayscale;\n }\n\n#tkecwprggm thead, tbody, tfoot, tr, td, th { border-style: none; }\n tr { background-color: transparent; }\n#tkecwprggm p { margin: 0; padding: 0; }\n #tkecwprggm .gt_table { display: table; border-collapse: collapse; line-height: normal; margin-left: auto; margin-right: auto; color: #333333; font-size: 16px; font-weight: normal; font-style: normal; background-color: #FFFFFF; width: auto; border-top-style: solid; border-top-width: 2px; border-top-color: #A8A8A8; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #A8A8A8; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; }\n #tkecwprggm .gt_caption { padding-top: 4px; padding-bottom: 4px; }\n #tkecwprggm .gt_title { color: #333333; font-size: 125%; font-weight: initial; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; border-bottom-color: #FFFFFF; border-bottom-width: 0; }\n #tkecwprggm .gt_subtitle { color: #333333; font-size: 85%; font-weight: initial; padding-top: 3px; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; border-top-color: #FFFFFF; border-top-width: 0; }\n #tkecwprggm .gt_heading { background-color: #FFFFFF; text-align: center; border-bottom-color: #FFFFFF; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; }\n #tkecwprggm .gt_bottom_border { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }\n #tkecwprggm .gt_col_headings { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; }\n #tkecwprggm .gt_col_heading { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: bottom; padding-top: 5px; padding-bottom: 5px; padding-left: 5px; padding-right: 5px; overflow-x: hidden; }\n #tkecwprggm .gt_column_spanner_outer { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: normal; text-transform: inherit; padding-top: 0; padding-bottom: 0; padding-left: 4px; padding-right: 4px; }\n #tkecwprggm .gt_column_spanner_outer:first-child { padding-left: 0; }\n #tkecwprggm .gt_column_spanner_outer:last-child { padding-right: 0; }\n #tkecwprggm .gt_column_spanner { border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; vertical-align: bottom; padding-top: 5px; padding-bottom: 5px; overflow-x: hidden; display: inline-block; width: 100%; }\n #tkecwprggm .gt_spanner_row { border-bottom-style: hidden; }\n #tkecwprggm .gt_group_heading { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; text-align: left; }\n #tkecwprggm .gt_empty_group_heading { padding: 0.5px; color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; vertical-align: middle; }\n #tkecwprggm .gt_from_md> :first-child { margin-top: 0; }\n #tkecwprggm .gt_from_md> :last-child { margin-bottom: 0; }\n #tkecwprggm .gt_row { padding-top: 8px; padding-bottom: 8px; padding-left: 5px; padding-right: 5px; margin: 10px; border-top-style: solid; border-top-width: 1px; border-top-color: #D3D3D3; border-left-style: none; border-left-width: 1px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 1px; border-right-color: #D3D3D3; vertical-align: middle; overflow-x: hidden; }\n #tkecwprggm .gt_stub { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-right-style: solid; border-right-width: 2px; border-right-color: #D3D3D3; padding-left: 5px; padding-right: 5px; }\n #tkecwprggm .gt_stub_row_group { color: #333333; background-color: #FFFFFF; font-size: 100%; font-weight: initial; text-transform: inherit; border-right-style: solid; border-right-width: 2px; border-right-color: #D3D3D3; padding-left: 5px; padding-right: 5px; vertical-align: top; }\n #tkecwprggm .gt_row_group_first td { border-top-width: 2px; }\n #tkecwprggm .gt_row_group_first th { border-top-width: 2px; }\n #tkecwprggm .gt_striped { background-color: rgba(128,128,128,0.05); }\n #tkecwprggm .gt_table_body { border-top-style: solid; border-top-width: 2px; border-top-color: #D3D3D3; border-bottom-style: solid; border-bottom-width: 2px; border-bottom-color: #D3D3D3; }\n #tkecwprggm .gt_sourcenotes { color: #333333; background-color: #FFFFFF; border-bottom-style: none; border-bottom-width: 2px; border-bottom-color: #D3D3D3; border-left-style: none; border-left-width: 2px; border-left-color: #D3D3D3; border-right-style: none; border-right-width: 2px; border-right-color: #D3D3D3; }\n #tkecwprggm .gt_sourcenote { font-size: 90%; padding-top: 4px; padding-bottom: 4px; padding-left: 5px; padding-right: 5px; text-align: left; }\n #tkecwprggm .gt_left { text-align: left; }\n #tkecwprggm .gt_center { text-align: center; }\n #tkecwprggm .gt_right { text-align: right; font-variant-numeric: tabular-nums; }\n #tkecwprggm .gt_font_normal { font-weight: normal; }\n #tkecwprggm .gt_font_bold { font-weight: bold; }\n #tkecwprggm .gt_font_italic { font-style: italic; }\n #tkecwprggm .gt_super { font-size: 65%; }\n #tkecwprggm .gt_footnote_marks { font-size: 75%; vertical-align: 0.4em; position: initial; }\n #tkecwprggm .gt_asterisk { font-size: 100%; vertical-align: 0; }\n \n</style>\n<table class="gt_table" data-quarto-disable-processing="false" data-quarto-bootstrap="false">\n<thead>\n\n<tr class="gt_col_headings">\n <th class="gt_col_heading gt_columns_bottom_border gt_left" rowspan="1" colspan="1" scope="col" id="row">row</th>\n</tr>\n</thead>\n<tbody class="gt_table_body">\n <tr>\n <td class="gt_row gt_left">row_1</td>\n </tr>\n <tr>\n <td class="gt_row gt_left">row_2</td>\n </tr>\n <tr>\n <td class="gt_row gt_left">row_3</td>\n </tr>\n <tr>\n <td class="gt_row gt_left">row_4</td>\n </tr>\n <tr>\n <td class="gt_row gt_left">row_5</td>\n </tr>\n <tr>\n <td class="gt_row gt_left">row_6</td>\n </tr>\n <tr>\n <td class="gt_row gt_left">row_7</td>\n </tr>\n <tr>\n <td class="gt_row gt_left">row_8</td>\n </tr>\n</tbody>\n\n\n</table>\n\n</div>\n '