G.6. Internal Linking

In Appendix F, we discussed how to hyperlink one Web page to another. Figure G.6 introduces internal linkinga mechanism that enables the user to jump between locations in the same document. Internal linking is useful for long documents that contain many sections. Clicking an internal link enables users to find a section without scrolling through the entire document.

Figure G.6. Internal hyperlinks to make pages more navigable.

1 6 7 8

"http://www.w3.org/1999/xhtml"> 9 10 Internet and WWW How to Program - List 11 12 13 14 15 16

"features">The Best Features of the Internet

17 18 19

<a href="</span">"#bugs">Go to Favorite Bugs</a>

20 21
  • 22
    • You can meet people from countries 23 around the world.
    • 24 25
      • You have access to new media as it becomes public: 26
        • 27
          • New games
          • 28
            • New applications 29
              • 30
                • For Business
                • 31
                  • For Pleasure
                  • 32
                  33
                • 34 35
                  • Around the clock news
                  • 36
                    • Search Engines
                    • 37
                      • Shopping
                      • 38
                        • Programming 39
                          • 40
                            • XHTML
                            • 41
                              • Java
                              • 42
                                • Dynamic HTML
                                • 43
                                  • Scripts
                                  44
                                  • New languages
                                  • 45
                                  46
                                • 47
                                48
                              • 49 50
                                • Links
                                • 51
                                  • Keeping in touch with old friends
                                  • 52
                                    • It is the technology of the future!
                                    • 53
                                    54 55 56

                                    "bugs">My 3 Favorite Bugs

                                    57 58

                                    59 60 61 <a href="</span"> "#features">Go to Favorite Features</a><a href="</span"> 62 </a>

                                    63 64
                                    1. 65
                                      • Fire Fly
                                      • 66
                                        • Gal Ant
                                        • 67
                                          • Roman Tic
                                          • 68

                                    69 70 71

Line 16 contains a tag with the id attribute (called "features") for an internal hyperlink. To link to a tag with this attribute inside the same Web page, the href attribute of an anchor element includes the id attribute value preceded by a pound sign (as in #features). Lines 6162 contain a hyperlink with the id features as its target. Selecting this hyperlink in a Web browser scrolls the browser window to the h1 tag in line 16.

Look and Feel Observation G 2

Internal hyperlinks are useful in XHTML documents that contain large amounts of information. Internal links to different parts of the page makes it easier for users to navigate the page. They do not have to scroll to find the section they want.

 

Although not demonstrated in this example, a hyperlink can specify an internal link in another document by specifying the document name followed by a pound sign and the id value, as in:

href = "filename.html#id"

 

For example, to link to a tag with the id attribute called booklist in books.html, href is assigned "books.html#booklist".

Категории