Opening Local HTML files - render HTML (not display as text)

Joined
Nov 1, 2009
Messages
4
Reaction score
0
Points
1
Hello everyone,

I am somewhat new with web development on a mac, and am running into some issues trying to test my HTML. I create an HTML file and save it to my local file system. When I open it in a web browser (Firefox and Safari), the page displays the literal HTML text instead of rendering the HTML into a web page like it should.

Is there a setting somewhere on the Mac OS that can overturn this?

Thanks.
 

vansmith

Senior Member
Joined
Oct 19, 2008
Messages
19,924
Reaction score
559
Points
113
Location
Queensland
Your Mac's Specs
Mini (2014, 2018, 2020), MBA (2020), iPad Pro (2018), iPhone 13 Pro Max, Watch (S6)
You should have no problem with opening html files in your web browser. Are you saving them with the html extension (.html or .htm)?
 
OP
G
Joined
Nov 1, 2009
Messages
4
Reaction score
0
Points
1
Thanks for the quick reply

Thank you for the quick response.

Yes, the file had a .html extension. The file info displays as "HTML Document". However, even the preview just displays the literal HTML text. Very frustrating, considering this is such a trivial issue on a PC. Is there a setting in the Apache Web Server on OS X that is running a style transform on local HTML documents to cause the literal text to be displayed?

Another thing to add: when I view the page source, it appears additional HTML has been added so that the page will display the literal HTML. Makes zero sense.

Pardon my frustrations.
 
Joined
Mar 17, 2008
Messages
6,879
Reaction score
191
Points
63
Location
Tucson, AZ
Your Mac's Specs
Way... way too many specs to list.
I don't believe the Preview application does HTML rendering. Now, why the browsers are not rendering html? I've no idea... generally when I've seen that it was a code issue...


edit: are you browsing this through the filesystem or through the webserver?
 
OP
G
Joined
Nov 1, 2009
Messages
4
Reaction score
0
Points
1
I don't believe the Preview application does HTML rendering. Now, why the browsers are not rendering html? I've no idea... generally when I've seen that it was a code issue

I tried it with a very basic HTML file
<html>
<head />
<body>abcd</body>
</html>

And it does the exact same thing (displays tags & text as a literal text file). Make little sense to me as well, and I doubt it is browser specific since Safari and Firefox are both doing it. Almost tempted to chalk up the loss and scrap the mac from a web development standpoint, because this is way too trivial to be spending a lot of time trying to troubleshoot.
 
Joined
Mar 17, 2008
Messages
6,879
Reaction score
191
Points
63
Location
Tucson, AZ
Your Mac's Specs
Way... way too many specs to list.
I just copied that into textedit and saved it as html... it did the same as you described... so I did a cat -v

Code:
mikeMbp:Desktop mike$ cat -v Untitled.html 
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
<html>
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
  <meta http-equiv="Content-Style-Type" content="text/css">
  <title></title>
  <meta name="Author" content="Mike">
  <meta name="Copyright" content="Mike">
  <meta name="Generator" content="Cocoa HTML Writer">
  <meta name="CocoaVersion" content="1038.11">
  <style type="text/css">
    p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Times}
  </style>
</head>
<body>
<p class="p1"><html></p>
<p class="p1"><head /></p>
<p class="p1"><body>abcd</body></p>
<p class="p1"></html></p>
</body>
</html>
mikeMbp:

So i edited out the cr@p in vi.

Code:
mikeMbp:Desktop mike$ cat -v Untitled.html 

<html>
<head>
<title></title>
</head>
<body>
abcd
</body>
</html>

and it works. It's not the mac, it's textedit (which I think sucks anyway) try textwrangler, it's LEAPS and BOUNDS better as an editor.

Alternately you can (in textedit) go to Format > Make Plain Text


I hate rich text biased editors.
 
OP
G
Joined
Nov 1, 2009
Messages
4
Reaction score
0
Points
1
Thanks for the suggestion! You are right -- it probably is the text editor. I have been using komodo edit, but haven't really found it very intuitive. I will take a look at text wrangler.

Thanks again!
 

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top