Completely agree - I brought up that same point and was told the trouble is that web browsers are too smart and recognize HTML tags so they figure "I know what this person is doing... I'll fix it". It sounds like you have some experience with HTML - if you are comfortable I would open up TextEdit or NotePad and copy and paste the code in - then have the students debug why it isn't showing if you opened it locally. For some advanced students I had them using WebStorms from JetBrains (it's free for students with an educational email address) - this certainly didn't allow for anything to appear outside of the body tags.
Let me know if you have any other questions!