junky
junky

Reputation: 1478

On a Mac, I created a .html document locally but in a browser I just see HTML source

On a Mac, I created a file with some very simple html, e.g. <h1>my web page</h1> I save it as .html. I start firefox or Opera and I use open file, but I just see the content as html source, e.g. I see <b> tags, etc.

If you want all the code here it is:

<html>
<head>
</head>
<body>
  <h1>My Web Page</h1>
</body>
</html>

Edit: 'Rich text' format was the issue. See my answer below.

Upvotes: 10

Views: 12277

Answers (3)

junky
junky

Reputation: 1478

Shad was actually on to the right answer here.

The problem was that I was using the standard mac text editor - textedit - and it was saving the document type as rich text formatting (the standard). I had to go into textedit preferences and make change the default formatting for a new document from Rich text to Plain text. This fixed the problem! As this was a stupid problem, yet not obvious to most I'll post the screen shot of where you change that default new document preference in textedit prefs.

enter image description here

Upvotes: 10

Manny Morales
Manny Morales

Reputation: 1

Open the "Get Info" of the file by right clicking on the file (or control click) and selecting Get Info. Under the section titled Name & Extension un-check Hide extension. You will see that mac has added an extension (usually .txt), just remove that extension and close

Upvotes: -1

DanRedux
DanRedux

Reputation: 9349

Probably because of some silly header stuff. Browsers use the header information to decide how to render it, not the extension, I think. You know, there's a tiny chance that any file- exe, jpg, png, txt- could actually appear as valid HTML because they're both just files at heart.

Upvotes: 0

Related Questions