Which Doctype have you used? Or: have you used any Doctype in the top of your document?
On the other side it is a good habit to use always
the braces whenever you are dealing with conditionals, loops, etc:
//statements, expressions, etc...
At least to help the others to follow your codes, if not for other reason.