Easy-to-follow video tutorials help you learn software, creative, and business skills.Become a member
While linking to other pages is usually the norm, there are times when you need to link to places within the same page. Usability is an important consideration when designing Web sites. Although people will usually tolerate scrolling a little bit for your information, if they have to scroll a lot, you are usually going to end up with some unhappy visitors. Named Anchors allow us to link to places within the same page, allowing users to just jump further down the page, for example. Named Anchors are aptly named because instead of the normal href attribute the links used to resolve the new location, Named Anchors are merely A or anchor tags that have a name and an ID attribute.
Other links can reference this name to navigate to the location other than Named Anchor on the page. Since Named Anchors typically do not contain any text and since they have no href attribute, they are totally invisible to the user. They are normally only used as points for the user to navigate to. So here we have our frequently asked questions, or faq.htm file open. And if we scroll down a little bit, it becomes apparent why Named Anchors are going to be such a nice addition to this page.
So, we have Frequently Asked Questions for each of the tour packages. And we have about five or six questions for each tour package. So, by the time you get to the last tour, you have done a lot of scrolling down towards the bottom of the page. So we are going to try to make life a little bit easier by allowing people to jump a little bit further down. Now if you're paying attention to the page, you've also noticed that we already have links down here to allow a person to return to the top of the page. That is a really good point of usability. If you are going to allow somebody to jump further down the page to your content, you should also give them easy access back up to where they were before.
Just because they don't have to scroll down doesn't mean that they are going to want to scroll back up. Okay. So, creating Named Anchors and using them is pretty much a two-step process. The first step is to create the anchors themselves, and then the second step is then to then create a link to those anchors. So, that's what we are going to do first. We are going to go ahead and create the Named Anchors themselves. All right. So, I want to scroll towards the top of the page, but what I want to do is place my cursor right here in front of the large headline FAQ.
This is where I want people to be able to jump back to if they have been reading my Frequently Asked Questions. Why? Because just below this is the navigation to be able jump down the page. That way they can read a little bit, jump right back up to the navigation and jump back down again. So, it's kind of a nice little system, so inserting a Named Anchor on the page is really, really simple, and the easiest way to do that is through the Insert panel. So, if we look at the Insert panel and we find our common objects, you'll find this very, very nice little anchor symbol that is our Named Anchor.
And you just want to click on that to insert a Named Anchor on the page. Now when we name our anchors we have to use standard naming conventions, so don't use any spaces, try to avoid punctuation and that sort of thing. As a matter of fact, I try to keep them to one word. If I do have to use two words, I usually use CamelCase naming, but underscores are also okay. I am just going to name this one top, because that's exactly what this link is. It's the top link on the page. Keeping them short makes them easy to remember and a lot easier to link too as well.
I am going to go ahead and click OK and in comes my Named Anchor. Now Dreamweaver shows us something pretty curious on the page now. And if I deselect it, I can see it a little bit more clearly. I see a little shield with that anchor symbol on it. And if I hover over that, and click on it, I can see in the Properties Inspector that's my Named Anchor, and its name is top. I'm free to change that name anytime that I want. So once you place it on the page, if you've forgot to name it something, or if you have meant to change the name, you can simply click on that and change it. Now what is this? Well, that little yellow shield is something that we call invisible elements.
And they can actually cause your layout look like it's shifting around, because Dreamweaver has to make a little bit of space for them. The fact of the matter is though, no one will ever see them. You're only seeing them if you are in Dreamweaver because otherwise they are in the code, but they are invisible, so in Design view we wouldn't be seeing them. As a matter of fact, if I go to Split view, we can see right here is our new Named Anchor. a name="top" ID="top" and then the anchor tag closes out, so there is nothing inside of that, there's no text, and it just has a name and an ID.
Also, if you don't like these shields, if they kind of bug you and they get in your way, there is a couple of ways to get rid of them. Number one, you can go right up here to your Document toolbar, go to Visual Aids, and you can turn off Invisible Elements right there. So that's a nice little toggle. Also, if you go to Edit and choose Preferences, on the Mac you would go to Dreamweaver in Preferences, you'll also find an Invisible Elements category. Here you get to choose exactly which items show up as an invisible element. So, if you didn't want Name Anchors to show up at all, but you still wanted some of your other invisible elements to show up, you could simply deselect the check box here.
I am going to hit Cancel because I don't want to make any changes. I kind of like having them out there. And as you are going to see in just a moment, they sort of extend our functionality a bit. Okay. So, we have a little bit of work to do now. What we are going to need to do now is place Named Anchors at the top of each of those individual sections. So, I am going to place my cursor right in front of Backpack Cal, insert another Named Anchor, and I am going to name this one backpack. Again, we're just going to try to keep them short and just try to keep them single names. If I scroll down, I can see that the next section is California Calm.
Now this time I am actually going to place my cursor on the line just above the headline California Calm. Later on we would begin to test them, and I'll talk about why I'm placing the Named Anchor here. I am going to add another Named Anchor on the Page, and this one is going to be calm. Now just keep scrolling down. Place another anchor on the page here. This anchor is going to be hotsprings. I am going to keep scrolling down. Above Cycle California, I am going to place the anchor cycle, so you can see you can pretty much get into a rhythm with this.
From Desert to Sea, I am going to insert another Named Anchor. I am going to call this one desert. Now once again, it looks like everything is shifting down. Don't panic. That's not a big deal. The Named Anchor just needs a little bit of room visually, but since that's an invisible element, when you preview that in your browser you won't see it. So there we've just created the Named Anchor kids. We will follow that up with nature in the next section, snowboard just underneath that. And then, finally, for Taste of California we'll just do taste.
So, it's pretty easy to put in your Named Anchors. It's a very fast process, but one of the things you want to do is make sure that you have a naming convention already set up and that you are aware of what that naming convention is. It's just going to make creating the links themselves a little bit easier. Okay. So now that we've done that, we need to go ahead and create our links. So, if I scroll back up, I can see that we have this navigation section up here Backpack Cal, California Calm, so the users would click on that to jump down to the actual link themselves. Well, there are a couple different ways to create these links, and they are very easy to do.
I am going to go ahead and highlight the text Backpack Cal and using the Point to File icon down here in the Properties Inspector, I can literally just point right there to the invisible element. As soon as I let go, notice that it resolves it as #backpack. So, that's one of the reasons to keep the invisible elements on the page. We can use the Point to File icon to quickly point to those. Now notice also how this link was resolved. This is really important. Do you notice the # symbol in front of the word backpack? Well, pound identifies that as an ID.
So, to link to any Named Anchor on the page, all you have to do is pass its ID as the href of the link, and it'll jump right to that specific point. Now we can certainly use the Point to File icon again. I can highlight California Calm, for example, use the Point to File icon and if it's off the page, just place your Point to File icon towards the bottom of page. It'll scroll automatically. If for whatever reason that doesn't happen, you can just place it right over the scroll bars at the bottom and then scroll that way too. Then you can point to the invisible element that the represents the link that you want and let go, and it resolves.
Honestly though, if you can remember what you've name them and it makes sense to you, typing them in yourself is the fastest way to do this. So notice I can just highlight Hotsprings right here, type in #hotsprings. You have to remember the pound symbol, and that link resolves. I am going to do the same thing all the way down. I am going to do #cycle, #desert, #kids. Also notice there is no space here, #nature, #snowboard and finally, #taste.
So yes the Point to File icon would have been fast, but I don't think it would have been that fast. Now we're not quite done. We have a one more thing to do before we can test our page. I know we have been working for a while, but let's go and take care of this really fast. We notice that we have some links down that say return to top. I am going to go all the way down to the very bottom of the page, so I can find the very bottom one of those and highlighting that link tag, I am going to type #top. Now after you've already resolved one of these links once, remember you don't have to do it again.
You can simply click in the next one, grab that pulldown menu and find #top. So after that, you don't have to keep typing them in or using the Point to File icon. You can simply click inside the link, grab the pulldown menu for the link itself and find the Named Anchor that you are going towards. That is really quick, really easy. You just want to make sure you are going to do that for every single one of those guys. And if you are more comfortable typing that in, there is nothing wrong with that either.
Okay. So, that should do it for us. I am going to go ahead and Save this file, and now I want to preview this in my browser so that I can test their functionality. So here I am previewing this in the Firefox and if I click on Taste of California, notice that it takes me all the way down to the bottom of the page. Clicking on the return to top brings me right back up to my Navigation. So, I can simply go anywhere that I want and click back and forth, simply by using the links that we've created. Now I want to point something out to you. Do notice how, instead of coming right up to the headline, we are actually landing just a little bit above it? That's because that's where we placed the Named Anchor.
The page is going to navigate exactly to that Named Anchor. So, if we were to place our Named Anchor in front of the K here, it would look like that. Now, there is nothing wrong with that. But think about usability. If you were to jump here, the first thing you would do is scroll up a little bit to make sure you hadn't missed anything. So by going ahead and placing that in there automatically, it sort of tells people, yes you are in the right place. So, I always put my Named Anchors just a little bit above where I want to link on the page. Now obviously, not every page you are working with is going to need Named Anchors.
However, when your data does require a lot of scrolling, or if you want to give people quick access to a specific location, Named Anchors allow you to add a lot of functionality to your page. In our next movie, we are going to take Named Anchors one step further by linking to a Named Anchor on an external page.
Get unlimited access to all courses for just $25/month.Become a member
82 Video lessons · 103219 Viewers
58 Video lessons · 55891 Viewers
61 Video lessons · 89948 Viewers
56 Video lessons · 105075 Viewers
Access exercise files from a button right under the course name.
Search within course videos and transcripts, and jump right to the results.
Remove icons showing you already watched videos if you want to start over.
Make the video wide, narrow, full-screen, or pop the player out of the page into its own window.
Click on text in the transcript to jump to that spot in the video. As the video plays, the relevant spot in the transcript will be highlighted.
Your file was successfully uploaded.