yibuyiqu
yibuyiqu

Reputation: 718

font color doesn't work

I have the following html segment presented in my iPad app.

<font size="4px" face="HelveticaNeue" color=rgb(49,49,49)>ABC</font>

It is supposed be dark grey, and it does below iOS 5.1. But on iOS 6 it is in green, and it shows green color in chrome and firefox as well.

Is there any mistake in above code? Why does it work in previous iOS?

Thanks.

Upvotes: 2

Views: 4009

Answers (3)

om_jaipur
om_jaipur

Reputation: 2196

The <font> tag is not supported in HTML5. Use CSS instead!

If you still want to use color attribute, you should try Hexadecimal values #xxxxxx instead of rgb(x,x,x)

Upvotes: 0

Jukka K. Korpela
Jukka K. Korpela

Reputation: 201866

By the HTML 4.01 specification, the value of the size attribute in a font element has a numeric value, without any unit, and the value is taken as an index to a browser-dependent array of sizes. Besides, 4px would make little size if taken as in CSS to mean 4 pixels – at that size, almost all fonts become illegible. Spaces are significant in font names, so HelveticaNeue is quite different from Helvetica Neue. And the color attribute value must be either a 6-digit hexcode prefixed by # or one of the keywords defined in the spec.

The spurious </span> tag is a syntax error but normally ignored by browsers. However, if there was a preceding <span> tag that hasn’t had a matching end tag yet, then (as part of common error recovery) the end tag ends its effect.

So it’s a miracle that the code works anywhere. It does that only because you are using it in a special environment where font markup is interpreted in a manner that happens to coincide with your expectations.

Provided that by 4px you don’t mean 4 pixels but HTML size 4 in a scale from 1 to 7, the size next larger than the default, then the following would be conforming:

<font size="4" face="Helvetica Neue" style="color:#313131;">Text hereABC</font>

though most people would regard the use of CSS as more appropriate. In CSS, you can use e.g. color values like rgb(49,49,49).

Upvotes: 2

StrataGeeks Beta
StrataGeeks Beta

Reputation: 23

use this <font size="4px" face="HelveticaNeue" style="color:#313131;">Text here</span>ABC</font>

Upvotes: 0

Related Questions