X hits on this document

PDF document

HTML Beginner's Guide - page 8 / 16

38 views

0 shares

0 downloads

0 comments

8 / 16

Links

So far you've been making a stand-alone web page, which is all very well and nice, but what makes the internet so special is that it all links together.

The 'H' and 'T' in 'HTML' stand for 'hypertext', which basically means a system of linked text.

An anchor tag (a) is used to define a link, but you also need to add something to the anchor tag - the destination of the link.

Add this to your document:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html> <head> <title>My first web page</title> </head> <body> <h1>My first web page</h1> <h2>What this is</h2> <p>A simple page put together using HTML</p> <h2>Why this is</h2> <p>To learn HTML</p> <h2>Where to find the tutorial</h2> <p><a href="http://www.htmldog.com">HTML Dog</a></p> </body> </html>

The destination of the link is defined in the href attribute of the tag. The link can be absolute, such as 'http://www.htmldog.com', or it can be relative to the current page.

So if, for example, you had another file called 'flyingmoss.html' then the line of code would simply be <a href="flyingmoss.html">The miracle of moss in flight</a> or something like this.

A link does not have to link to another HTML file, it can link to any file anywhere on the web.

A link can also send a user to another part of the same page they are on. You can add an id attribute to just about any tag, for example <h2 id="moss">Moss</h2>, and then link to it by using something like this: <a href="#moss">Go to moss</a>. Selecting this link will scroll the page straight to the element with that id.

Document info
Document views38
Page views38
Page last viewedMon Dec 05 14:06:02 UTC 2016
Pages16
Paragraphs214
Words4418

Comments