Cell Highlighting

Add CSS classes to cells for highlighting based on their content.

Highlighting or, more in general, changing the styling of individual cells is possible using “Custom CSS” code. This can be tedious if the cell that is to be changed often changes. If the cells contains a suitable search term, this can be used to automatically apply the highlighting to matching cells.

By the way: The Row Highlighting feature module allows this for entire rows!

Feature description

In the table below, the goal is to automatically change the styling (here to different background colors with bold font) of all cells that contain the country names “Australia” or “Chile” or the sports “Basketball” or “Golf”:

NameYearCountrySport
Eric1986SwedenSoccer
Julia1991GermanyBasketball
Adam2002IndonesiaGolf
Kim1986ChileBadminton
Jackson1998AustraliaBaseball
Cade1986IndiaBadminton
Keaton2003Costa RicaBasketball
Ray1999FranceGymnastics
Omar1984BrazilTennis
Maite1986NorwayWrestling
Jeremy1987United StatesFencing
Libby1989AustriaSwimming
Kermit1994UkraineVolleyball
Madison1988United StatesBoxing
Francis1993ChileVolleyball
Leigh1988AustriaRugby
Caleb1981ChinaGymnastics
Alexandra1985BelgiumWrestling
Ivana2000ItalyFencing
Craig1986BrazilAthletics
Joshua1981South AfricaGymnastics
Ryder1981BrazilSwimming
Faith1980IndonesiaBoxing
Janna1984PolandTable Tennis
Alana1986UkraineGymnastics
Wesley1981BrazilBadminton
Ina1991United StatesCycling
Amery2003ChinaSoccer
Lavinia2002FranceRowing
Maggie1981Costa RicaSkating
Walker1986MexicoBadminton
Barry1983United StatesCricket
Cheryl1982ChileHockey
Eugenia1991ItalyVolleyball
Ulla2006NetherlandsBaseball
Cynthia1999GermanySoccer
Kyle1983ItalyBoxing
Byron1984South AfricaSwimming
Matthew1994SwedenCycling
Claudia2000SpainRugby

To achieve this, the highlight term was set to

Australia||Chile||Basketball||GolfCode language: plaintext (plaintext)

which contains the || logic operator to allow for searching multiple different terms

Cells that contain one of these search terms get the respective additional CSS class

highlight-australia
highlight-chile
highlight-basketball
highlight-golfCode language: plaintext (plaintext)

where the search term is appended to the string highlight- in lowercase, and (if used) special characters removed.

These CSS classes can be used in CSS code that is added to the “Custom CSS” text area:

.tablepress-id-123 .highlight-australia {
  background-color: #c00000 !important;
  font-weight: bold;
}
.tablepress-id-123 .highlight-chile {
  background-color: #00c000 !important;
  font-weight: bold;
}
.tablepress-id-123 .highlight-basketball {
  background-color: #00c0c0 !important;
  font-weight: bold;
}
.tablepress-id-123 .highlight-golf {
  background-color: #c0c000 !important;
  font-weight: bold;
}Code language: CSS (css)

Usage instructions

To use this feature with your tables, configure the desired options on the table’s “Edit” screen.

Alternatively, configure the desired options in the “Cell Highlighting” section of the “Settings” sidebar of the table’s “TablePress table” block when editing the post or page with the table.

The available settings for the Cell Highlighting module in the "Settings" sidebar of the "TablePress table" block.
The available settings for the Cell Highlighting module in the “Settings” sidebar of the “TablePress table” block.

After this, add the customized CSS code for the desired highlight styling to the “Custom CSS” text area on the “Plugin Options” screen.

Configuration parameters

To configure this module’s features, you can also use these configuration parameters in the “TablePress Table” block or in the Shortcode that you are using to embed the table:

ModuleSlugConfiguration parameterNameDescriptionTypeDefault value
Cell Highlightingcell-highlightinghighlightCell Highlight termCells that contain this term will be highlighted. You can combine multiple highlight terms with an OR operator, e.g. term1||term2 or term1&&term2.string"" (empty string)
Cell Highlightingcell-highlightinghighlight_full_cell_matchFull cell matchingIf this is true, the full cell content has to match the highlight term.boolean (true or false)false
Cell Highlightingcell-highlightinghighlight_case_sensitiveCase-sensitive matchingIf this is true, the case sensitivity of the highlight term has to match the content in the cell.boolean (true or false)false
Cell Highlightingcell-highlightinghighlight_columnsHighlight columnsA comma-separated list of the columns which should be searched for the highlight terms, e.g. 1,3-5,7. By default, all columns will be searched.string"" (empty string) // “” equates to ‘all’.
Cell Highlightingcell-highlightinghighlight_url_parameterCell Highlight URL parameterThis allows providing the Cell Highlight term in a URL parameter.string"" (empty string)