Transparent <font color> becomes red

This html shows a red text in Chrome and Firefox:

<font color="rgba(0,0,0,0)">foobar</font>

One would expect transparent font. Is this a browser-bug?

>Solution :

You are confusing HTML and CSS. The color attribute of the font element only takes an hex value, such as #000000 which doesn’t support transparency. (See https://developer.mozilla.org/en-US/docs/Web/HTML/Element/font#attr-color). rgba(0,0,0,0) is CSS syntax and can’t be used there.

Generally you shouldn’t be using the font element anyway.

Leave a Reply