Links are what make the web the web. With a simple mouse click they let you transfer to another page anywhere on the World Wide Web.
The format of a link looks like this:
<a href="index.html">Go Home</a>
Let's look at each part of this statement:
index.htmlis the value of the
hrefattribute. The browser will load this page when the hyperlink element is clicked.
Attributes, as you may recall from the section with that title in
Lesson 1, are modifiers of html
elements with values assigned to names using
name="value" inside the open tag of an element.
href attribute is required for hyperlink elements.
The attribute in the hyperlink tag,
href, stands for
reference. It is the
href attribute that tells the browser
which location to load when the
hyperlink (or as it's
more commonly called, link) element is clicked. Links are what
World Wide Web
and makes it so popular.
The value of an href attribute is usually a web address, which describes the location of another web page. Web addresses are also called URLs. There are two ways to specify the location of a hypertext link.
absolute location uses the entire URL, like:
Not only is this tedious to type, but using absolute locations makes it difficult to move your site, which brings us to...
Let's say you want to go from
From inside the
lesson6.html file, the link only needs to
be written as:
<a href="lesson7.html">Lesson 7</a>
lesson7.html are in the same
directory, and so have the same relative location.
Hyperlinks can also link to places within a document - either the same document or a different one. For example, clicking this link will take you the format section at the beginning of this lesson.
Two attributes were combined to make that work. First, an
id="format" attribute was added to the
h2 element at the beginning of the lesson. Second, a link
href="#format" was put around the the word
this, making it a local link.
The link to the Attributes section of Lesson 1 above is another example of a link to a location within a document. In this case the link looks like this:
<a href="lesson1.html#attributes">Lesson 1</a>
and is combined with the element
in Lesson 1 to make the link.
My Favorite Web Sitesin the title and a top level heading. Create an ordered list with absolute links to your top 10 favorite websites. Your completed
favorite.htmlmight should look something like this.
gdw.html file that you created in Lesson 2,
making the following changes:
Object Elements, and
Special Charactersfrom third level headings to list items. Put them in an unordered list. Make
Block-level Elementslink to the file
block.htmlthat you created in lesson 3.
Inline Elementsshould link to
Descriptionfrom third level headings to list items. Put them in an unordered list. Link
Orderedto the file
ordered.htmlthat you created in lesson 4. Link the other two labels to their corresponding files as well.
Tablesheading with two items:
Decimal, Binary, Octal, and Hex, and
My Table. Link the first one to the
decbinocthex.htmlfile you made in lesson 5, and the second one to
Relative) and in their place create an unordered list with a single list item. Put the text
My Favorite Websitesin this list item and link it to the
favorite.htmlfile you created in the previous exercise.
Gallery IIas the text in these list items. You will make these links in the next lesson.
gdw.htmlpage should look something like this, and all the links should load the correct pages when clicked.