The html hyperlink is written as an example. Hyperlink - what is it, how to make a link and insert into HTML code (href, target blank and other attributes of the a tag)

- 4.3 out of 5 based on 13 votes

View page

This is if the razdel.html file is located in the same folder as the index.html file. If it is, for example, in the pages folder, then the address will look like this:

View page

The entire code for the index.html file will look like this:

My first page View page

You can open the index.html file in your browser and follow the link, as a result it will open new page... As you noticed, in this case the page has opened in the current window. You can make it so that when you click on the link, a new page opens in a new window for this in the opening tag you need to add target = "_blank" attribute It will look like this:

View page

In addition to them, there are also internal links. Internal links are meant to navigate within the same open document... This can be useful if, for example, you decide to create a single large document, and put the content at the top of it. Or you just need to quickly direct the visitor to some part of your page.

Suppose we need to make such a link, by clicking on which, the visitor will be taken to the top of this page. To do this, the first word or phrase on this page must be enclosed in the tag first word... Where in quotation marks it is necessary to indicate a name.

For example, for the page where you are now, you can do this:

All pages

With this, we have defined the anchor, that is, the place where the user will go when he clicks on our link. Now, in the place where you need it, you need to specify the link itself. This is done like this:

Go up

Note that there must be a hash # sign in front of the word verh in quotes here. To see how it works, you can click on the following link:.

You can link not only to files with the html extension, but also to files with other extensions. To do this, the corresponding file name and extension must be entered in the link address. For example, the html link to the archive file will look like this:

Download archive

Download ringtone

You can try to copy any archive or music file to the folder with the files created earlier and give a link to them. In this case, when you click on the link, the browser will prompt you to open or save the file. The target = "_blank" attribute can also be applied to these links.

Now let's look at what types of links are there. There are the following types of links, absolute and relative. Absolute links are links that provide the full address of the document. Such links are used to link to external network resources. An example of such a link:

Webmaster portal

View page

http: // is the most common protocol, it provides access to web pages, the link looks like this:

Webmaster portal

mailto: - protocol for accessing e-mail. It must be used if you want to link to email... The link code is written as follows:

to send a letter

In addition to these protocols, there is also the ftp: // protocol, which is used to transfer files via FTP using an FTP client program. And also the file: // protocol - is used to specify a link to a page located on the local computer.

When creating web pages, you will mainly have to deal with the first two protocols. And the last thing left for us to consider, within the framework of this lesson, is how to link from an image. In fact, everything is very simple. Instead of the text enclosed in tags, you need to insert the image address. We examined how to insert an image in the lesson How to insert images and position them in html.

Save the image that you see on the left in the folder where the files that we created earlier are. Now we will make this image a link. To do this, we need to write the following in our index.html file:

Browsing the internet, you may have seen this effect when, when you click on a link in the form of a small image, another large image is loaded. In order to make such an effect, it is necessary to indicate the address of the large image as the address in the link.

A hyperlink can link pages within one site or point to any page on the Internet. When building links to other people's pages, you should always use the absolute page address (http://www.site.com/page.html). When linking to a page within a site, it is preferable to use a relative URL (page.html, catalog / page.html). When making a graphic hyperlink, remember that graphics are not available to some users, so be sure to include the appropriate text elements.

Example:

Hyperlink within html page

Sometimes it is necessary to make a hyperlink within one page. For example, on this page there are hyperlinks at the beginning of the lesson, allowing you to go to viewing a specific question, and at the very bottom of the page, allowing you to go to the top of the page.

Example:

Mail hyperlink

Example:

HTML code:


[email protected]

Browser display:


Opening html pages in a new window

Using the TARGET attribute, you can load the page in a new browser window. This attribute is used to set the name of the window. The window name is used for business purposes. To open the page in a new window, use the _blank constant.

Example:

Hyperlink text color

The LINK, ALINK, VLINK attributes set the font color of the hyperlinks.

The LINK attribute is used to highlight hyperlinks that have not yet been visited by the user.

How to follow hyperlinks

Some browsers may support the Tab key to follow hyperlinks. In this case, the browser, by default, highlights the hyperlinks in the order they appear in the text of the page. You can change the order of the jump using the TABINDEX attribute of the tag ... To include a hyperlink in the list describing the new navigation order, you must assign the TABINDEX attribute some positive integer in the range from 1 to 32767. To exclude a hyperlink from the list, you must assign any negative number to the attribute. When the user presses the Tab key, the cursor moves to the hyperlink with the lowest positive index value. If several hyperlinks have the same index value, the one that is higher in the text of the page will be selected first.

