HTML labels in Context

“Hyper Text Markup Language (HTML) are sets of markup symbols or codes which is used to define the contents of a webpage and they can be utilised to extent labelling in QGIS”

HTML can be used in QGIS for rendering complex labels thereby enhancing what the labelling engine in QGIS provides. HTM labels can be accessed in QGIS map composer.
In this module, we will explore how HTML can be used to generate complex and beautiful labels in the map composer.

You try:

Goal: To learn how to use HTML and functions to label map elements

  • Load the layers from the exercise data.
  • Symbolize all the layers so that they look nice and can be used in making maps.
  • Change the map scale to 1:500 000.
  • Add a new map layout and ensure the page size is in portrait mode.
  • Add a map label using this text Map showing urban areas within Zimbabwe.
  • Play around with the properties of the label and change the font size, font colour etc.
  • How can you change the font size, colour for some part of the map label ie Make the text Zimbabwe bold and have its colour as blue whilst the rest of the rest retains the default properties.
    Hint Convert the label to HTML tags.
  • Add a grid using the given parameters.
  • Add map credits ie add your organization and profession and date when you created the map.
  • How can you generate a dynamic date so that when you print your map on a different date it still reflects the correct date and time ?.
  • Add all other map elements that constitute a map.

Name Expectation

Map date

now()

Grid 1

Interval unit. X and Y = 5, Interval units = cm

More about

QGIS has an advanced labelling engine which can use expressions, data defined properties to make complex label rules. Labelling features have more options as opposed to mapping labels in map composer. Each composer label has its properties which can be customised but the customisation affects the whole label. In some cases, users want to fine-tune the label by separating it based to highlight specific text and the HTML labelling allows us to achieve this effect. Rendering labels as HTML allow for nice cartographic visualisation and add more options to the QGIS labelling engine. One useful scenario for rendering labels as HTML is when you want to create a composite label that contains different types of text sizes and colours.

Check your knowledge:

  1. Which of the following statement is incorrect:
    1. HTML labels cannot be combined with expressions
    2. A logo can be inserted as an HTML when the image is fetched from the internet
    3. Text labels can be converted into HTML labels in map composer.
  2. HTML labels can be used when your map consists of vector layer only :
    1. True
    2. False