Customizing the Highlight Color for Search Hits

Customizing the Highlight Color for Search Hits

When users perform searches in your online output, the keywords that are found may be highlighted in the topics. The background for each term found in a topic can be highlighted in a different color. In Flare you can use styles to change not only the color background, but other settings as well (e.g., font style, text decoration).

Customizing the highlight color for search hits is useful when you want to coordinate the visual elements of your online target with a color palette or scheme. It can also be used to improve the accessibility of your documentation. For example, if you are developing a project for an audience with impaired vision, you might want to customize the search highlighting to provide users with a higher color contrast.

For most types of output, you can customize the highlight color using span styles (e.g., span.SearchHighlight1, span.SearchHighlight2) in a regular stylesheet. For HTML5 Tripane output, this is done in the Skin Editor instead.

Example

Example You have the following three classes: span.SearchHighlight1, span.SearchHighlight2, and span.SearchHighlight3. For span.SearchHighlight1, you change the background color to blue. For span.SearchHighlight2, you change the background color to orange. And for span.SearchHighlight3, you change the background color to yellow.

If a user enters "topic information help find" in the search field, the term "topic" will be displayed with a blue background everywhere it occurs in a topic. The term "information" will be displayed with an orange background, and the term "help" will be displayed with a yellow background. The term "find" will be displayed with the default background color specified by Flare (since you did not change it).

If another user enters "help find topic information" in the search field, the term "help" will be displayed with a blue background. The term "find" will be displayed with an orange background, and the term "topic" will be displayed with a yellow background. The term "information" will be displayed with the default background color specified by Flare (since you did not change it).

