| Hyperlinks |
|
1-17 Orientation 2: Review Review the definition of hypertext on the first page. |
1-17 A 1 Discover
Explain the meaning of href="LittleText1.html": |
|
1-17 Definition 1: The href attribute The href attribute stands for hypertext reference. |
|
1-17 Definition 2: Hyperlink A word, a phrase or an image in an HTML document, that opens another HTML document when clicked, is called a hyperlink. |
|
1-17 Example 1: Hyperlink For an HTML file with the code below, and LittleText2.html located in the same directory, the HTML file will display a hyperlink that opens the LittleText2.html:<html> |
|
1-17 Definition 3: Anchor tag pair This tag pair: <a></a> is called an anchor tag pair. |
|
1-17 Explanation 1: Linking from an HTML file to another HTML file in the same folder To link a word or a text in an HTML file to another HTML file located in the same folder, assign the file name of the other HTML file to the anchor tag's href attribute:<a href="FileName.html">This hyperlink links to FileName.html.</a> |
1-17 A 2 Discover
|
|
1-17 Explanation 2: Opening a page in a new tab The anchor tag below contains tow attributes: the href attribute and the target
attribute. The _blank value of the target attribute causes the linked
HTML page to open in a new tab: When you click on this hyperlink with the target attribute set to _blank, then the link will open the HTML file specified by the value assigned to the href attribute in a new tab. |
|
1-17 Example 2: Linking from an HTML file to another HTML file in a different folder This anchor tag:<a href="PracticeFiles/LinkedFiles/LittleText1.html" target = "_blank">This sentence is a link to LittleText1.html.</a> can be used to create this link: When you click on the link, it opens the LittleText1.html file in a new tab, because the target attribute is set to: '_blank'. |
|
1-17 Explanation 3: Linking from an HTML file to another HTML file in a different folder To link from an HTML file to another HTML file located in a different folder, include the path to the file in the anchor tag:<a href="Path/FileName.html" target = "_blank">This sentence is a link to file.html.</a> |
|
1-17 A 3
In the StarfruitJuiceFiles folder, create: LinkToStarfruitJuiceFile.html with a link that opens StarfruitJuiceJuice15.html in the same tab. |
|
1-17 A 4
In the StarfruitJuiceFiles folder, create: LinkToStarfruitFileNewTab.html with a link that opens StarfruitJuice15.html in a new tab. |
|
1-17 Orientation 3: Image files For the following exercises, you are going to need 3 image files. In the PracticeFiles folder, create a folder named images. Download these 3 files, and save them in the images folder: |
|
1-17 Example 3: Linking from an image This anchor tag creates a link from the StarfruitJuice.jpg to the LittleText1.html:<a href="LittleText1.html"><img src="images/StarfruitJuice.jpg"></a> |
|
1-17 Explanation 4: Linking from an image To create a link from an image, place the <img> tag with its src attribute inside the anchor tag pair:<a href=""><images src="Path/ImageFileName"></a>. |
|
1-17 A 5
Linking from an image In the StarfruitJuiceFiles folder, create LinkFromImage.html, with the StarfruitJuice.jpg image serving as a hyperlink to StarfruitJuice15.html. |
1-17 A 6
Linking from an image
|
1-17 B 1 Linking three pages
|
|
1-17 A 7 Rereading the yellow sections
Now that you have gone through the exercises on this page, reread the yellow sections. |
|
1-17 Submit 1: Study motivation |
|
This page was created by Hanspeter Amend
|
|
|
Solution proposals 1-17 A 3 <html> <body> <a href=StarfruitJuice15.html">This links to StarfruitJuice15.html</a> </body> </html> 1-17 A 4 <html> <body> <a href="StarfruitJuice15.html" target="_blank">This links to StarfruitJuice15.html</a> </body> </html> 1-17 A 5 <a href="StarfruitJuice15.html"><img src="images/StarfruitJuice.jpg"></a> 1-17 A 6 LinkFromStarfruit.html: LinkFromMelon.html: |
|