How to set an HTML anchor correctly. How to set an HTML anchor. HTML anchor on a page How to make an anchor on an html page
Until now, we have looked at links that simply led to other documents on the Internet. And in this lesson you will learn how to create anchors. Anchor (anchor) in HTML is a special bookmark that is used to move the user to a specific area of the page when clicking on a link.
How to create an anchor and a link to it?
To create an anchor, you need to indicate in the place to which the link will be followed: name= "name" > , where the anchor name is any word in English. As you can see, it is absolutely not necessary to write anything between the tags for a bookmark, because it is used only as a service label. The most important thing is not to forget that - this is a built-in (inline) tag and can only be placed inside HTML elements that can contain this type. However, there are a lot of such elements.
Two important notes! Please note that the name of the anchor in both places must be specified in the same case, that is, you cannot write the name in the anchor, but #NAME in the link to it. In addition, each HTML page cannot have two anchors with the same names, otherwise the browser will not understand which one to navigate to. But there can be as many links to the same anchor as you like!
Example of creating anchors in HTML
Paragraph.
Paragraph. To the begining
Paragraph. To the begining
Paragraph. To the begining
Paragraph. To the begining
Result in browser
Link to the anchor of another HTML page
Well, you and I have learned how to navigate inside the page. Now let's learn how to create links from one HTML page to the anchors of other pages. This can be very convenient, especially if you are linking to a page that has a lot of information, but the user only needs a certain section. So, to create a link to the anchor of another page, you need to specify the #name of the desired anchor in the href attribute at the end of the address.
Sorry, but I won’t show you the result of the example, since I’m not good at cacti and I don’t have articles about them on the site. :)
In the slang of SEO optimizers (the guys who promote websites on the Internet), “anchors” are often called not what we have studied here, but the contents of the tag , that is, what users see on the page.
Homework.
- Create a title for the article and its three sections.
- Under each heading, write a few paragraphs, but under the title of the article, make them so long that they take up about one and a half pages.
- At the end of each section, create a link to the title of the article.
- Immediately below the title of the article, write links to all its sections.
- Create some file (for example, page2.html) and make links in it to all sections of the previously created page. This point is only in the answers, but I’m sure you can handle it! By the way, you can put page2.html in another folder and practice with relative addresses.
An anchor is a very useful tool that allows you to organize a document and make it easier for the user to read. Like all HTML tools, this tag follows a standard syntax, and working with it does not cause any difficulties.
This principle is used to create active lists, links to points with the desired description in the text, or bookmarks. A page structured with anchors creates a pleasant impression and is easy to read.
How to make an anchor
The anchor is very simple to make. The first thing you need to do is create the required label in the body of the document. It is to this label that the link on the page will cling and take the reader to this point.
The label is created in a standard way for the HTML language. You can use the name tool, or you can set the id of the element and refer to it.
Examples of using name and id
name tool
The label name specified in quotes must be unique and different from other names on the page. Otherwise the algorithm will get confused.
Filling the space between tags in this case is not necessary, but is encouraged. This makes it easier to navigate the code.
Tool id
This method is even simpler. It is enough to assign an id number to a specific element on the page.
In this case, the h1 heading became our anchor.
Example of a link inside a page
It is necessary to refer to point 1. The code is as follows:
Sometimes a situation arises that required to link to a specific point on another page contained on this site. For example, when describing the features of cooking chicken in the oven, you need to go to the website page where the rules for using the oven were described. At the same time, after clicking on the link, you need to go to a specific rule to speed up the perception of the text. In this case, you should create a structure like this:
Here /adress-stranici is the name of the page on the server that describes the operating modes and to which the reader should be sent.
Punkt1 is the mode you need to learn on this page.
13.07.2015
Hi all!
We continue to diligently study the basics of HTML.
In this lesson we will learn how to cast anchors on an HTML page.
Don't be scared! You've come to the right place - here I won't tell or teach nautical tricks. In this lesson I will tell you what an HTML anchor is, how to create an anchor on an HTML page and how to add an anchor to another page.
The lesson will be very useful and important, because you will encounter more than once HTML anchors.
Anchor - this is a bookmark with a unique name, which is located in html document in a certain place and serves to quickly navigate to it using a link.
If you like associative explanation, then I’ll put it this way:
Anchor- this is something like bookmarks or contents in a book.
Anchor links are often used for business sites (one-page links) or at the very beginning of an article to quickly navigate to the desired section (as in Wikipedia).
I think you already understand that what is an anchor link in HTML?. If not, don't worry. Don’t bother yourself with theory, because after practical examples, everything will become clear to you.
○ How to create an anchor onHTML
To create an anchor on a web page, to the tag enter the “name” attribute, where you specify a unique name as the value, for example, “stepkinblog”.
This is what the anchor layout looks like in HTML:
For tag closing tag required.
Attention:
Wrong:
Right:
Instead of the “name” attribute, you can write the “id” attribute
could be so
Attention: the name of the anchor must be written in Latin.
Wrong:
Right:
The content is made in HTML.
Go to article No. 1 - About the blog BlogGood.ruGo to article No. 2 - About the blog site
Go to article No. 3 - About the site wm-money.org.ua
Article No. 1 - About the blog BlogGood.ru
Blog on various topics, SEO optimization, website promotion, website creation, tasty effects for the website and much more...
Article No. 2 - About the blog site
Blog dedicated to: HTML, CSS, PHP, WordPress, Bootstrap
Article No. 3 - About the site wm-money.org.ua
Exchange, withdrawal and deposit of WebMoney
○ How to dohtml anchor to another page
Let's say you have two web pages. On the first page you want to make a link that will send the user to a specific section of another page, for example, to the life date of the writer Taras Shevchenko.
So this is how it is done. On the first page you link to the anchor. On the second page you need to create an anchor in the right place.
Now let's try to implement all this with an example.
Create a page called, for example, "index-1.html".
Insert a link to the anchor into the text:
text.. T. G. Shevchenko ...text
Completely finished HTML code: