Short answer
If the color brings a real information, like telling if it succeeded (green) or failed (red), the best is to write it plain text next to the value.
Alternatively, you can use an icon with proper markup.
Longer answer
The general rule as stated in WCAG is don't convey information only with colors, basicly meaning
you must add something else other than just colors to allow everyone to get the information.
You can add anything you like, i.e. text or icon. It's fine as long as there is another way than just color to get the information.
You may be tempted to write the information in plain text but make it visible only for screen reader users, as follows:
<td>123<span class="sr_only"> Success</span></td>
<td>-45<span class="sr_only">Failed</span></td>
Or alternatively, use aria-label with these additional warnings:
- aria-label is guaranteed to be taken into account only if the element is interactive. By default a table cell isn't interactive.
- The aria-label attribute entirely replaces the content of the cell. So you must write
<td aria-label="123, success">123</td> and not <td aria-label="success">123</td> because in that later case the screen reader user won't get the value.
However, both are in fact bad ideas, and don't fully conform to the WCAG rule stated above.
For example, color blind people can see the screen and so don't need a screen reader, but may not be able to make the difference between red and green.
Thus the data wouldn't be accessible to them.
The fixed scale case
IF your colors express some scale, i.e. green is good, yellow is acceptable and red is bad, and if the color depends on fixed values, i.e. green above 60, yellow between 40 and 60 and red below 40, then in fact the color doesn't bring any new information.
It is just a visual indication so that you can quickly see what is good and what is bad. IF you remove the colors, you certainly lose some ease, but the information is still there in the value itself.
IN this case, it can quickly become uselessly noisy to add a text saying "good", "acceptable" or "bad" in each cell,
since as long as you remember the scale, the value itself tells you if it's good or bad.
OF course you will explain clearly and in plain text the meaning of the colors, probably above or below the table, and make the information visible for all users.