How to Customize Search Highlight Colors

  1. From the Content Explorer, open the stylesheet that you want to modify.
  2. Complete one of the following sets of steps, depending on whether you want to use the Simplified view or Advanced view in the Stylesheet Editor.

    • Simplified The Simplified view displays styles in a grid view and is often best for brand new users.

      This view provides an easy way to apply properties to styles, with format options available from a toolbar and dialogs (similar to the way one would use an interface such as Microsoft Word). In some cases, only the most common property options are available in the Simplified view (e.g., font, letter/word spacing, paragraph alignment/indentation, autonumbering format, borders, background). One advantage of the Simplified view is that you can apply a property to multiple styles at the same time. You can also click a check box to hide the properties in the editor, allowing you to see only the styles.

    • Advanced The Advanced view displays styles in a tree structure, and despite the name, is user friendly for authors of all levels.

      For the properties, you can toggle between a grouped display and an alphabetical display. The Advanced view of the Stylesheet Editor lets you edit more settings than are available in the Simplified view. In addition, the Advanced view lets you see and apply settings to multiple mediums and media queries at the same time.

  3. If Using Simplified View

    1. In the local toolbar, make sure the first button displays Simplified View button (which means that the Simplified view is currently shown in the editor). If the button displays Advanced View button instead, then click it.
    2. In the upper-left corner of the editor, click in the drop-down field and select .
    3. (Optional) If you have an older stylesheet that does not yet contain the appropriate span classes you need for search highlighting, you can create them. You can do this for a main "SearchHighlight" class, as well as for the first 10 terms that users enter in the search field, naming each class "span.SearchHighlight1," "span.SearchHighlight2," and so on until you create "span.SearchHighlight10." The easiest way to create these classes is to import them from a Flare factory stylesheet, but you can also create them manually.

      To Import These Classes From a Flare Factory Stylesheet

      1. In the local toolbar, click the Options button and select Import Styles. The Import Styles dialog opens.
      2. In the Library Folders section, make sure Factory Stylesheets is selected.
      3. In the Stylesheets section, select SearchHighlight.
      4. (Optional) In the [Medium] drop-down list, you can select a specific medium. This determines the medium to which the styles are imported in your current stylesheet. If you select "default," the imported style properties will be applied to all of the mediums in the other stylesheet. If you select a custom medium, the imported style properties will be imported to that medium in the other stylesheet. For more information see Mediums and Media Queries.
      5. In the section below, click the Import check box next to each style class named span.SearchHighlight followed by a number. There are 10 of these style classes.
      6. Click OK. The style classes are added to the current stylesheet.

      To Create These Classes Manually

      1. From the grid in the bottom portion of the Stylesheet Editor, select the span tag.
      2. In the local toolbar, click . The New Selector dialog opens.
      3. Enter SearchHighlight1 (or replace 1 with another number at the end, up to 10).
      4. Click OK.
    4. Select the style class that you want to modify. If you select the main SearchHighlight class, the same color will be used for all search terms found. Otherwise, you can select a numbered SearchHighlight class (e.g., SearchHighlight1, SearchHighlight2) to set individual colors for different terms found.
    5. In the local toolbar of the editor, click Display properties for the selected item.. The Properties dialog opens.
    6. Use the Properties dialog to change values for the style's properties.

      Example You want to change the background color for the class span.SearchHighlight1. After you select that class on the left you can select the Font tab in the Properties dialog. Then click the down arrow in the Background field and choose the color you want.

    7. In the Properties dialog, click OK.

    If Using Advanced View

    1. In the local toolbar, make sure the first button displays Advanced View button. If the button displays Simplified View button instead, then click it.
    2. In the upper-left corner of the editor, click in the drop-down field and select .
    3. (Optional) If you have an older stylesheet that does not yet contain the appropriate span classes you need for search highlighting, you can create them. You can do this for a main "SearchHighlight" class, as well as for the first 10 terms that users enter in the search field, naming each class "span.SearchHighlight1," "span.SearchHighlight2," and so on until you create "span.SearchHighlight10." The easiest way to create these classes is to import them from a Flare factory stylesheet, but you can also create them manually.

      To Import These Classes From a Flare Factory Stylesheet

      1. In the local toolbar, click the Options button and select Import Styles. The Import Styles dialog opens.
      2. In the Library Folders section, make sure Factory Stylesheets is selected.
      3. In the Stylesheets section, select SearchHighlight.
      4. (Optional) In the [Medium] drop-down list, you can select a specific medium. This determines the medium to which the styles are imported in your current stylesheet. If you select "default," the imported style properties will be applied to all of the mediums in the other stylesheet. If you select a custom medium, the imported style properties will be imported to that medium in the other stylesheet. For more information see Mediums and Media Queries.
      5. In the section below, click the Import check box next to each style class named span.SearchHighlight followed by a number. There are 10 of these style classes.
      6. Click OK. The style classes are added to the current stylesheet.

      To Import Create These Classes Manually

      1. On the left side of the editor, select the span tag.
      2. In the local toolbar, click . The New Selector dialog opens.
      3. Enter SearchHighlight1 (or replace 1 with another number at the end, up to 10).
      4. Click OK.
    4. Select the style class that you want to modify. If you select the main SearchHighlight class, the same color will be used for all search terms found. Otherwise, you can select a numbered SearchHighlight class (e.g., SearchHighlight1, SearchHighlight2) to set individual colors for different terms found.
    5. From the Show drop-down list on the upper-right side of the editor, select Show drop-down set to display all properties in styles..
    6. (Optional) You can use the toggle button in the local toolbar to show properties below in a group view Stylesheet local toolbar button to show properties in a group view. or an alphabetical view Stylesheet local toolbar button to show properties in an alphabetical view..
    7. Locate the property you want to change. Not only can you change the background color, but you can change any other property for the class as well.
    8. The area to the right of the property is used for selecting and entering values. If you know how to enter the information correctly, you can click in the value field and type it directly. Otherwise, click the ellipsis button Display more options. to the right of the property. Depending on the type of property, the appropriate controls and options display, allowing you to choose or enter values (e.g., select from a drop-down list, click a button, complete fields in a dialog or popup). If you completed values in a popup, click OK at the bottom of the box.

      Example You want to change the background color for the class span.SearchHighlight1. After you select that class on the left you can open the Background property group on the right side of the editor. Then to the right of background-color, click Display more options., then choose the color you want.

  4. Click Save the active file. to save your work.

How to Customize Search Highlight Colors—HTML5 Tripane Only

Use the following steps if you are creating HTML5 Tripane output. If you are creating HTML5 Side Navigation, Top Navigation, or skinless output, use the steps above for doing this in a stylesheet.

  1. In the Project Organizer, open the Skins folder.
  2. Open the desired HTML5 Tripane skin.
  3. In the Skin Editor, click the Styles tab.
  4. On the left side of the editor, in the Search Results section, expand the Search Highlight style.
  5. If you want the setting(s) to be applied to all of the items, complete the fields under the main Search Highlight style itself. Otherwise, expand any of the child styles (Search Highlight 01 to 10) to apply settings to them individually. Each search highlight style is numbered to coordinate with the order search terms are entered. For example, the style named "Search Highlight 01" will be used for matches to the first search term entered and "Search Highlight 10" would coordinate with the tenth entered term. You can customize up to 10 highlight colors. For more information about root and children properties, see HTML5 Skin Styles.
  6. Click Save the active file. to save your work.

What’s Noteworthy?

Note Search highlighting for Eclipse Help is provided by the Eclipse platform. Highlight colors for search cannot be modified in Flare.