Browser shows plain text instead of HTML in mac

给你一囗甜甜゛ 提交于 2019-12-23 20:21:52

问题


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?


回答1:


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




回答2:


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.




回答3:


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




回答4:


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.




回答5:


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.




回答6:


Use a text editor such as Dreamweaver, Sublime

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

and ensure your file ends in .html not .txt



来源:https://stackoverflow.com/questions/14439513/browser-shows-plain-text-instead-of-html-in-mac

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!