> ## Documentation Index
> Fetch the complete documentation index at: https://algolia.com/llms.txt
> Use this file to discover all available pages before exploring further.

# highlightPostTag

> Closing HTML tag for highlighted attributes

export const Setting = ({type, default: defaultValue, defaultNote, scope, min, max, formerly}) => {
  const renderedDefault = defaultValue === '' ? '""' : defaultValue;
  const renderedNote = defaultNote ? `(${defaultNote})` : '';
  return <ul>
      <li><strong>Type:</strong> <code>{type}</code></li>
      <li><strong>Default:</strong> <code>{renderedDefault}</code>{renderedNote}</li>
      {min && <li><strong>Min:</strong> <code>{min}</code></li>}
      {max && <li><strong>Max:</strong> <code>{max}</code></li>}
      <li><strong>Scope:</strong> <a href="/doc/api-reference/api-parameters"><code>{scope}</code></a></li>
      {formerly && <li>
          <strong>Deprecated name:</strong> <code>{formerly}</code>
        </li>}
    </ul>;
};

<Setting type="string" default="</em>" scope="settings,search" />

The `highlightPostTag` parameter defines the HTML tag inserted **after** the matching text in highlighted attributes.
It works in combination with [`highlightPreTag`](/doc/api-reference/api-parameters/highlightPreTag),
which marks the beginning of the highlighted portion.

## Usage

* Set an empty string (`""`) to fallback to the default tag.
* To turn off highlighting, remove the searchable attribute with the [`attributesToHighlight`](/doc/api-reference/api-parameters/attributesToHighlight) parameter.

## Examples

### Set default tag

<AccordionGroup>
  <Accordion title="Current API clients" defaultOpen="true">
    <CodeGroup>
      ```cs C# theme={"system"}
      var response = await client.SetSettingsAsync(
        "INDEX_NAME",
        new IndexSettings { HighlightPostTag = "</em>" }
      );
      ```

      ```dart Dart theme={"system"}
      final response = await client.setSettings(
        indexName: "INDEX_NAME",
        indexSettings: IndexSettings(
          highlightPostTag: "</em>",
        ),
      );
      ```

      ```go Go theme={"system"}
      response, err := client.SetSettings(client.NewApiSetSettingsRequest(
        "INDEX_NAME",
        search.NewEmptyIndexSettings().SetHighlightPostTag("</em>")))
      if err != nil {
        // handle the eventual error
        panic(err)
      }
      ```

      ```java Java theme={"system"}
      UpdatedAtResponse response = client.setSettings("INDEX_NAME", new IndexSettings().setHighlightPostTag("</em>"));
      ```

      ```js JavaScript theme={"system"}
      const response = await client.setSettings({
        indexName: 'theIndexName',
        indexSettings: { highlightPostTag: '</em>' },
      });
      ```

      ```kotlin Kotlin theme={"system"}
      var response =
        client.setSettings(
          indexName = "INDEX_NAME",
          indexSettings = IndexSettings(highlightPostTag = "</em>"),
        )
      ```

      ```php PHP theme={"system"}
      $response = $client->setSettings(
          'INDEX_NAME',
          ['highlightPostTag' => '</em>',
          ],
      );
      ```

      ```python Python theme={"system"}
      response = client.set_settings(
          index_name="INDEX_NAME",
          index_settings={
              "highlightPostTag": "</em>",
          },
      )
      ```

      ```ruby Ruby theme={"system"}
      response = client.set_settings("INDEX_NAME", Algolia::Search::IndexSettings.new(highlight_post_tag: "</em>"))
      ```

      ```scala Scala theme={"system"}
      val response = Await.result(
        client.setSettings(
          indexName = "INDEX_NAME",
          indexSettings = IndexSettings(
            highlightPostTag = Some("</em>")
          )
        ),
        Duration(100, "sec")
      )
      ```

      ```swift Swift theme={"system"}
      let response = try await client.setSettings(
          indexName: "INDEX_NAME",
          indexSettings: IndexSettings(highlightPostTag: "</em>")
      )
      ```
    </CodeGroup>
  </Accordion>

  <Accordion title="Legacy API clients">
    <CodeGroup>
      ```cs C# theme={"system"}
      IndexSettings settings = new IndexSettings()
      settings.HighlightPostTag = "";

      index.SetSettings(settings);
      ```

      ```go Go theme={"system"}
      res, err := index.SetSettings(search.Settings{
      	HighlightPostTag: opt.HighlightPostTag(""),
      })
      ```

      ```java Java theme={"system"}
      index.setSettings(
        new IndexSettings()
          .setHighlightPostTag("")
      );
      ```

      ```js JavaScript theme={"system"}
      index
        .setSettings({
          highlightPostTag: "",
        })
        .then(() => {
          // done
        });
      ```

      ```kotlin Kotlin theme={"system"}
      val settings = settings {
          highlightPostTag = ""
      }

      index.setSettings(settings)
      ```

      ```php PHP theme={"system"}
      $index->setSettings([
        'highlightPostTag' => ''
      ]);
      ```

      ```python Python theme={"system"}
      index.set_settings({"highlightPostTag": ""})
      ```

      ```ruby Ruby theme={"system"}
      index.set_settings(
        {
          highlightPostTag: ""
        }
      )
      ```

      ```scala Scala theme={"system"}
      client.execute {
        setSettings of "myIndex" `with` IndexSettings(
          highlightPostTag = Some("")
        )
      }
      ```

      ```swift Swift theme={"system"}
      let settings = Settings()
        .set(\.highlightPostTag, to: "")

      index.setSettings(settings) { result in
        if case .success(let response) = result {
          print("Response: \(response)")
        }
      }
      ```
    </CodeGroup>
  </Accordion>
