Beginner - following sitepoint book Build Your Own Website The Right Way

Page 29-31
I have copied the example text into Notepad but when I open in Firefox it does not display a webpage, just the HTML. What could I be doing wrong?

I am a complete beginner and no advice is too basic for me!

Welcome to SitePoint! You’re in the right place for help.

Did you save it using the .html extension?

mypage.html

I can’t be more specific because I don’t have the book. :frowning:

Thanks for swift reply!

Yes - I saved as basic.html and UFT-8 from the drop down (Plain Text Encoding) as the book says

this is the html I wrote:

<!DOCTYPE html PUBLIC "-//W3C/DTD XHTML 1.0 Strict//EN"
		"http://www.w3.org/TR/xhtml1/DTD?xhtml-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
	<head>
		<title>The Most Basic Web Page in the World</title>
		<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
		<h1>The Most Basic Web Page in the World</h1>
		<p>This is the very simple web page to get you started. Hopefully you will get to see how the markup that drives the page relates to the end result that you can see on screen.</p>
		<p>This is another paragraph, by the way. Just to show how it works.</p>
	</body>
</html>

I was able to save and open it in Opera without difficulty. Hmmmm.

You have three typos in your code:

Should be be written as follows:

<!DOCTYPE html PUBLIC "-//W3C/[B][COLOR=Magenta]/[/COLOR][/B]DTD XHTML 1.0 Strict//EN"
  "http://www.w3.org/TR/xhtml1/DTD[B][COLOR=Magenta]/[/COLOR][/B]xhtml[COLOR=Magenta][B]1[/B][/COLOR]-strict.dtd">
  <html xmlns="http://www.w3.org/1999/xhtml">

I’ll give you a tip for the DOCTYPE, i.e. this code sample in this post copy and paste a correct Doctype (those three lines) rather than typing it all by hand - not even I bother typing out that part in full… I’ve highlighted the 3 corrections too.

However, that won’t effect it from rendering in Fx. thus most probable the reason you are seeing markup and not the actual webpage is probably because your file extension is still *.txt and not *.html You might have accidentally have a file called: basic.html.txt

One easy way to findout, is to look at the Firefox address bar URL and see if the file you load ends in *.html your file should be called basic.html and nothing else.

Double-check it has the *.html extension as sometimes people accidentally leave the extension *.txt in place on the end when is should be be *.html

Thank you
You are right about the address bar as it does show a .txt but I am unable to save the file as anything else in Notepad. It offers a ‘txt’ file or an ‘All files’ option the all files optiion does not seem to do the trick. When searching for it it comes up as basic.html only but the address bar shows it ending in .txt as you predicted. How should I correct that?

You will need to show file extentsions in windows. Open any folder, click tools, folder options, view tab. A few options down, there will be hide known extentions - untick it. Hit apply. Right click your file, choose rename. Delete the .txt, and type .html, hit ok/yes to the prompt. open it FF

i have windows XP and i am unable to do as you suggest. there is no ‘hide known extensions’ check box. Is there another way do you think?

I have now saved the html scipt again in a new notepad document and i have finally achieved the result I was supposed to get.

Thank you all very much indeed for your advice that put me on the right track.

This is truely an amazing resource you all provide. (No doubt I will be back!)

Very much appreciated.
Ady Cole

No worries Ady, hundreds of people make that mistake regarding that book or for that matter a lot of beginners. When you get onto external CSS files around page [79] you do similar but save as *.css instead of the *.html extension.

Or use Notepad++ (free) that lets you save files as a bunch of different types, including HTML and CSS.

Top notch - thanks again!