Create another page
Now let's create another HTML file and put in links between the two.
- Open a new file in your text editor (TextEdit on a Mac or Notepad on a Pc)
- Copy the HTML under Your Code from the Playground and paste it into your new document
- Name the file myotherpage.html and save it in the same folder as your other files. Now we'll add a link from one page to the other
- Return to your text editor and go to (or re-open) the mypage.html file
- Somewhere within the body, add a link to the HTML file you just created. Here's how it should look:
<a href="myotherpage.html">My Other Page</a>
This is the tag for creating links; the href attribute tells the browser which page you want to link to. Whatever is between the starting <a> tag and the ending </a> tag is what we need to click on to actually go to that page.*
- Save the file in the text editor and refresh mypage.html in your browser
Try clicking on the link you created. It should take you to your second page.
Now add a link to myotherpage.html that brings you back to mypage.html using the following code:
<a href="mypage.html">My First Page</a>
With these 2 interconnected web pages, you have your very own website!
*FYI: You can use this same tag if you want to link to somebody else's web page; all you have to do is change the value of the href attribute to the web address you want. So if I wanted to create a link to SmartGirl, for example, I would use this code:
<a href="http://www.smartgirl.org">Go to SmartGirl</a>
|