This page lists various HTML tricks I have discovered over the years.
Show Example Code
You can wrap any HTML code in <xmp></xmp> tags to display is as example code rather than having to convert all the greater then and less than signs to their > and < equivalents.
FONT COLOR Oddity
The depreciated FONT tag has a COLOR element which doesn't function like colors in the new STYLE element. Both the old and new HTML examples below give the same result with red text:
- <P><FONT COLOR=red>This text will be red.</FONT></P>
- <P STYLE=COLOR:red>This text will be red.</P>
However, if you use a word that isn't a valid HTML color (e.g., "lsfrq") using the STYLE element, browsers resort to the document's default color, which is usually black. However, if you use the depreciated FONT COLOR, it is processed differently. When it sees data that isn't a color word, the browser assumes it's reading a hex RGB value, and any non-hex number is treated as a 0. Thus, the value "lsfrq" is converted to #00F000, a shade of green.
- <P><FONT COLOR=lsfrq>This text will be green.</FONT></P>
- <P STYLE=COLOR:lsfrq>This text will be black.</P>
I tested this in FireFox, Chrome, and IE, and each functions the same way.