Return to Video

HTML links

  • 0:00 - 0:03
    - [Voiceover] You've already learnt
    a bunch of HTML tags.
  • 0:03 - 0:05
    But do you know what HTML actually means?
  • 0:05 - 0:09
    HTML stands for
    HyperText Markup Language.
  • 0:11 - 0:14
    It's a way of using tags
    to markup content.
  • 0:14 - 0:17
    But what does hypertext mean?
  • 0:17 - 0:20
    It's actually a phrase that was invented
    before the Internet even existed,
  • 0:20 - 0:24
    in the 1960s, to mean
    text that is connected to other text
  • 0:24 - 0:26
    that the reader can immediately jump to.
  • 0:26 - 0:30
    Tim Berners-Lee invented HTML,
  • 0:30 - 0:33
    and other ingredients
    of the Internet, like HTTP,
  • 0:33 - 0:35
    to be a way to connect
    text to other text
  • 0:35 - 0:37
    located anywhere in the world.
  • 0:37 - 0:39
    How do we connect
    webpages to other webpages
  • 0:39 - 0:41
    in HyperText Markup Language?
  • 0:41 - 0:43
    With a hyperlink, of course!
  • 0:43 - 0:46
    Which we usually just call a link, now.
  • 0:46 - 0:49
    How do we make a link in HTML?
  • 0:49 - 0:50
    This is where it gets weird.
  • 0:50 - 0:53
    You might think that we'd use
    a `link` tag...
  • 0:53 - 0:58
    But actually, that's used for
    a different sort of link in HTML.
  • 0:58 - 1:03
    Instead, we use the `a` tag,
    where the "a" stands for "anchor".
  • 1:03 - 1:06
    It's anchoring the link in the page
    at a certain location
  • 1:06 - 1:09
    and connecting that anchor
    to a different webpage.
  • 1:09 - 1:12
    To make a link, you know
    we have to write the tag,
  • 1:12 - 1:15
    but we also have to decide
    on the text of the link,
  • 1:15 - 1:17
    and then the address
    that the link goes to.
  • 1:17 - 1:24
    Let's make this link to a page with more
    information about the birth of the web.
  • 1:24 - 1:30
    The text of the link will go inside
    the start and end tags.
  • 1:30 - 1:32
    So I'll stick my cursor
    in here and write,
  • 1:32 - 1:37
    "Read more about the history of HTML".
  • 1:37 - 1:41
    So now we can see that text
    looks like a link.
  • 1:41 - 1:44
    But it's not going anywhere yet.
    We need to add an address.
  • 1:44 - 1:47
    We don't actually want the address
    to show up on the page,
  • 1:47 - 1:50
    but we still need the browser
    to know what it is.
  • 1:50 - 1:53
    So we put it inside an attribute
    on the a tag.
  • 1:53 - 1:57
    That's the href attribute.
  • 1:57 - 2:00
    What does "href" stand for?
  • 2:00 - 2:03
    I will give you a hint:
    You have seen that "h" a lot.
  • 2:03 - 2:06
    It stands for "hyper"!
    Hyper-reference.
  • 2:06 - 2:12
    Now, I'll paste in the address,
    which we also call a URL.
  • 2:12 - 2:16
    Do you notice how this URL
    starts with "http:" ?
  • 2:16 - 2:19
    Guess what that "h"stands for?
    Hyper!
  • 2:19 - 2:21
    HTML is all about the hyper.
  • 2:22 - 2:26
    This URL specifies everything the browser
    needs to know to find the webpage:
  • 2:26 - 2:28
    The protocol used for finding it,
  • 2:28 - 2:30
    the domain it is on,
  • 2:30 - 2:34
    and the path that it's located in
    on the server.
  • 2:34 - 2:39
    Since it specifies everything,
    we call this an "absolute URL".
  • 2:39 - 2:43
    On some webpages, you might see URLs
    that start with just slash and a path.
  • 2:44 - 2:46
    That tells the browser to stay
    on the current domain,
  • 2:46 - 2:49
    and just look for a different path
    on that domain.
  • 2:49 - 2:51
    That's called a "relative URL".
  • 2:51 - 2:54
    We use them all over Khan Academy
    when we link between our content.
  • 2:54 - 2:58
    You should stick to absolute URLs
    in the webpages that you make here,
  • 2:58 - 2:59
    to stay on the safe side.
  • 2:59 - 3:02
    We can also tell the browser
    where to open the page:
  • 3:02 - 3:05
    the current window,
    or a new window.
  • 3:05 - 3:07
    To tell the browser to open
    a link in a new window,
  • 3:07 - 3:11
    we'll add another attribute, target.
  • 3:11 - 3:15
    `target="_blank"`
  • 3:15 - 3:19
    Now, I want you to pause this
    talk-through and try clicking the link.
  • 3:19 - 3:23
    Go ahead, I'll wait.
    Clicky-clicky!
  • 3:23 - 3:24
    What happened?
  • 3:24 - 3:26
    You probably saw a warning
  • 3:26 - 3:28
    about the link being
    from a user-generated webpage.
  • 3:28 - 3:31
    And then if you clicked "OK",
    the link opened up.
  • 3:31 - 3:33
    That's because
    we treat links a little special
  • 3:33 - 3:34
    on the webpages made here.
  • 3:34 - 3:38
    Because we don't want users thinking
    that links are specially endorsed
  • 3:38 - 3:41
    by Khan Academy and then landing
    on a scary, unexpected website.
  • 3:41 - 3:44
    So, every link that you make here
    will have that warning,
  • 3:44 - 3:46
    and every link will pop up
    in a new window.
  • 3:46 - 3:50
    That means that I can actually
    delete this target attribute,
  • 3:50 - 3:53
    since it's getting set
    behind the scenes, too.
  • 3:53 - 3:54
    Or, I could leave it,
  • 3:54 - 3:58
    in case I want to move this HTML
    off of Khan Academy one day
  • 3:58 - 4:01
    and make sure that link still opens
    in a new window.
  • 4:01 - 4:03
    When should you use target?
  • 4:03 - 4:06
    Generally, if a link is going
    to another page on the same domain,
  • 4:06 - 4:08
    it should open in the same window.
  • 4:08 - 4:12
    And if it's going to a page on another
    domain, it should open in a new window.
  • 4:12 - 4:14
    Enough of that blabbing,
  • 4:14 - 4:17
    let me show you
    something else neat about links.
  • 4:17 - 4:19
    We can link more than just text.
  • 4:19 - 4:22
    We can also link images,
    or text and images!
  • 4:22 - 4:27
    Here, we have this image, which is
    which is this picture of Tim Berners-Lee.
  • 4:27 - 4:30
    I'm going to actually cut it...
  • 4:30 - 4:34
    and paste it so that it's inside
    this link here.
  • 4:34 - 4:36
    Oh! Sweet.
  • 4:36 - 4:39
    Now, if I mouse-over this image,
  • 4:39 - 4:41
    I'll see my cursor change to a pointer,
  • 4:41 - 4:44
    and clicking it will go
    to the CERN webpage.
  • 4:44 - 4:47
    In fact, you could link
    your entire webpage --
  • 4:47 - 4:50
    and make it
    a big, blue, underlined blob.
  • 4:50 - 4:57
    But please don't do that!
    Link with love, my friends.
Title:
HTML links
Video Language:
English
Duration:
04:57
Myusernamegoeshere2 edited English subtitles for HTML links
Myusernamegoeshere2 edited English subtitles for HTML links
Josh Kline edited English subtitles for HTML links
Josh Kline edited English subtitles for HTML links
Josh Kline edited English subtitles for HTML links
Josh Kline edited English subtitles for HTML links
Josh Kline edited English subtitles for HTML links

English subtitles

Revisions