If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

What program are you using to edit the code? It looks like you have a character encoding problem. Your program is probably switching between encodings so that the input is first in one format then the output is in another, and this continues creating the garbage you see.

By default, Text Edit will be problematic for code. You need to switch the mode to Format -> Make Plain Text. However, this will remove all formatting. Basically you can't open plain text within Text Edit, at least I haven't figured out how. You can actually edit websites without a problem if you start a new document and make it plain text first then edit it like that, but I have not found a way around opening an HTML document. I suppose you can rename it .txt first instead of .htm, but that's annoying.

I strongly recommend that you find a better editor for doing websites. Text Edit is not designed for it.

I highly recommend Text Wrangler if you're on a Mac. It's free and works well, and it includes FTP so you can edit directly on your website.

That's correct, in a certain way. A "text editor" as the term is used there refers specifically to a plain text editor. Programs like MS Word, Text Edit, and others used for word processing tend to be rich text editors. The formats vary, but .txt is the standard plain text format (it stands for "text"). For rich text, the most basic is .rtf (rich text format) and that is the default of Text Edit, Word Pad and a few others. The MS Word format .doc is something else, but it's also rich text (not strictly .rtf, but still includes formatting obviously). Regardless, what you need for making a website is a plain text editor that by default has a plain text format. The most common will be a .txt editor (just make a new file and choose save, and see what the default format is). And of course there are others that are specifically for web design and by default will save in .htm or another web design format. Note that .htm (and many other programming/scripting/markup languages) are actually exactly the same as .txt except that they are processed differently in browsers. But on the system they're saved exactly as .txt files, just with .htm and usually include html code.
That's probably more information than you need at the moment, but I hope it helps a bit and if anyone else has a similar question now it's answered.

It's also confusing because windows comes with notepad, a plain text editor, while Mac comes with Text Edit, which is actually a rich text editor despite the fact that it seems just like notepad at first. So there's no default program on a mac for editing .htm-- but Text Wrangler is one of my favorite programs (of any type), so that's easy, and it's free.

One more thought: on OS8 and OS9 (before OSX), there was a problem called SimpleText. That was almost exactly the same as Notepad. It's a plain text editor. So if you happen to have an older version of OSX where the older apps still work (I think OSX 10.2 might be the latest for that), then SimpleText will work well for editing HTML like Notepad.
When I still had SimpleText available, I used to use that for HTML sometimes. I think this might help someone else who has a similar issue.

Like the difference between Notepad and Text Edit, SimpleText and Text Edit are very different. I don't really understand why Apple decided to change it that way.