HOW TO CREATE LINKS IN HTML


HOW TO MAKE LINKS TO OTHER PAGES, AND IN OTHER PLACES


So far you've been making an independent web page, which is all very nice and enjoyable, but what makes the internet so special is that it all links to each other.

The "H" and "T" in "HTML" mean "hypertext", which basically means a linked text system.
An anchor tag (a) is used to define a link, but it is also necessary to add something to the anchor tag - the destination of the link.

Add this to your document:

<! DOCTYPE html>
 <Html>
 <Head>
<Title> My first webpage </ title>
</ Head>
 <Body>
 <H1> My first web page </ h1>
 <H2> What is this </ h2>
<P> A simple page formed 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"> Dog HTML </a> </ p>
 </ Body>
 </ Html>
The link destination is defined in the href attribute of the tag. The link can be absolute, such as "http://www.htmldog.com", or it may be relative to the current page.

So if, for example, you had another file named "flyingmoss.html" in the same directory, then the line of code would just be <a href="flyingmoss.html"> The miracle of moss in flight </a> or something I 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 almost any tag, for example <h2 id = "moss"> Moss </ h2> and then link to it using something like this: <a href="#moss"> Go to Moss </a>. If you select this link, the page will move directly to the element with that ID.
Latest