Select Lesson
Recap from image lesson
5 min
Anchors
2 min
Hyperlinking text href=
3 min
Nesting
5 min
Anchor attributes &mdash:href
, target
, title
10 min
Lesson 5. Linking pages using the anchor tag
30 min
Lesson 6. More common mistakes
30 min
Anchors Review Quiz
5 min
Anchor Tags
Level OneRecap from image lesson
5 min
Anchors
2 min
Hyperlinking text href=
3 min
Nesting
5 min
Anchor attributes &mdash:href
, target
, title
10 min
Lesson 5. Linking pages using the anchor tag
30 min
Lesson 6. More common mistakes
30 min
Anchors Review Quiz
5 min
60 min
Anchors
Anchors are the tags used to make links (hyperlinks) to other webpages and files.
Activity
Recap from image lesson
Can you answer these questions?
- What are attributes?
- What are 3 image attributes?
- What are the 3 common types of image files?
Concepts
Anchors
- The
<a>
anchor tag is used to tell the browser that we want to link to somewhere else on our site or on the web. - The anchor element uses start and end tags,
<a></a>
. - In between the opening and closing tags is where you put your text (or image) that you want to make clickable.
<a href=http://www.google.co.nz>
= Go to Google
Go to Google
</a>
link
versus anchor
Anchor Tag
A link created with an anchor element is also known a hyperlink or hypertext link. Anchors link your page to other webpages, images etc.
<a href="www.google.com">Link to Google</a>
.
These are visible links for users to click on to navigate the Internet.
Link Tag
This is different from a link element that connects your web page to another internal document, like CSS. This link pulls in code from another file and is invisible to the user.
<link rel="stylesheet" href="fancy.css" type="text/css">
Concepts
Hyperlinking text href=
Here we have "Code Avengers" in between the anchor tags.
Example:
Visit <a>Code Avengers</a>
Result:
Visit Code Avengers
But wait! This link doesn't take me anywhere!
We need a way of setting the URL (e.g. http://codeavengers.com) to the text, so that the browser will request a destination when someone clicks on the link.
How??
Once again, we need to use attributes.
Example:
Visit <a href="http://codeavengers.com">Code Avengers</a>
Result:
Visit Code Avengers
href
is the attributehttp://codeavengers.com
is the value of that attribute- And remember that the human-viewable text goes in between the opening and closing a tags
Concepts
Nesting
(Or make an image clickable)
You can also make an image a link using nesting.
Nesting is when we place a tag within another tag,
Example:
<a href="#">
<img src= "#">
</a>
This relationship is often referred to using the terms "parent" node and "child" nodes.
In the example below all the elements are children elements inside the <p>
element.
<section>
<p>"I challenge you to a dance off<br>
Hands off, no trash talk, no back walk<br>
On the black top, just me, you, that's all<br>
No cat calls, no tag teams, no mascots<br>
Right now, dance off"<br>
<a href="#">A part of a Macklemore Song</a>
<img src= "#">
</section>
Let's try linking our Code Avengers logo to our website.
Take our link from the previous example. Visit <a href="http://codeavengers.com">Code Avengers</a>
By replacing the text with an image tag which links to our logo, we will have created a linked image.
Example:
<a href="http://codeavengers.com">
<img src="/images/logo.png">
</a>
Result:
Concepts
Anchor attributes &mdash:href
, target
, title
1. Href
href
is set to the URL of the webpage or file you want to link to.
2. Target
The target
attribute specifies where to open the linked document/page.
- The default target value is
_self
.- When you click on a link it will navigate away from your current page to that page, in the same tab/window.
However, you may not always want to leave the page you are on.
Here are the options:
target="_self"
: loads the linked content in the same frame as it was clicked (this is default)
target="_blank"
: loads the linked content in a new window or tab
There used to also be;
target="_parent"
: loads the linked content in the parent frame
target="_top"
: loads the linked content in the top level frame set
framename
: loads the linked content in a frame with a custom name
But these three are not used anymore with HTML5 and are not something you need to think about.
Example code:
<a href="http://codeavengers.com" target="_blank">
Code Avengers Home
</a>
Results:
blank: Code Avengers Home- Blank
self:Code Avengers Home- Self
3. Title
This works with both the image tag and anchor tag.
It creates a tooltip message that pops out when you hover over the link.
Example:
<a href="http://codeavengers.com"
target="_blank" title="Go to the hompage">
Code Avengers Home
</a>
HTML/CSS 1 Lesson
Lesson 5. Linking pages using the anchor tag
HTML/CSS 1 Lesson
Lesson 6. More common mistakes
Code Avengers Quiz
Anchors Review Quiz
Resources
Guide
- download
- new file
- upload media
- rename
- delete
Run Ctrl+Enter
Check Ctrl+Shift+Enter
Reset Ctrl+Backspace
Redo Ctrl+Y
Cut Ctrl+X
Copy Ctrl+C
Paste Ctrl+V
Find Ctrl+F
Find & replace Ctrl+F+F