Link to home
Start Free TrialLog in
Avatar of Larry Heimendinger
Larry Heimendinger

asked on

How to get a table cell in HTML to both right align and have text color set

I need some HTML guidance - probably very simple to fix what I am doing wrong.  I am trying to format an email in Microsoft Flow and have the following scenario:

In Flow, I calculate the difference between two numeric fields to send out in the email.  If the difference is negative, i want to format the fields by enclosing it in parenthesis but also want it to be in red, otherwise green.  The email formats a table of both fields and calculated values.  The table has two columns, the left for a description and the right for values.

i know that the detection of negative values works fine as the display was easy to format with () and it is showing up that way.  However, I cannot get the color to appear.

Flow details - if the value is negative, I do a substring() to add () but then set a string variable - let's call it colorname - to red else green if the value is positive.  The HTML code then looks like this (modified for this question):

<tr>
<td>Description of value</td>
<td align=right> valuestring</td>
</tr>

Ant that works perfectly without the color.  If I modify the td to add color it fails

<td align=right; color=colorname> valuestring</td>    I get neither color nor right alignment. I also tried these variants

<td {align:right; color:colorvale;} valuestring</td>
<td align;right; color:colorvalue;} valuestring</td>
<td {text-align:right; color:colorvalue;} valuestring</td>

and probably some others I am forgetting.  Mostly the results have been all no color and left alignment.

Before you comment about colorname being a problem, let me tell you that when Flow runs I can view all the details, and it shows color=red or color=green indicating that the variable contents have been used, so I am somewhat confident that it is sending out the right HTML but not right in the sense of it giving me the results I want.

As I said to start, it's probably something simple, but if you can help me figure it out I would be most appreciative.
Avatar of Chris Stanyon
Chris Stanyon
Flag of United Kingdom of Great Britain and Northern Ireland image

You should be using CSS for this:

<td style="text-align:right; color:red;">Some Value</td>
<td style="text-align:right; color:green;">Some Value</td>

Open in new window

Avatar of Larry Heimendinger
Larry Heimendinger

ASKER

I looked in my history and had tried exactly that usage of CSS.  It still didn't work.  Then I noted i had entered

color;colorname - semi-colon instead of a colon.  Not it works perfectly.  Thanks for helping me catch my error.
No worries.

CSS Rules are set with key : value pairs, and rules are separated with a semi-colon
CSS Rules are set with key : value pairs, and rules are separated with a semi-colon
Actually you mean "declaration". A rule is the selector(s) and any declarations within the curly braces.

https://www.w3.org/TR/CSS21/syndata.html#rule-sets
This question needs an answer!
Become an EE member today
7 DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform.
View membership options
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.