Search code examples
htmlhtml-rendering

Why isn't html rendering on my web browser?


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.


Solution

  • 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