</AccordionGroup>

### Change default tag for the current search

<AccordionGroup>
  <Accordion title="Current API clients" defaultOpen>
    <CodeGroup>
      ```cs C# theme={"system"}
      var response = await client.SearchSingleIndexAsync<Hit>(
        "INDEX_NAME",
        new SearchParams(new SearchParamsObject { Query = "query", HighlightPostTag = "</strong>" })
      );
      ```

      ```dart Dart theme={"system"}
      final response = await client.searchSingleIndex(
        indexName: "INDEX_NAME",
        searchParams: SearchParamsObject(
          query: "query",
          highlightPostTag: "</strong>",
        ),
      );
      ```

      ```go Go theme={"system"}
      response, err := client.SearchSingleIndex(client.NewApiSearchSingleIndexRequest(
        "INDEX_NAME").WithSearchParams(search.SearchParamsObjectAsSearchParams(
        search.NewEmptySearchParamsObject().SetQuery("query").SetHighlightPostTag("</strong>"))))
      if err != nil {
        // handle the eventual error
        panic(err)
      }
      ```

      ```java Java theme={"system"}
      SearchResponse response = client.searchSingleIndex(
        "INDEX_NAME",
        new SearchParamsObject().setQuery("query").setHighlightPostTag("</strong>"),
        Hit.class
      );
      ```

      ```js JavaScript theme={"system"}
      const response = await client.searchSingleIndex({
        indexName: 'indexName',
        searchParams: { query: 'query', highlightPostTag: '</strong>' },
      });
      ```

      ```kotlin Kotlin theme={"system"}
      var response =
        client.searchSingleIndex(
          indexName = "INDEX_NAME",
          searchParams = SearchParamsObject(query = "query", highlightPostTag = "</strong>"),
        )
      ```

      ```php PHP theme={"system"}
      $response = $client->searchSingleIndex(
          'INDEX_NAME',
          ['query' => 'query',
              'highlightPostTag' => '</strong>',
          ],
      );
      ```

      ```python Python theme={"system"}
      response = client.search_single_index(
          index_name="INDEX_NAME",
          search_params={
              "query": "query",
              "highlightPostTag": "</strong>",
          },
      )
      ```

      ```ruby Ruby theme={"system"}
      response = client.search_single_index(
        "INDEX_NAME",
        Algolia::Search::SearchParamsObject.new(query: "query", highlight_post_tag: "</strong>")
      )
      ```

      ```scala Scala theme={"system"}
      val response = Await.result(
        client.searchSingleIndex(
          indexName = "INDEX_NAME",
          searchParams = Some(
            SearchParamsObject(
              query = Some("query"),
              highlightPostTag = Some("</strong>")
            )
          )
        ),
        Duration(100, "sec")
      )
      ```

      ```swift Swift theme={"system"}
      let response: SearchResponse<Hit> = try await client.searchSingleIndex(
          indexName: "INDEX_NAME",
          searchParams: SearchSearchParams.searchSearchParamsObject(SearchSearchParamsObject(
              query: "query",
              highlightPostTag: "</strong>"
          ))
      )
      ```
    </CodeGroup>
  </Accordion>

  <Accordion title="Legacy API clients">
    <CodeGroup>
      ```cs C# theme={"system"}
      index.Search(new Query("query")
      {
          HighlightPostTag = ""
      });
      ```

      ```go Go theme={"system"}
      res, err := index.Search(
      	"query",
      	opt.HighlightPostTag(""),
      )
      ```

      ```java Java theme={"system"}
      index.search(
        new Query("query")
          .setHighlightPostTag("")
      );
      ```

      ```js JavaScript theme={"system"}
      index
        .search("query", {
          highlightPostTag: "",
        })
        .then(({ hits }) => {
          console.log(hits);
        });
      ```

      ```kotlin Kotlin theme={"system"}
      val query = query("query") {
          highlightPostTag = ""
      }

      index.search(query)
      ```

      ```php PHP theme={"system"}
      $results = $index->search('query', [
        'highlightPostTag' => ''
      ]);
      ```

      ```python Python theme={"system"}
      results = index.search("query", {"highlightPostTag": ""})
      ```

      ```ruby Ruby theme={"system"}
      results = index.search(
        "query",
        {
          highlightPostTag: ""
        }
      )
      ```

      ```scala Scala theme={"system"}
      client.execute {
        search into "myIndex" query Query(
          query = Some("query"),
          highlightPostTag = Some("")
        )
      }
      ```

      ```swift Swift theme={"system"}
      let query = Query("query")
          .set(\.highlightPostTag, to: "")

      index.search(query: query) { result in
        if case .success(let response) = result {
          print("Response: \(response)")
        }
      }
      ```
    </CodeGroup>
  </Accordion>
</AccordionGroup>
