I’m trying to set background colours on a few different elements in an html page, but whenever I apply a doctype declaration the colours get ignored. Other styles seem unaffected. I’m sure I’m being an idiot.
It happens on IE7, FF3 and Chrome. With Strict and Transitional html 4 Doctype. Body and Div backgrounds are affected. A minimal example is below. If you delete the Doctype delcaration, it’s rendered in all it’s garish glory, with doctype – tedious black and white only.
<!DOCTYPE html PUBLIC '-//W3C//DTD HTML 4.01 Transitional//EN' 'http://www.w3.org/TR/html4/loose.dtd'> <html> <head> <style> body{background-color:FF00FF;} .class1{background-color:00FFFF;} </style> </head> <body> <div class='class1'>Some Text</div> </body> </html>
BTW – I’m not using XHTML because I think I once overheard a conversation in a pub between much cleverer people than myself who said that said you shouldn’t declare XML unless the mime types are correctly set on your server. On my cheapo hosting account I can’t do that sort of thing easily.
You forgot the
#in the color values.