1

I did several searches, but couldn't find anything quite similar to this. I did find the same question for Excel, but mine is for HTML/CSS: Highlight cell if an adjacent cell in column has the same value (Excel question).


Essentially I have a sortable HTML table with a bunch of values that can frequently be 100% identical. For example, often the same GUID repeats in several rows. Once I sort the table they end up adjacent to each other, and I want to highlight them both for clarity at that time (only when they are adjacent).

Before I do this in Javascript, I was just wondering if there is a built-in feature in CSS to do this? So many strange things seem to be possible in CSS these days.

Here is a mock up of what I want to do:

enter image description here

Stein Åsmul
  • 39,960
  • 25
  • 91
  • 164
  • 1
    There is no selector in standard CSS that matches text content. Possible duplicate of [Is there a CSS selector for elements containing certain text?](https://stackoverflow.com/questions/1520429/is-there-a-css-selector-for-elements-containing-certain-text), or [CSS selector based on element text?](https://stackoverflow.com/questions/5441680/css-selector-based-on-element-text), or [CSS rule based on content](https://stackoverflow.com/questions/1777357/css-rule-based-on-content) – Tyler Roper Sep 20 '17 at 20:36
  • 2
    I realize that your question is slightly more specific than the duplicates I've marked, but in order for this to work, CSS would have to be able to do the following: 1) Retrieve text from an element. 2) Store the text to compare to other values. 3) Be able to compare non-sibling elements (I assume your content is in `` tags, children of separate `` tags.) - CSS cannot do any of this. – Tyler Roper Sep 20 '17 at 20:47

1 Answers1

1

It is not possible with pure CSS. You must use JavaScript.