Yes, it is significant that you are using TextEdit. When you do a save as HTML in TextEdit, it actually inserts your HTML code as text in the middle of a HTML document. So, you can't actually enter HTML code using the default settings.
Try changing your preferences to Plain Text instead of the default Rich Text. When you do as 'save as,' make sure you add the .html extension to the file name.
(You can also change your settings to ignore rich text commands in HTML files and not add the .txt extension from plain text files.)