Colored/Coloured HTML <span> tag from Dialog input

Why not make a example to use HTML tag to make colored/coloured text.

Ps. You could find other colours here: HTML Color Names

Some text in color Yellow

Other text in color Green

My favorite color is Blue

ex. In the dialog you type: Some text in color Yellow,yellow

Save the code below as menu script, ex. ~/Library/Scripts/Applications/Safari

use framework "Foundation"
use scripting additions

on run
	set dialogString to (display dialog "Type word/sentence and end with comma and span tag color" default answer "")'s text returned
	
	set theString to current application's NSString's stringWithString:dialogString
	set theComponents to theString's componentsSeparatedByString:","
	
	set theString to current application's NSMutableString's alloc()'s init()
	theString's appendFormat_("<span style=color:%@>%@</span>", item 2 of theComponents, item 1 of theComponents)
	set the clipboard to (theString as string)
end run

Its also possible to use background-color
My text is background color of green

Ps. The problem could be that the color you choose isn’t the best look-feel in light vs dark appearance.

ex.
Text in Yellow looks good in dark mode appearance but not in light.