Text Labels - HTML?

The manual says that “By enclosing the text within tags, you can use simple HTML format to specify various colors, fonts and sizes.”

I tried it using an example from the manual (<font color=red>) which worked.

However, when I tried something a bit more complex, it failed:
“<html> <span style=“background-color:Tomato;”> Cadre </span></html>”

Is background-color supported in this usage or am I using a bad HTML construct?

See HTML/CSS Implementation for links to the limited subset of HTML/CSS that Java swing (and hence Vassal) supports.

I suspect that your issue is trying to use “Tomato”… I’ve found that the Vassal implementation supports only a limited number of colour keywords. I’ve ended up using the six digit hex codes. In your example, try #FF6347 in place of Tomato.

Background colour certainly works in html on Vassal.

2 Likes

I started out using the hexcodes, which didn’t work either.

Perusing the both the links Brent posted and the HTML 3.2 Reference Specification, I discovered a couple of things…

  1. “bgcolor = red” works !

  2. (based on my read of the HTML 3.2 reference specification) It appears that back then only 16 common colors were “named” (see below from the specification)…

Colors are given in the sRGB color space as hexadecimal numbers (e.g. COLOR=“#C0FFC0”), or as one of 16 widely understood color names. These colors were originally picked as being the standard 16 colors supported with the Windows VGA palette.
Color names and sRGB values

  • Black = “#000000” Green = “#008000”*
  • Silver = “#C0C0C0” Lime = “#00FF00”*
  • Gray = “#808080” Olive = “#808000”*
  • White = “#FFFFFF” Yellow = “#FFFF00”*
  • Maroon = “#800000” Navy = “#000080”*
  • Red = “#FF0000” Blue = “#0000FF”*
  • Purple = “#800080” Teal = “#008080”*
  • Fuchsia = “#FF00FF” Aqua = “#00FFFF”*

Ref. HTML 3.2 Reference Specification

1 Like

Maybe the embedded quotes are another problem here.
How about escaping them, like this ?

“<html> <span style=\“background-color:Tomato;\”> Cadre </span></html>”

I’ve found that the embedded quotes are usually redundant (missing them out doesn’t cause any noticeable problem). They’re probably mandated by the standards spec but the implementation used by Vassal, I guess, is more relaxed.

That tallies with my experience. I hadn’t got round to investigating what colour names are actually supported, so I’ve been limited to the primary colours in that list. Thanks for posting!

Here’s an example that uses embedded quotes that works (as far as I can tell):

{"<html><span style="+ '"' + "color:" + CharterTextColor + ";" + '"' + ">" + " Cash: "+CashDisplay + "</span></html>"}

Note:
CharterTextColor is the name of a Dynamic Property that contains either an HTML color name or a hexadecimal number for the text color. No background color is specified.

CashDisplay is the name of a Calculated Property that formats a numeric (integer) value with a leading currency symbol and a comma separator for thousands.