how do i create clickable links (ie: blog, about us, links, etc)

1 answer

Guffa 316

That seems to be a very basic question, answered over and over all over the web... I'll give you a short overview and see what you can get from it.

The simplest way to get a link is to use... a link. For example:

<a href="blog.html">Blog</a>

This is the most common way to make links between pages. Even if the navigation looks like links, most of the time they are still link elements that are just styled to look in a different way. Even if you want to use a different way to navigate your pages, you should still provide plain links between the pages, so that search engines can navigate the site, and people that can't click on a Javascript enabled element (e.g. blind people) can use the site.

You can make most any element clickable by using the onclick event:

<span onclick="window.location='blog.html';">Blog</span>

In that case you might want to style the text so that it looks similar to a regular link:

<span onclick="window.location='blog.html';" style="color:#9f0;cursor:pointer;">Blog</span>

If you are using a library like jQuery, you can use that to make a whole range of elements clickable, for example:

<script type="text/javascript">
      window.location = this.innerHTML + '.html';
Answered over 8 years ago by Guffa