1

I'm using QGIS 3.10.1, and am having trouble with getting HTML tables to render correctly in a layout. I generated the HTML table using the "TABLEIZER!" online tool, and just pasted the results into the HTML box. The CSS looks like something this:

<style type="text/css">
    table.tableizer-table {
        font-size: 12px;
        border: 1px solid #CCC; 
        font-family: Arial, Helvetica, sans-serif;
    } 
</style>

I first created a new HTML object on the layout, and pasted the HTML content from Tabelizer into the code box.

Then I copy/paste the same HTML table object (including the same HTML values) into different layouts. In the different layouts, the font sizes are being displayed in dramatically different in sizes. Finally, I copied one of the tables with "appropriately" sized fonts and pasted it back on the layout with the fonts that are being displayed too large.

The image below shows how on the same layout, 2 tables with the exact same HTML code, is being displayed differently. Both the HTML and CSS are located in the "HTML Source" box. Any ideas what the heck is going on, or how to get the "big font" HTML table to refresh to look correct (smaller text)?

HTML table in QGIS with different font sizes

4

If you use CSS size definitions in QGIS, it‘s best to use em relative units instead of pt or px. pt/px units are changing with the dpi settings of the Layout.

| improve this answer | |
  • ahhh... that sounds promising. While the page size and font size never changed, I did change my output DPI resolution from 300 to 96 to speed up the export when generating a "rough draft". I'll try changing from px to em. I wonder how the "base units" are determined when you add in fonts using "em" a or "pt/px". For reference, I was generating the HTML table using the "TABLEIZER!" online tool (link in original question). – RyanKDalton Jan 3 at 16:41
  • You can set the base font size by selecting a font size in the QGIS HTML dialog. – christoph Jan 3 at 16:55
  • Using "em" was the appropriate path to take. Now, no matter what resolution I export the layout in, the HTML characters look the same. I never considered that point size would be relative to DPI, but it totally makes sense after this "experiment". Thank you for your clear explanation. – RyanKDalton Jan 6 at 23:51

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.