Recent Changes - Search:

Web Design

This website demonstrates using wikis as teaching and learning tool.

The course instructor is happy to share the teaching materials here with those who find it readable.

Links and Navigation

A Web Design Lecture by Steven Choy

Overview: The importance of hyperlink design - Hyperlink States - Popular CSS Properties for Styling Hyperlinks - Adding image links - Adding a navigation bar - Why be conventional? - Navigation on large sites - Using a drop-down menu - Breadcrumb trails - Adding a site search - Adding a sitemap


The Importance of Hyperlink Design

  • Links are the most basic interactive component between a user and a web page.
  • Links are the oxgen of the Web! Imagine a webpage without links.
  • A link is an area of a web page that takes you to another web page (or part of the same page) when you click on it.
  • Links can be text or image, or even portion of an image (do you know what is image map?)
  • HTML code for links
    <a href="http://www.stepwise.hk/blog/" title="Stepwise Internet Solutions">Stepwise Blog</a>
    • <a> means anchor.
    • href means hypertext reference.
    • title gives a sensible title to the link.
  • What is anchor text? Anchor text is the text used to display a link.
  • If a hyperlink is represented by an image, the image's alt attribute will be included as the anchor text.
    <a href="http://www.stepwise.hk/blog/" title="Stepwise Internet Solutions">
    <img src="stepwise-logo.png" alt="Stepwise Blog" />
    </a>

Types of Hyperlink

  • External - links going to outside web sites;
  • Internal - links inside the current web site

Hyperlink States

  • There are 5 states that <a> elements can have:
1) a:link – this is the normal state of a hyperlink
2) a:visited – this is when the link has been visited before
3) a:hover – this is when the user hovers their mouse over a link
4) a:active – this is when the user clicks on the link (or presses the Enter key on a focused link)
5) a:focus – this is when the user uses the Tab key to navigate to hyperlinks
  • Web browsers treat these states differently by default.
  • It’s best to have a style for each state so that the user is aware of the status of each hyperlink on a web page.

Popular CSS Properties for Styling Hyperlinks

  • color – the color of the hyperlink
  • text-decoration – Setting this to none removes the default underline
  • background-color – If used in the :hover state, can make the link’s background color change
  • font-weight – Another distinguishing method for hyperlinks is setting them to bold
  • border – If you need more control outside of text-decoration: underline, try giving your hyperlinks a bottom border (experiment with thickness, color and style)

Hyperlink Design Best Practices

Reference: Designing Hyperlinks: Tips and Best Practices

  • In body text, text links are usually underlined and a different color.
  • In navigation menu, links are not usually underlined, but they may be styled (using CSS) to look like buttons.
  • If you have several links, which are related to each other, it makes sense to put them into an unordered list.
    • An example of HTML code
      <div id="nav-menu">
            <ul class="menu">
              <li class="first">
                <a href="index.html" class="current"><span>Home</span></a>
              </li>
              <li>
                <a href="services.html" ><span>Services</span></a>
              </li>
              <li>
                <a href="portfolio.html"><span>Portfolio</span></a>
              </li>
              <li>
                <a href="about.html"><span>About us</span></a>
              </li>
              <li class="last">
                <a href="contact.html" ><span>Contact us</span></a>
              </li>
            </ul>
          </div>
  • Links can change its appearance when you move your mouse pointer over them (mouseover effect).
  • Make your links conventional
    • Why be conventional? (for class discussion)
    • Keep links underlined
    • Visited links should be different
  • Sample CSS code for conventional links
      a { color: #0060ff; text-decoration: underline; }
      a:visited { color: #333; text-decoration: underline; }
      a:hover { color: #df0000; text-decoration: underline; }

Using images to make or decorate hyperlinks

  • Two ways to turn images into links
Method 1) Put a normal image inside a link
      <a href="/pluiplui/">
        <img src="/pictures/logo.gif" alt="Plui Plui Logo" />
      </a>
Method 2) Use a background image to the link itself, using CSS
HTML code:
      <a href="http://xavisys.com" title="Professional WordPress Development" id="xavisys-logo">
      Xavisys Website Development
      </a>
CSS code:
      #xavisys-logo {
          background-image:url(/wp-content/uploads/2009/11/email_logo.gif);
          display:block;
          height:58px;
          text-indent:-9999px;
          width:200px;
      }
Another example: HTML and CSS
HTML Code:
        <div id="main">
            <div id="header">
                <a href="/" title="Home"><h1>Title</h1></a>
            </div>
            <div id="body">Body</div>
            <div id="footer">Footer</div>
        </div>