It should be said that the TABINDEX attribute can be used to select other objects, such as graphics.

Instructions

Hypertext links are designed to link text, images, or other page elements to other hypertext documents. All elements of a 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 consists of "tags" that describe the type, appearance, and location of all elements of a web page. A standard hyperlink is created by the browser when it encounters in the page code, for example, the following tag: Text link Here is the opening link tag, - the closing tag. The opening tag can contain Additional information- "attributes". In this simple link, the href attribute contains the URL of the page or document that will be requested if a visitor clicks on the link. Sometimes it is not necessary to indicate the full address - if the requested document is on the server in the same folder (or a subfolder in it), then it is enough to specify only its name or the path to the subfolder. These are called "relative", they follow, for example, like this: Text link When you click on this link, the document moreText.html from the same folder will be loaded. And absolute link addresses start with a protocol, for example: Text Link Here "http" (HyperText Transfer Protocol) is the usual address of a document on a network. And if you specify the "mailto" protocol, then the hyperlink will launch your mail program, instead of going to: email link In the links to files located on the FTP server, the FTP (File Transfer Protocol) protocol is indicated, respectively: Link to the archive

Another hyperlink attribute that specifies which window to load this new document like "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 current page itself was loaded from another window (or frame), then it has a "parent" window. And the _parent value requires that the page to which the link points be loaded into this parent window; _top - the new page needs to be loaded into the same window. If this window is divided into frames, then upon loading they will be destroyed, 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 create a hyperlink to go not to another page, but to a 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 scrolling the document to this anchor looks like this: Link to the first anchor of the page You can link to anchors not only in this document, but also in others: Anchor in another pageOf course in the html-code of another document such an anchor link with the attribute name = "Anchor1" must exist.

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

Hyperlinks are one of the most important components of html documents. It is thanks to this component, as well as the usual links, that the Internet is so easy to use. We will consider the simplest options for inserting hyperlinks that will help you as novice programmers master this lesson.

How to create a hyperlink in html?

This code will only work on your site, for external links, it won't fit.

< a href=" *** ">***** < /a>

Example:

< a href="https://сайт/">Journal How to do everything< /a>

In the browser it will look like this:

< a href="https://сайт/prigotovlenie-edy/368-kak-sdelat-malosolnye-ogurcy.html">How to make lightly salted cucumbers?< /a>

In the browser, we can see the following:

How to create a hyperlink in html to an external site?

For xrefs, the code should be slightly modified. To link to another site, using the code:

< a href="*** ">***** < /a>

< a href="https://vk.com/kaksdelatvse">We are in contact "How to do everything"< /a>

In today's article, we will look at the easiest way to create a website. I want to say right away that this way is very primitive and today no one creates sites in this way, because for this there are special programs and services.

But, if we need to create a web page, then this method has the right to exist.

In order to create a simple website, we need the Notepad program, which is in every computer.

Click on the "Start" button in the lower left corner and select "All Programs". Find "Notepad" and open it by double-clicking the left mouse button.

Let's print something.

For example: Hurray! I made my site!

Name the file "index.html", select "all files" and save it to your desktop.

After saving, this icon will appear.

If we open this file, then in the browser we will see the web page that we have created.

To edit our entry, right-click on the icon and select "Open with" -> "Notepad" in the context menu.

After the changes are made, do not forget to save the file. By opening the file in a browser, we will see the changes.

To make the site visible to everyone on the Internet, you need to upload it to the hosting.

Thus, you can make the simplest web resource.

To embellish the site with pictures and hyperlinks, as well as add colors, change the font size, add a table, etc., you will have to use HTML, which the browser will understand.

That is why we saved our file with the .html extension.

Tags for creating a website in html in notepad

For a start, it would be a good idea to know what a page on a website is.

It is a text document written in Hypertext Markup Language (html).

To understand what it is, you should familiarize yourself with the general terms.

HTML is a way of document markup that is interpreted in the same way by different browsers in a convenient and user-friendly way. The language is based on certain structural elements- tags. With their help, the html document is drawn up.

Frequently used

Tags are:

  • paired
    , i.e. opening , and closing tags
    , ... The closing tag is a descriptor with a slash sign (/);
  • unpaired.

The main types and purpose of tags

In fact, there are many more tags, but the listed ones are quite enough to create a simple website page through notepad.

Based on the above, the page created by us in html language will take the following form:

Thus, it is quite easy to create a website in html in notepad.

Video: "How to make a website in 15 minutes"

To make the page more attractive, you will need not only, but also learn CSS.