1
00:00:00,210 --> 00:00:05,250
In the previous lecture we explored adding links that take you to different web pages.

2
00:00:05,260 --> 00:00:11,560
Now we're going to work with anchor tags anchor tags allow us to link to a specific area of content

3
00:00:11,710 --> 00:00:14,350
on our existing page.

4
00:00:14,350 --> 00:00:21,030
Let's take a look at an example on this page you'll notice we have a table of contents at the top of

5
00:00:21,030 --> 00:00:24,600
the page that lists five articles.

6
00:00:24,600 --> 00:00:29,020
Article 1 2 3 4 and 5.

7
00:00:29,040 --> 00:00:36,650
The idea is to have these items linked to their corresponding article on the same page so if I click

8
00:00:36,650 --> 00:00:44,430
on Article 3 for example you'll notice that the page navigates to the beginning of the third article

9
00:00:44,700 --> 00:00:45,900
in our content area

10
00:00:48,970 --> 00:00:57,390
and the same goes for article for and so on and so forth in order to make this work.

11
00:00:57,770 --> 00:01:05,210
We need to set up an anchor that will instruct a text link on the position of the article that corresponds

12
00:01:05,210 --> 00:01:05,830
to the link

13
00:01:09,040 --> 00:01:15,700
we've included a file called anchors that HMO in the downloads folder corresponding to this lecture.

14
00:01:17,060 --> 00:01:22,070
You'll need to open this file in your text editor in order to follow along with this tutorial

15
00:01:35,760 --> 00:01:42,680
so here we have the source code for the file and in order to make this work we'll have to go ahead and

16
00:01:42,680 --> 00:01:45,810
add a few anchors on all five.

17
00:01:45,830 --> 00:01:46,790
Article headings

18
00:01:49,990 --> 00:01:55,750
to add the anchor locate the article heading and insert the following code.

19
00:02:15,390 --> 00:02:20,670
You'll notice that we're using the a tag with an I.D. attribute

20
00:02:23,230 --> 00:02:31,890
later on in this tutorial tutorial we're going to link to each one of these anchors from our table of

21
00:02:31,890 --> 00:02:32,490
contents

22
00:02:36,840 --> 00:02:42,030
so once you've inserted your first named anchor you'll need to insert the others in front of the other

23
00:02:42,030 --> 00:02:43,680
article headings.

24
00:02:44,460 --> 00:02:46,290
So just copy this block of code

25
00:02:49,600 --> 00:02:52,310
and paste it in front of each article heading.

26
00:02:52,330 --> 00:03:00,860
Remember to make sure you change the number of the article so it corresponds to the correct article

27
00:03:00,860 --> 00:03:01,160
heading

28
00:03:28,670 --> 00:03:33,970
now that we've inserted the named anchors we'll need to link to them from our table of contents.

29
00:03:35,430 --> 00:03:37,470
So let's scroll up to the table of contents

30
00:03:40,230 --> 00:03:43,110
and add the following code around each article heading

31
00:04:06,220 --> 00:04:15,620
you'll notice we're using the tags with the R H R you f attribute one difference is that we have a no

32
00:04:15,620 --> 00:04:19,750
sign in front of the link.

33
00:04:21,550 --> 00:04:28,740
No sign instructs the browser not to divert the user to a new web page when the link is clicked when

34
00:04:28,740 --> 00:04:31,610
the no sign is followed by an anchor name.

35
00:04:32,130 --> 00:04:36,350
The page will notice search for the anchor name on the existing page.

36
00:04:36,570 --> 00:04:44,430
It will then retrieve the content that is defined by the anchor position.

37
00:04:44,490 --> 00:04:51,990
So again that's copy this block of code and create our links for the additional article headings.

38
00:04:52,000 --> 00:04:56,110
Once again remember to change the number so it corresponds to the correct article heading

39
00:05:31,180 --> 00:05:36,060
so once you've added all your links save the file

40
00:05:39,160 --> 00:05:54,020
and preview the page in your web browser to make sure that everything works.

41
00:05:54,020 --> 00:05:57,890
So now we can see that each item in the Table of Contents

42
00:06:00,760 --> 00:06:02,290
does have a link attached to it.

43
00:06:02,440 --> 00:06:10,820
And let's just confirm that it does work so Article 1 Article 2 Article 3.

44
00:06:13,020 --> 00:06:16,060
For and 5.
