简体   繁体   中英

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?

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

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.

Download install "TextWrangler" (for mac) paste your html content to a new file in it and save with .html link. Dont use TextEdit.

If you open the file using a basic text editor (like nano from the terminal), you'll probably see there's a lot of additional lines added to your basic HTML code. That's what happened to me.

I removed all the lines except what I wanted and it finally rendered correctly.

I've had the same issue in TextEdit. The resolution is - go to "Format", then "Make plain text". Save the document and open it again in browser. It had worked in my case. Hope it will work for you too.

I found that the parent folder on my web server contained an old .htaccess file that was causing HTML files to display as plain text. Renaming/reworking the .htaccess file or just moving my HTML file to another folder fixed the issue.

I have same issue. I am using TextEdit. Issue was fixed by following the change: text edit->preferences>New document>Fromat>plain text (not Rich text).

Use a text editor such as Dreamweaver, Sublime

Sublime http://www.sublimetext.com/2

and ensure your file ends in .html not .txt

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM