To style labels with SLD, you can use a TextSymbolizer, which includes settings to configure the label content, the label location, and styling settings such as the font and the color. To enhance the readability of labels, users commonly want to add a box around a label. The OGC SLD/SE standards don’t support this capability, But LuciadLightspeed and LuciadFusion do support it by means of an SLD/SE extension.

To add a box around label text:

  1. Add the well-known mark square as a graphic to the TextSymbolizer. You can configure the desired stroke and fill settings for the box on the graphic.

  2. Add the vendor option graphic-resize=stretch to the TextSymbolizer. With this setting, you make sure to stretch the well-known mark square to contain the label.

  3. Optionally, add the vendor option graphic-margin to the TextSymbolizer. This vendor option takes an integer value to represent the desired padding in pixels between the label and its box.

The order of these elements is important. Place them at the end of the TextSymbolizer block.

This example adds a label with a box to a line geometry:

Program: Defining a text style with a box
<?xml version='1.0' encoding='UTF-8'?>
<FeatureTypeStyle xmlns=""
        <SvgParameter name="font-style">
        <SvgParameter name="font-weight">
        <SvgParameter name="font-size">
        <SvgParameter name="font-family">Lucida Sans</SvgParameter>
            <SvgParameter name="fill-opacity">
            <SvgParameter name="fill">#FFFF00</SvgParameter>
            <SvgParameter name="stroke-opacity">
            <SvgParameter name="stroke">#0000FF</SvgParameter>
            <SvgParameter name="stroke-width">
      <VendorOption name="graphic-resize">stretch</VendorOption>
      <VendorOption name="graphic-margin">4</VendorOption>
        <SvgParameter name="stroke-width">
        <SvgParameter name="stroke">
        <SvgParameter name="stroke-opacity">