Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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.

like image 680
junky Avatar asked Mar 12 '12 18:03

junky


People also ask

How do I open a local HTML File on a Mac?

View an HTML document In the TextEdit app on your Mac, choose File > Open, then select the document. Click Options at the bottom of the TextEdit dialog, then select “Ignore rich text commands.” Click Open.

Why is this HTML showing up as plain text in browser?

This HTML isn't being interpreted as plain text: it's being interpreted as HTML. It's just that the contents of your HTML include markup that has been escaped, such as &lt; and &gt; .

How do I open a local HTML File in Chrome on a Mac?

Use The Open With Command Find the HTML file you want to view, right-click on it, and choose Open with from the menu. You will see a full list of apps that you can use to run your file. Your default browser will be at the top of the list. Select Google Chrome from the list, and view your file in the browser.

Why is HTML File not displaying in browser?

Possible Reasons: You might not have saved the changes after writing the code (most likely). Problem with the browser (load it in another browser) Check the extension (just for clarification)


1 Answers

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

like image 100
junky Avatar answered Sep 27 '22 22:09

junky