When you search in Magento, on search result page you will see the results with below text for example,

Search results for 'configure'

Here my search keyword is configure.

How can I highlight the searched keyword on results page ?


1 Answer 1


That can be found in app\design\frontend\base\default\template\catalogsearch\result.phtml. So create a local copy of that file in your theme and add some code/CSS to highlight your search term.

The code will look like that:

<h1><?php echo ($this->getHeaderText() || $this->getHeaderText() === false) ? $this->getHeaderText() : $this->__("Search results for '%s'", $this->helper('catalogsearch')->getEscapedQueryText()) ?></h1>

The search term itself comes from:


So you can take that out and add some element around it with a class or id. After that add a style for that class or id, something like:

.yourGivenClass {
    background-color: yellow;
    padding: 5px;

That should be it.


  • The above solution would work only to highlight the searched text. What I want is to highlight the searched text all over my result page.For example if I search t-shirt then all the products on search result page having word t-shirt in their name or description gets highlighted.
    – Mark
    May 1, 2014 at 10:34
  • Well, in that case you have to open the template file and get the name or the description (do you display the description on the search result page at all?) and use a regular expression to search for your seach term in for example the name of the product. If found, replace (preg_replace) the match with <span class="yourGivenClass">$term</span>. That should do it. May 5, 2014 at 11:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.