Present your full code then.
Not just the snippet that works fine when I copy/paste it to my html file