IT581: Practicum in Web Development, Summer 2015 (Hybrid)

Hyperlinks


Anchors


Example


Absolute URLS


Relative URLS


Folders (Directories) and URLs



If the new document is in in a subfolder (technically called a directory), the folder name must be used in the path.

        <a href="services/consult.html">
          Consulting services we offer
        </a>



If the original document is in a subfolder, the URL uses a special symbol consisting of two dots ( .. ) to indicate going up a level.

        <a href="../index.html">
          Back to HOME PAGE
        </a>



If both the original and the new document are in subfolders, the URL uses the two dots ( .. ) to go up a level and then names the new subfolder.

<a href="../portfolio/cust_sites.html">Examples of our work.</a>


Full vs relative URLs


Portability


Another Example

URLs for links from within in the index.html page

  • from index.html to about.html
    <a href="about.html">About Us</a>
  • from index.html to tapenade.html
    <a href="recipes/tapenade.html">Tapenade recipe</a>
  • from index.html to linguine.html
    <a href="__________________________">Linguinirecipe</a>

More URLs

  • about.html back to index.html
  • <a href="index.html">Home</a>
  • tapenade.html to index.html
    <a href="../index.html">Home</a>
  • couscous.html to tapenade.html
    <a href="__________________________">Tapenade Recipe</a>
  • couscous.html to index.html
    <a href="__________________________">Home</a>




Targets within a page


The ID attribute


The fragment part of a URL

URL diagram


Example, part 1

In this example, the targets are in the same document as the links.

Link to complete example 1 page illustrating targets in the same page.


Example continued

In this example, the targets are in a different document from the links.

Link to complete example 2 page illustrating targets in a different page.


Anchors and Styles


Example

For example, a page might use the following style rule:

  <style type="text/css">
      a {color: lime}
  </style">

Link to complete example 6 page illustrating styling links.


Pseudo-elements and pseudo-classes

Pseudo-classes

Pseudo-classes are written after the element using a colon between the element symbol and the pseudo-class name. The following table lists most of them.

pseudo-classdescription
:linkdesignates an unvisited link
:visiteddesignates a visited link
:hoverapplies while the user selects an element, but does not activate it;
for example, when the mouse pointer hovers over a link.
:activeapplies while an element is being activated;
for example, between the time the user presses the mouse button and releases it.
:focusapplies while an element has the focus (accepts keyboard events or other forms of input)
:first-childmatches an element that is the first child element of some other element.

Example of pseudo-classes

    <style type="text/css">
      a:link { color: red }
      a:visited { color: green }
      a:hover { color: yellow }
      a:active { color: blue }
     </style>

Another Example

For example, a page might use the following style rules:

  <style type="text/css">
    a {color: lime}
    a:link {color: #ff6600}
    a:visited {color: #0066ff}
    a:hover {color: red}
  </style">

Link to complete example page illustrating pseudo-classes.


Guidelines

Comments to: dong@hood.edu
Last Modified: 13 July 2015. 12:16