13.08.2023

What is a link and how to make a hyperlink in HTML. Hyperlink - what is it, how to make a link and insert into HTML code (href, target blank and other attributes of the a tag) What tags create a hyperlink to other documents


Good day to all, my dear friends and readers. I hope that you decided to take part in my contest and write about your blogging path. Well, I would like to continue our study of the html language and today I would like to tell you about one of the most important components, namely hyperlinks.

Yes, without such hyperlinks, the Internet would not be so convenient. No, I'm lying. It would not be convenient in terms of navigation at all. Can you imagine the internet without them? I personally don't.

And today we will learn how to insert a hyperlink in html. But first I would like to ask you: Do you know what a hyperlink is and how it differs from a regular link? Everything is really simple here: a link is a simple writing of information referring to some document. At the same time, you cannot click on this text (nothing will happen), but you know where to look for information.

Example: You can learn how to select hair in Photoshop at //website/adobe-photoshop/kak-vydelit-volosy/

A hyperlink is the same text, only its essence lies in the fact that you can click on this text and get to the desired page, site or any other object. Moreover, the text itself can be any, while the address is already written inside separately and can be completely different. But be that as it may, all the same, in colloquial speech they are simply called links. Here is an example of a hyperlink:

You can read about how to properly select hair in Photoshop in one of my.

Anyway. Good theory. Now let's move on to practice and see which ones are responsible for all these things.

The pair tag is responsible for the hyperlink, but by itself it does not represent anything. It always goes in conjunction with an attribute. And in this case, we need to constantly prescribe this very href. In the attribute value, we put the very link to the desired resource. And in the content itself, we write the text itself, which should become clickable (work on click). Look at the example and I think you will understand everything.

Yandex search engine

As you understand, in this example, I wrote that when you click on a piece of text "Yandex search engine", a person will be directed to the address written in the value of the href attribute.

I think many of you are aware that there are internal and external links. Internal links are carried out within one directory, that is, the site, and external links lead to some third-party resource. And now I'll show you how to do both.

Internal transitions File in the same folder

But such a transition will work provided that the file you are linking to is located in the same folder as the file in which you put the link. For other options, everything is a little different.

