Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Browser shows plain text instead of HTML in mac

I want to write an html document like this :

<html>
<body>

<h1>My First Heading</h1>

</body>
</html>

I wrote it and saved it in my desktop with the name hello.html , but when I open this file with firefox or safari, the browser shows the whole text (including <html> and all of the texts) instead of only showing my first heading! what's the problem?

like image 300
Navid777 Avatar asked Jan 21 '13 13:01

Navid777


People also ask

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 view HTML in browser on Mac?

Open Safari. Navigate to the web page you would like to examine. Select the Develop menu in the top menu bar. Select the Show Page Source option to open a text window with the HTML source of the page.

How do I enable HTML on Mac?

Always open HTML files in code-editing mode In the TextEdit app on your Mac, choose TextEdit > Preferences, then click Open and Save. Select “Display HTML files as HTML code instead of formatted text.”


2 Answers

The problem was that I wrote the HTML document with "Text Edit" application, and it saved the file with .rtf extension, that is not plain text, so changing the name of file to hello.html didn't change anything.

there are two ways to fix this problem:

1) if you insist on using "Text Edit" you should go to text edit->preferences and tick the plain text at top of the page, then when you save something, it is saved as plain text

2) you can use some text editor, like lime edit

like image 170
Navid777 Avatar answered Oct 11 '22 01:10

Navid777


The most likely reason is that you used a WYSIWYG editor and saved the document as HTML.

This created an HTML representation of the HTML source code you typed.

Use a text editor instead. I'm fond of Sublime Edit 2.

like image 43
Quentin Avatar answered Oct 11 '22 03:10

Quentin