Browser shows plain text instead of HTML in mac

39,333

Solution 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

Solution 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.

Share:
39,333
Navid777
Author by

Navid777

I'm a mathematics student in Sharif University of Technology

Updated on July 16, 2022

Comments

  • Navid777
    Navid777 almost 2 years

    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?

  • Quentin
    Quentin over 11 years
    Use a text editor (or force TextEditor to save in plain text mode … but getting a decent editor would be better, you get other benefits like syntax highlighting).
  • feeela
    feeela over 11 years
    What does the editor has to do with the file extensions given for a file? (Except nothing.)
  • Quentin
    Quentin over 11 years
    It is what I use. There are lots of options out there. TextWrangler is free.
  • feeela
    feeela over 11 years
    Why is the choice of the editor important for which file extension is set to a file on save?
  • Quentin
    Quentin over 11 years
    @feeela — It isn't and I never said it was. The OP had two problems. This answer addresses only one of them. The other was resolved in comments.
  • Navid777
    Navid777 over 11 years
    @quentin what should I do now ? accept your answer and vote up user23127's comment, or write an answer that contains both ?
  • Dimitri Kouvdis
    Dimitri Kouvdis over 11 years
    Just in case. Opening a new window with Sublime text without changing the format could result in this (I mean hello.html.txt).
  • Dimitri Kouvdis
    Dimitri Kouvdis over 11 years
    @feeela Look at the answer below, see what happens. Its a common thing. I did this simply to make OP aware while troubleshooting.
  • Behram Mistree
    Behram Mistree about 6 years
    Checking in, in case it's useful for anyone else. On TextEdit version 1.13 (333), this option is Format > Make plain text.
  • msashish
    msashish over 4 years
    Just to add, I also changed text edit->preference->open and save->display html files as html code instead of formatted text. Without this i was not able to see the html code written.