10.07.2017 Views

246996016-HTML5-Step-by-Step

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

70 Chapter 5<br />

When creating a link to a file that’s stored in a subfolder of the current one, you can<br />

point to that subfolder but otherwise leave the path relative. For example, suppose that<br />

index.htm is stored in a folder called c:\main, and foliage.htm is stored in c:\main\articles,<br />

which would be considered a subfolder (or child folder) of it. To refer to foliage.htm from<br />

within index.htm, you would use a tag like this:<br />

Diagnosing Foliage Problems<br />

You can also create a link to a file that is up one level (a parent folder) with a relative reference.<br />

For example, suppose you wanted to refer to index.htm from within foliage.htm<br />

(both in the same locations as before). You would precede the reference with . ./ to indicate<br />

that the file is one level up:<br />

Home<br />

Setting a Target Window<br />

By default, a hyperlink opens the referenced page in the same browser window. That<br />

means the new page replaces the previous page in your browser. Usually this is fine, but<br />

in some cases you might want the hyperlink to open in a new window. For example,<br />

perhaps you want to recommend that visitors check out a page on another site, but you<br />

don’t want them to leave your site.<br />

To direct the hyperlink to open a page in a new window, add the attribute target ″ blank″<br />

to the tag. For example, to open the foliage.htm file in a new window, the tag would<br />

be structured like this:<br />

Diagnosing Foliage Problems<br />

Note The target= attribute is not allowed in XHTML. W3C suggests that you use JavaScript for<br />

such situations.<br />

In this exercise, you will create hyperlinks to other files.<br />

Note Use the practice file provided for this exercise rather than a file created in a previous<br />

exercise.<br />

SET UP Use the index.htm file in the practice file folder for this topic. This file is<br />

located in the Documents\Microsoft Press\<strong>HTML5</strong> SBS\05Links\CreatingHyperlinks<br />

folder. Open the index file in Notepad and in Internet Explorer.<br />

1. Locate the text Diagnosing Foliage Problems and enclose it with an tag that<br />

refers to foliage.htm.<br />

Diagnosing Foliage Problems

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!