Before you make a link in HTML, you need toto figure out what it is and what kinds they are. Any link starts with the <a> tag and is closed with a tag </a>. The user displays only what is enclosed between these tags. The browser does not show the link itself. It can be seen by hovering in the status bar.

All links can be divided according to different criteria and types. For example, you can divide links by purpose:

  • within the document;
  • to another web page;
  • on various files;
  • to postal addresses.

In addition, the 2nd and 3rd items can be divided into absolute and relative addresses. About this a little later. Now consider the simplest case.

How to make a link in html

How in HTML to make the link? To do this, you can open a notepad or any other editor and overwrite the code above.

The result is the following.

how to link to a page in html

What does the link consist of?

Remember that any link is required:

  • opening and closing tag;
  • link text;
  • the href attribute, which specifies the address to which the user will be sent.

as in html to make the link to a file
The remaining attributes are optional. I use them at my discretion.

As you can see, the first figure shows the link pages / about.html. This is a relative reference. In the figure above, the link begins with http: //. In this case, the absolute reference is used.

If you do not specify a closing tag, then allThe next one will also be a continuation of this link. Be careful. When writing the code, immediately put the opening and closing tag. So it's safer.

How to make a picture a link in HTML?

Instead of the text in the tags <a> ... </a>, you can specify images. That is, if the user clicks on the image, he will click on your link.

This method is used very often. Especially in the menu on the beautiful sites. Makeup designers always think how to make a link to a page in HTML before creating a web site design. More precisely, in what form all this is done. In the course are all the ways that the web master owns. We'll look a little further.

How in HTML to make a link to a file?

In the href attribute, you can specify references to files. This usually happens when you specify a link to download a file (archive, movie, music, book, text file and so on).

In other words, you can specify anything in the address. If it is not a web page, the browser will try to download it.

Internal References

Surely you visited at least once"Wikipedia". There is the content of the article. And when you click on an item, you move to the corresponding sub-heading. Such links are called references within a document or bookmarks.

How in HTML to make a link inside the page?

how to make a picture link in html

Everything is very simple. We specify the links in the text with the attribute <a>, but do not specify href. You must write the name attribute and specify a unique name within the document. And in the place where you specify references to these notes inside the document, in the href attribute we first write a lattice, and then that unique name.

As soon as the browser sees the character # in the address, it understands that it is necessary to refer to an element within the same document.

Links to e-mail

Sometimes you need to specify a link to e-mail. You can do this.

Links to e-mail

After clicking on this link from the useran application for managing mail will open. This is usually a standard Outlook. But this program is usually not customized. Therefore, usually the email address is simply indicated in the form of text.

Attributes

If you understand how to make a link in HTML, it is recommended that you study the remaining attributes of the <a> tag. This is very important information. Consider the most basic:

  • The title attribute - creates a pop-up hint when hovering over a link. This is very convenient. Thanks to this, you can provide additional information to the user.
  • The target attribute is the place where the new document will be loaded (web page). Here can be the following values:
    • _blank - a new browser window will open;
    • _self - opening in the current window, this is the default value, it is not necessary to specify it;
    • _parent - loading into the parent frame, if there are none, then the attribute takes the value_self;
    • _top - Cancels all frames and loads the page into the full size of the browser. If there are no frames, then there is an analogy with _self.
  • The download attribute. Thanks to it you can forcefully download the file specified in the href attribute. This parameter does not have a value. We just mention <a download href="img/photo.jpg"> Link to the file </a>. If you do not specify the browser simply opens the photo. In this case, it will be downloaded to the computer.

Designing links

If you understand how to make a picture reference inHTML, it is desirable to take care of the fact that it looks normal. By default, around the picture, which is a link, a frame appears. It looks rough and ugly. Since its thickness is 3 pixels.

That it was not, it is necessary to specify border = "0". That is, the boundary will be zero. Here is a link from the picture will look nice and acceptable. Otherwise, you will frighten all visitors to the site.

Conclusion

Links, at first glance, are a very simple tag. But if you go deeper and consider all kinds of links and attributes, it turns out that not everything is so easy and cloudless.

Remember, links are the backbone of the World Wide Web. Without them, it would not exist.

</ p>