4

It just appears like this in Google Chrome:

<html>
<head>
<title>Hello World!</title>
</head>
<body>
<h1 align="center">Hello World!<br/>Welcome to My Web Server.</h1>
</body>
</html>

Why isn't it transforming as expected?

Edit: Yes the file does have an .html filename. I'm not sure it should need a header yet according to a tutorial I'm using which says that it should render correctly without one? All new to this so I'm unsure.

Edit: When I open it with textedit, I get this:

<!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="Generator" content="Cocoa HTML Writer">
  <meta name="CocoaVersion" content="1038.35">
  <style type="text/css">
    p.p1 {margin: 0.0px 0.0px 0.0px 0.0px; font: 12.0px Helvetica}
  </style>
</head>
<body>
<p class="p1">&lt;html&gt;</p>
<p class="p1">&lt;head&gt;</p>
<p class="p1">&lt;title&gt;Hello World!&lt;/title&gt;</p>
<p class="p1">&lt;/head&gt;</p>
<p class="p1">&lt;body&gt;</p>
<p class="p1">&lt;h1 align="center"&gt;Hello World!&lt;br/&gt;Welcome to My Web Server.&lt;/h1&gt;</p>
<p class="p1">&lt;/body&gt;</p>
<p class="p1">&lt;/html&gt;</p>
</body>
</html>

I don't remember saving it like this at all.

3
  • And what transforming is expected? Jul 20, 2011 at 7:57
  • 1
    You have probably broken html Jul 20, 2011 at 7:59
  • Can you be more specific, what web server are you using and what kind of configuration?
    – OsQu
    Jul 20, 2011 at 7:59

3 Answers 3

11

How did you create the web page? It is possible that the editor that you used converted the html so that it shows "<" instead of rendering them

Open the file in notepad, check that the contents are:

<html>
<head>
<title>Hello World!</title>
</head>
<body>
<h1 align="center">Hello World!<br/>Welcome to My Web Server.</h1>
</body>
</html>

and not

&lt;html&gt;
......
&lt;/html&gt;

make sure you save your file with a .html extension

2
  • Okay, changing it back to the original Html worked. How do I prevent text edit from converting it in future? Thanks for the help btw!
    – Chucky
    Jul 20, 2011 at 8:11
  • 1
    Switch your HTML to editor to "edit HTML" ... or if you use the WYSIWIG mode then you don't need to type in the tags at all, just use it like Word
    – Ian G
    Jul 20, 2011 at 8:14
5

It should be rendered by the browser, not the webserver. Check the HTTP headers "Content-Type". It should read something like "Content-Type: text/html; charset=utf-8".

Given your using Chrome, load up developer tools using the following steps;

  1. Right click the page -> Choose "Inspect Element"
  2. Go to the network tab
  3. Load the page your trying to inspect
  4. Pick the URL of the page for which you want to inspect headers etc
3

From the file content you posted contains the explanation:

<meta name="Generator" content="Cocoa HTML Writer">

Basically, your text editor thought you wanted to convert the "text" you had entered to a webpage. So it saved it as a webpage that displays exactly what you have entered.

How did you save the file? If you used anything that says "convert" or "export" to HTML, that's the culprit. Just use the regular "save" option. And if that doesn't work: get a better editor, one that doesn't try to be smarter than you.

Not the answer you're looking for? Browse other questions tagged or ask your own question.