02Geek HTML5 and JavaScript, TypeScript, React, Flash, ActionScript online School
Previous VideoNext Video

Creating our first Link with the a Tag

It's about time we learn how to create links. By the end of this video you will know how to work with the a tag and settings its href property.

Video Transcript

00:00So we run through the iframe relatively quickly and again we said that you could embed inside of it
00:06any website. In this case I put 02geek.com but you could put really any site into it.
00:13There's a few other attributes but from now on we're not going to go through every single attribute
00:17or every single element. Our goal is to get you familiar with the elements so you could start working with them
00:22we encourage you to explore if you need a specific element to find out all the different capabilities of it
00:28but that would take too long for a video series to go through every single definition of every single element
00:34So we set the source, we set the height and the width. There's one more thing I want to talk about
00:39which will be the name, which you could give an iframe the name,
00:42before we give an iframe a name I want to move on to the next topic and in this video we're going to get back
00:47to iframe and give it a name. What I want to do is I want to add maybe on top of the iframe a few links
00:56Maybe one link will go to 02geek.com - let's do that.
01:09So back in our code editor, what I'm going to do is right underneath our iframe,
01:12I'm going to make our iframe even smaller again so it's easy for us to see everything.
01:18maybe I'll make the height 200 and I'm going to write here: Go to 02geek.com
01:26now, by putting this copy directly without anything connected to it I'm not really doing anything
01:30It's not going to turn into a link it's going to be static copy.
01:34To be able to turn it into URL what I have to do is bound it with the tag 'a'
01:42which 'a' represents for links, it enables you to put links.
01:45An anchor in HTML is called 'a'. I don't know why they decided to call it an anchor
01:50but it's an anchor point.
01:52and in the anchor point we put a property which is called href
01:56and again it's like hyper link reference but the name doesn't really matter,
02:00what matters is whenever you put it here, it will be a place that we go to,
02:03so if we wanted go to 02geek.com which I know you want to go there,
02:09we're going to type here 02geek.com
02:13and now we created a link and we saved it we can go right back into our browser,
02:25first of all you could see our link and you know, let's practice one of the things
02:29let's drop this a line, so I'm going to use a BR to do that,
02:33I'm going to go right into our editor and I'm going to put a BR right before our 'a' tag
02:39because I really want to break a line right here and I want to start a new thing
02:44Back into our browser, we click refresh, we'll see now that's right underneath
02:51Now if we click on the link, by deafult it's going to load in our site and overwrite where we were,
02:57we're not going to be on our site anymore, that's the default behavior of a link
03:03now, we could change that default behaviour, there's a few different types of relationships that you can have
03:10Let's go through the basic ones which is the default and the default is basically 'self'
03:16it's a self contain. For example if we go up here and I click on the link,
03:20you see this link which is inside of our website?
03:22If I click into this link by default it's going to update the content that it's in,
03:27inside of the iframe. It's not going to update the whole external site.
03:31It's only going to update the internal area inside here

Ready to Level Up Your Skills?

Join thousands of learners on 02GEEK and start your journey to becoming a coding expert today!

Enroll Now for Free!