14. How to create a hyperlink

14. How to create a hyperlink

Hyperlinks (or links) are integral to the way the web works today.

Without them, we wouldn't be able to get around on a website or get from website to website as easily. We'd have to type the URL of every individual web page we wanted to visit.

To create a link in (X)HTML, we use the <a> tag. Links are considered inline elements.

1) We'll add a link to the second paragraph.

The only required attribute of an <a> tag is its href (or hypertext reference). This is where you put the destination of the link; it can either be a file on the same website as your web page or an external URL.

2) We'll use a URL for this one.

3) Then, in between the opening and closing tags, put the link's description. This is what will actually show up on the page.

You can tell a link to open in a new window by using the target attribute. This attribute is deprecated, though, so it can't be used with the Strict DOCTYPE.

Just so you know how, though...

target="_blank" tells the browser to open this link in a new, blank window rather than the current one.

Since it's invalid in Strict, we'll go ahead and remove this attribute.

1) With that done, it's time to save and view our web page.

Here it is without the link.

And, now, here is the link we added.

That's all it takes to create a link in (X)HTML. This tutorial is now complete.

  • 0 کاربر این را مفید یافتند
آیا این پاسخ به شما کمک کرد؟

مقالات مربوطه

2. An introduction to coding web pages with XHTML

2. An introduction to coding web pages with XHTML In this series of tutorials, you will learn...

3. How is XHTML different from HTML?

3. How is XHTML different from HTML? If you watched the previous tutorial, you'll know that...

5. Some resources you should know about before you begin

5. Some resources you should know about before you begin Before we begin, you should know...

4. Choosing a text editor for web development

4. Choosing a text editor for web development In this tutorial, we will discuss the factors...

6. How to quickly open a local web page in your browser

6. How to quickly open a local web page in your browser They may seem obvious to some, but...