[GIS] Font size in HTML in QGIS’ print composer only starts to change at 6

htmllayoutsprint-composerqgisqgis-3

<font size ="10">font size 10</font></br>
<font size ="9">font size 9</font></br>
<font size ="8">font size 8</font></br>
<font size ="7">font size 7</font></br>
<font size ="6">font size 6</font></br>
<font size ="5">font size 5</font></br>
<font size ="4">font size 4</font></br>
<font size ="3">font size 3</font></br>
<font size ="2">font size 2</font></br>
<font size ="1">font size 1</font></br>

s

What's wrong with my code?

Best Answer

Problem

The <font> tag's size property is only defined for values of 1 through 7. MDN says about the <font> tag:

Obsolete

This feature is obsolete. Although it may still work in some browsers, its use is discouraged since it could be removed at any time. Try to avoid using it.

and later:

[...] For any new web development, styling should be written using CSS only.

Solution

Use the style property of HTML tags and CSS styling.

<span style="font-size:84">font size 10</span></br>
<span style="font-size:72">font size 9</span></br>
<span style="font-size:60">font size 8</span></br>
<span style="font-size:48">font size 7</span></br>
<span style="font-size:36">font size 6</span></br>
<span style="font-size:24">font size 5</span></br>
<span style="font-size:18">font size 4</span></br>
<span style="font-size:16">font size 3</span></br>
<span style="font-size:12">font size 2</span></br>
<span style="font-size:8">font size 1</span></br>

different font sizes in QGIS layout composer / HTML layout

Related Question