Just for the heck of it, I stuffed your posted code into Sigil and did a mend and prettify on it.
One nasty item is that your code seems to use random case (<head> and </HEAD> for example).
I also stuffed your code into calibre's editor and ran it's internal bugchecker (the ladybug icon). I've attached those results as an image.
Basically, Garbage in, Garbage out.