🎉 Try the public beta of the new docs site at algolia.com/doc-beta! 🎉
API Reference / API Parameters / highlightPreTag
Type: string
Engine default: "<em>"
Parameter syntax
'highlightPreTag' => 'opening_tag'

Can be used in these methods:

About this parameter

The HTML string to insert before the highlighted parts in all highlight and snippet results.

Usage notes

  • highlightPreTag needs to be used along with highlightPostTag
  • If you specify an empty string, the engine will use the default <em> tag instead
  • To turn off highlighting, remove the searchable attribute with the attributesToHighlight parameter

Examples

Set default highlight pre tag

1
2
3
$index->setSettings([
  'highlightPreTag' => '<em>'
]);
1
2
3
$results = $index->search('query', [
  'highlightPreTag' => '<strong>'
]);
Did you find this page helpful?