File in another folder
  • Open pushkin.html file in Notepad++
  • Now find the word photo and wrap it in tags.
  • And now attention! In the attribute value, we write the path relative to the file being edited, that is, pushkin.html itself. You should have something like this:
  • Photo

    What have we done now? And we did the following: since the path to the photo lies in a separate img folder, which is located in the same folder as the pushkin.html file, then in the attribute value we have to first write the name of the folder, and then through the slash (/) the full name of the document (in in our case photos).

    Now save and run the pushkin.html file in your browser. You will see that the word “Photo” has become highlighted in blue and has become clickable, which means that by clicking on this link we will be taken to the fofo.jpg file, which is located in the img folder.

    Well, how? All clear? Feel free to ask if you need anything.

    External transitions

    And of course, we can’t help but mention external links, after clicking on which we will get to a completely different site. But there is nothing complicated here. The whole point is that you throw in the href value the full address of the site or web page. I showed an example with Yandex above. But here's another example for you:

    I will study for the master of social projects.

    Here we get to a specific page of a specific site.

    Opening in a new window

    By default, when you click on a link, the document opens in the same window as your page, i.e. your page will crash. And this is not good. In particular, for promoted content projects or blogs, it is recommended that when you click on a link, the document opens in a new window or tab without closing your page.

    The target attribute with the value "_blank" will help us with this. There is nothing complicated here. You just need to paste this inside the opening tag after the value of the href attribute. Let's take that excerpt from the lukomorye.html file, where we made a link to the pushkin.html page, only now we will write this very attribute. It should look like this:

    From the poem Ruslan and Lyudmila (Author - A.S. Pushkin)

    Well, everything is clear here. Now when you click on the content, the desired page will open in a new window. This thing is very necessary, because if you do not register it, then the user will simply leave your page. And so, in any case, he will remain on it, only if he does not specifically close it. Try to do everything yourself, just make everything beautiful with your hands. No need to copy and paste.

    Somehow like this. It seems that he told all the most important things, but if you want to move in this direction and learn HTML and CSS to create professional websites, blogs and even online stores, then be sure to watch an excellent video course on this topic. The lessons are really excellent and are really told for people who are still little familiar with website building or are unfamiliar at all.

    Well, that concludes our lesson for today. I hope that you liked my article and I will be glad if you become my regular reader. So do not forget to subscribe to my blog updates, so as not to miss something interesting. Well, I wish you success in all your endeavors. Bye bye!

    Sincerely, Dmitry Kostin.

    Hello dear readers of the blog site. Today we will talk about how to create hyperlinks in html, learn how to use the tag and its href and target attributes, let's learn how to make an image a link.

    Hyperlinks are the key elements of a web page. They link disparate html pages together into a complete website. Usually links are displayed as an underlined piece of text, when you hover over it, the mouse cursor becomes a pointing finger. In addition, a hyperlink may take the form of a graphic image or its fragment. When a link is clicked, the browser loads the web page specified in the link's attributes. Hyperlinks allow you to link to internal pages of your site, as well as to any other resources on the Internet.

    Create text hyperlinks

    Let's start simple and look at creating regular text links. To create a text hyperlink, it is enough to enclose any piece of text that should become a link in a pair tag . And in the href attribute of this tag, you must specify the address of the target web page on the Internet:

    page 15

    This piece of html code creates a paragraph that contains a link. The link points to the page15.html web page, which is located in the catalog folder stored in the root folder of the www.site.ru site.

    page 15

    If the page does not use CSS styles and does not apply additional attributes, then hyperlinks on the page are displayed by default as follows:

    • regular links are displayed in blue;
    • visited links are highlighted in purple;
    • the active hyperlink (which is currently clicked) is displayed in red, but since the time between clicking on the link and the start of loading a new document is quite short, this state of the link is very short-lived;
    • Link text is underlined.
    Internet addresses

    The complete address contains contains the Internet address of the web server, and the path to the file to be retrieved. For example:

    http://www.site.ru/catalog/page15.html

    Here www.site.ru is the address of the web server, and /catalog/page15.html is the path to the file on this server. In general, full Internet addresses are usually used only if it is necessary to create a hyperlink pointing to some resources located on another website.

    When creating hyperlinks pointing to files that are part of the same site as the current web page, it is best to use abbreviated Internet addresses. The abbreviated address contains only the path to the file on the server, because The address of the web server is already known to the browser.

    Abbreviated Internet addresses are absolute And relative. The absolute address specifies the path to the target file relative to the site's root folder. Such an address begins with the character / (slash), which denotes the root folder. For example, the address "/page15.html" points to the file page15.html, which is stored in the root folder of the site. Or the address "/catalog/page.html" points to the page.html file, which is placed in the catalog folder, nested in the root folder of the site.

    Relative address is a file path relative to the file of the current web page. Relative addresses do not contain a leading slash. Let's look at a few examples.

    For example, the address "page.html" points to a file that is in the same folder as the file of the current web page. And the address "catalog/page.html" will open the page.html file stored in the catalog folder, nested in the folder where the current page is stored. Using two dots at the beginning of the address, you can specify folders of the previous level of nesting. So, for example, the address ".../page.html" points to the page.html stored in the folder in which the folder with the current web page is nested.

    Link to mail

    Using the html language, you can create mail hyperlinks, which, when clicked, launches the mail client program. When specifying an address in the href attribute, email must be preceded by “mailto:”, i.e. something like this: href="mailto: [email protected]". Moreover, after the colon, there should not be spaces before the postal address.

    write a letter

    How to make an image a link

    This is where I finish talking about creating hyperlinks, I will only remind you of the main points:

  • Link tag is used to create links with the obligatory href attribute, the value of which contains the address of the target page: Text;
  • When creating a link to mail in the href attribute, you must put “mailto:” before the mail address: write a letter;
  • If you need to create an image link, then just put the img tag inside the tag : .
  • Hello, dear readers of the blog site! As you know, in order to successfully promote a site and increase its position in search results, it is necessary to carry out high-quality SEO optimization of the site. The concept of ““, which, in turn, is divided into internal and external, is inextricably linked with such concepts as “internal and external site links”. Therefore, it is very important for us to know how many links should be on the site, how to check their number, how to remove unnecessary links from the site and close them from indexing, how to increase the link mass, etc. To answer all these questions and more regarding internal and external links, let's first understand what a link (or hyperlink) is in HTML.

    In this article I will explain what a link is, how to make a hyperlink in HTML on a website, how to open a link in a new window, how to create a link to an e-mail address (e-mail) and how to make a link an image. We will also touch upon such concepts as html tags and hyperlink attributes, link anchor, html anchor (anchor) and hash links. So, let's begin.

    What is a link (hyperlink).

    If a hyperlink leads to a web page or file that does not exist (deleted, moved) or its address is incorrect, then such a link is called broken. There should not be broken links on the site, as they mislead visitors and, by clicking on such a link, a person is unlikely to return to your site. We will talk in more detail about why broken links appear, how to find and fix them, in a separate article. And now let's continue.

    How to make a link (hyperlink) in HTML on a website.

    Linking to another page on your site or another site is very easy. To create a hyperlink, you need to tell the browser what the link is and indicate the address of the document to which it will lead. This is done using the HTML tag. and the required href attribute:

    Here URL is the address of the document to go to. And the text of the hyperlink located between the tags And, is called the link anchor and is visible to the web page visitor. In addition to the fact that the link text (anchor) informs the reader where the transition will be made, it is also very important in search engine optimization (SEO), as it is one of the determining factors influencing the ranking of your site for the keywords contained in this anchor. Typically, this type of ranking is called referential.

    Absolute link

    They are used to point to a document on another site (external link).

    It is allowed to make absolute links within the same site, however, it is more correct to use relative addresses to create an internal link, which look shorter. But, while analyzing various sites, I noticed that the vast majority of webmasters make internal links with absolute addresses. There is a plus here, because if your page is copied, then in this way you will get working back external links.

    As you can see, with absolute references, everything is simple. It’s more difficult with relative ones, because when creating them, you need to understand what value of the href attribute you need to specify, since it depends on the original location of the documents. As I said, no one really bothers with this and makes all links on the site absolute. However, if you are interested in learning more about how to correctly create relative links for a site, I can recommend an article by Dmitry, the author of the ktonanovenkogo.ru blog. I have not yet seen a more detailed and understandable explanation.

    For example, I will show how the link leading to the file relative to the site root will look like (just cut off everything to the left of the third slash in a similar absolute link):

    Relative link

    To main

    Link text (anchor)

    The colors and design of the pop-up text depend only on the settings of the operating system and browser.

    How to open a link in a new window.

    By default, when you click on a link, a new document will be opened in the current window. However, when viewing sites personally, this is not convenient for me. When reading an article and following a link, it is convenient for me that the page opens in a new window and I can continue reading the previous article at any time. Another reason to open a link in a new window is that when you go to someone else's site, there is a high probability that the reader will not come back. Especially if he makes several transitions and simply does not remember where he was a few minutes ago.

    The target tag attribute will help us open the link in a new window. . It defaults to _self , which is usually not written. To open the document in a new window, change the value of the target attribute to _blank :

    1 New window

    New window

    What if when you visit someone else's site, where links open in the current window, you want to open them in a new one? You just need to click on them not with a button, but with the mouse wheel. In this case, a new page will open in a new window.

    How to make a link to an e-mail (e-mail address).

    When you click on this link, your default email program will open, where the “To” field will already be filled in. To automatically fill in the subject of the letter, you need to make a link to the e-mail of the following form:

    Dmitry KtoNaNovenkogo advises another way to set bookmarks in the text of a web page, without using html anchors. To do this, we make a bookmark from any HTML tag available on the page, prescribing a universal id attribute to it. For example, we make a bookmark from the h3 header tag:

    Title text

    It is important to write a Latin letter in the id attribute as the first character of the anchor name, then you can use any other allowed characters.

    Let's, for example, return to the heading “ “, and then continue.

    You can use hash links to go to the right place not only within one page, but also to go to another page of the site. To do this, we set the html anchor in the right place on the right page, and in the hash link itself, before the hash symbol, we write the address of this page. For example:

    Link text to html bookmark anchor

    Types and colors of hyperlinks in HTML.
    • An unvisited link is blue and underlined.
    • Active Link - Turns red in the time between clicking on the link and starting to load the new page. Of course, she hasn't been in this state for long.
    • Visited link - changes its color to purple after clicking on it.

    You can change the color of hyperlinks in an html document using a tag and its following attributes:

    • Link - the color of unvisited links.
    • Alink - active link color.
    • Vlink is the color of visited links.

    All of the above attributes can be combined:

    1

    I hope it is now clear how to create a hyperlink on an HTML page and on an e-mail, how to make a picture a link, what are text anchors, hash links and html anchors, what are html tags and link attributes. I have tried my best to describe in detail what links are in HTML and what they are. Let me remind you that inserting hyperlinks into text is done only in HTML mode.

    Never had to write such long articles, more than 10,000 characters. But this topic of links is not exhausted, to be continued.

    If this article was useful for you, please click on the buttons of social networks below. See you on the pages!

    Instruction

    Hypertext links are designed to link text, images, or other page elements to other hypertext documents. All elements of the site page, including links, are created by the browser, which receives detailed instructions from the page code sent to it by the server. This HTML (HyperText Markup Language) code is made up of "tags" that describe the type, appearance, and location of all elements on a web page. A standard hyperlink is created by the browser when it encounters, for example, the following tag in the page code: Text linkHere - the opening link tag, - the closing one. The opening tag may contain additional information - "attributes". In this simple link, the href attribute contains the address of the page or document that will be requested if the visitor clicks on the link. Sometimes it is not necessary to specify the full address - if the requested document is located on the server in the same folder (or a subfolder), then it is enough to specify only its name or the path to the subfolder. These are called "relative", they should, for example, like this: Text link When you click on this link, the moreText.html document will be loaded from the same folder. And absolute link addresses start with the protocol, for example: Text link Here "http" (HyperText Transfer Protocol - "hypertext transfer protocol") is the usual address of a document on the web. And if you specify the "mailto" protocol, then the hyperlink will launch your mail program, instead of going to: email-linkIn links to files located on the FTP server, respectively, indicate the FTP protocol (File Transfer Protocol - "file transfer protocol"): Link to archive

    Another hyperlink attribute that specifies which window this new document should be loaded into is "target". If you can enter any correct address in the href attribute, then target can have only four values: _self - the page must be loaded into the same window or frame. "Frames" refers to one part of a window divided into several parts; _parent - if the current page itself was loaded from another window (or frame), then it has a "parent" window. And the _parent value requires that the page pointed to by the link be loaded into this parent window; _top - the new page must be loaded into the same window. If this window is divided into frames, then they will be destroyed upon loading, and the new page will be the only frame in this window; _blank - a separate window will be opened to follow the link; For example:
    Link will open in a new window

    It is possible to make a hyperlink to go not to another page, but to some given section of the same document. To indicate such a “destination” in the html code of the document, an anchor link is used: And the link that scrolls the document to this anchor looks like this: Link to the first anchor of the page pageOf course, in the html code of another document, there must be such an anchor link with the name="Anchor1" attribute.

    A hyperlink can be not only text, but also other page elements - for example, pictures. The simplest tag that draws an image looks like this: And for the image to become a hyperlink, it should be enclosed between the opening and closing tags of the link:

    A distinctive feature of hypertext and hypermedia documents are active links to other documents (hyperlinks). The link can be either text or an image. When you hover your mouse over a link, the cursor changes to a hand shape, and you can click the mouse to open the document associated with that link in a browser window.

    The link is established using a pair tag (from English anchor- anchor). The tag has an HREF parameter that specifies the address of the document. A link is all the information between the opening and closing tags.

    Hyperlink color

    The LINK parameter indicates the color of a regular link, VLINK is the color of a visited link, ALINK is the color of the link the mouse cursor is over.

    Links to other pages of the site

    If the linked document is located on the same computer as the current page, you must specify its relative address (relative to the current one). It is strongly not recommended to specify the drive name and the absolute path to the file, because if you transfer the site to another computer or to another directory, such links will not work.

    Relative paths can use the characters .. , which denote an exit from the current directory to the superdirectory. For example, link

    linked to the index.html file in the text directory next to the current one. Note that the slash separating directory names must be slashed to the right to be compatible with paths in UNIX and similar systems.

    Links to sites on the Internet

    If only the protocol and site address are specified in the address, the main page of the site opens, which usually has the name index.htm, index.html or default.htm(this depends on the Web server on that site).

    The tag also has a TARGET parameter that tells the browser where to open the window. It can be followed by the name of the opened window (if there is no such window, a new window with that name is opened) or one of the following values

    • _blank - open in a new window
    • _parent - open in parent window
    • _top - open in full screen

    The last two values ​​are used when working with frames. For example, a link to the site mail.ru, which always opens in a new window, is made like this:

    Links within the page

    2023
    maccase.ru - Android. Brands. Iron. News