CSS Code:
        #header
        {
            background: url(logoExample.jpg);
            width: 180px;
            height: 135px;
            position: relative;
        }
        #header a
        {
            position: absolute;
            top: 0;
            left: 0;
            width: 180px;
            height: 135px;
        }
        #header a h1
        {
            display: none;
        }
  • Image Mouseover Effect with CSS
HTML Code:
        <ul id="nav">
          <li id="work"><a href="work.php">Work</a></li>
          <li id="about"><a href="#aboutme">About</a></li>
          <li id="blog"><a href="http://blog.mattdempsey.com">Blog</a></li>
          <li id="contact"><a href="#contactme">Contact</a></li>
          <li id="twitter"><a href="http://www.twitter.com/mattdempseycom">Twitter</a></li>
        </ul>
CSS Code:
        li#work a{
          background: url(../images/nav-work.png) 0 0 no-repeat;
          display: block;
          height: 50px;
          width: 87px;
          text-indent: -100000px;
           }
        li#work a:hover{
          background: url(../images/nav-work.png) 0 -50px no-repeat;
           }

        li#about a{
          background: url(../images/nav-about.png) 0 0 no-repeat;
          display: block;
          height: 50px;
          width: 100px;
          text-indent: -100000px;
           }
        li#about a:hover{
          background: url(../images/nav-about.png) 0 -50px no-repeat;
           }

Navigation Design

Adding a navigation bar

  • Most sites have a navigation bar (or called menu).
  • It is important that the navigation looks consistent across the site. (Why? for class discussion)
  • The 7 link rule - you should try to avoid giving people more than 7 choices at any stage while they're on your site.
  • If you do have more than 7 pages in your site, you'll need to group them into sections or put some of the less important ones in a secondary navigation bar.
  • If there are more than 7 sections in your site, consider grouping some together into sub-sections.

Navigation on large sites

1) Provide a good site search function
2) Provide many levels of navigation (e.g. drop down menu)
3) Provide a "related links" section
4) Provide an advanced search function

Using a drop-down menu

  • Drop-down menus are useful for web sites that have more than a handful pages.
  • You can use JavaScript or CSS to make a drop-down menu
  • You can see a live example here.
  • Sample HTML code
<ul id="menu">
  <li><a href="">Home</a></li>
  <li><a href="">About Us</a>
    <ul>
    <li><a href="">The Team</a></li>
    <li><a href="">History</a></li>
    <li><a href="">Vision</a></li>
    </ul>
  </li>
  <li><a href="">Products</a>
    <ul>
    <li><a href="">Cozy Couch</a></li>
    <li><a href="">Great Table</a></li>
    <li><a href="">Small Chair</a></li>
    <li><a href="">Shiny Shelf</a></li>
    <li><a href="">Invisible Nothing</a></li>
    </ul>
  </li>
  <li><a href="">Contact</a>
    <ul>
    <li><a href="">Online</a></li>
    <li><a href="">Right Here</a></li>
    <li><a href="">Somewhere Else</a></li>
    </ul>
  </li>
</ul>
  • Sample CSS code
ul {
  font-family: Arial, Verdana;
  font-size: 14px;
  margin: 0;
  padding: 0;
  list-style: none;
}
ul li {
  display: block;
  position: relative;
  float: left;
}
li ul { display: none; }
ul li a {
  display: block;
  text-decoration: none;
  color: #ffffff;
  border-top: 1px solid #ffffff;
  padding: 5px 15px 5px 15px;
  background: #2C5463;
  margin-left: 1px;
  white-space: nowrap;
}
ul li a:hover { background: #617F8A; }
li:hover ul {
  display: block;
  position: absolute;
}
li:hover li {
  float: none;
  font-size: 11px;
}
li:hover a { background: #617F8A; }
li:hover li a:hover { background: #95A9B1; }

Breadcrumb trails

  • Breadcrumb navigation (also referred to as a "breadcrumb trail"), locates the current webpage in the context of a navigation path.
  • A breadcrumb trail shows current page in webpages hierarchy
  • It helps people work out
    • where are they?
    • how do they get there?
  • The term comes from the trail of breadcrumbs left by Hansel and Gretel in the popular fairytale (童話故事-糖果屋)

Adding a site search

Adding a sitemap

  • For a large website, it is not practical to put links to every web pages in the navigation menu.
  • A sitemap helps visitors find their way around quickly and easily.
  • It also provides a way for visitors to check if the site has the page they are looking after.
  • Sitemaps also help search engines to index your site.
  • Some examples

Thanks for Reading

If you would rather like to have this lecture note in printed format, please click the print action link in the top right corner.

If you find any problem in this lecture note, please feel free to tell Steven via steven [at] findaway.hk.

Edit - History - Print - Recent Changes - Search
Page last modified on November 10, 2011, at 12:42 PM