ComputersSoftware

How to properly assign and use the HTML anchor?

Today's topic for discussion will be the HTML anchor. This element allows fast transitions both inside the page and in external documents. Anchors are often used by web developers. Because they help to organize a website that is convenient for readers. The article will provide a detailed description of this element and examples of effective use.

Description

An HTML anchor is a kind of unique bookmark for a web page. It always has its own individual name, which should not be repeated on one page. The main purpose of the anchor is to quickly jump from one part of the document to another, to a specific location. Particularly effective this element brings, when the web page is large. Because of this, users are uncomfortable to read the contents of the site. And the anchor on the HTML page allows for a quick transition.

Assignment

To create such a bookmark on a page, you can use two different methods. The first is to use the Name attribute, and in the second case, you need to use the ID attribute. Next, we will look at each method separately. The transition in both cases occurs using the tag "a", the attribute of which contains a name or an identifier. For example: "a href = http: // site / article / 106223 /% E2% 80% 9D # footer% E2% 80% 9D% C2% BB. The # symbol tells the browser that the link will anchor.

Name

The Name attribute was created specifically to create an anchor on the page. Its value can be any text. This HTML anchor can only be used in conjunction with the "a" tag.

For example, you want to create a bookmark at the very end of your page. You need to put the tag "a name =" footer "" / a "in the desired part of the web document. In another area of the page, you will have to create a link to the anchor, for this, add the entry "a href = http: // site / article / 106223 /% E2% 80% 9D # footer". When you click on this item, the browser automatically takes you to the part of the document where the Footer tab is located.

ID

First of all, it's worth mentioning that ID is an identifier that does not have a direct purpose to create anchors. But it allows you to create bookmarks on the entire document area without creating additional links. That is, you can apply the ID attribute to any HTML element. And then, using the "a" tag, refer to it. Here is an example: the "p" element is in the middle of the document. To go to it from the beginning of the page without using scrollbars, add the ID attribute: "p id =" centr "" "/ p". Then create the link: "a href = http: // site / article / 106223 /% E2% 80% 9D # centr% E2% 80% 9D% C2% BB% D0% A2% D0% B5% D0% BA% D1 % 81% D1% 82% C2% AB% 2Fa% C2% BB. Thus, we get quick access to any part of the document. The value of the ID attribute can be any text.

Effective use

In HTML, the anchor link is very often used to build document navigation. For example, a page has a huge amount of textual information, which in turn is divided into separate paragraphs or chapters. To make it convenient for visitors to use the site, you must assign bookmarks to quickly jump to a separate part of the document. To do this, in each chapter we create an anchor link, or use ID identifiers. And from the top we'll make a navigation bar with the contents of all the links. Interesting is the fact that anchors can be referenced from other web pages. It is enough to add the value of the Name or ID attributes to the end of the link. Do not forget to add the # symbol. The schema in this case should look like this: main link # name (id).

Conclusion

An HTML anchor is very useful and in some cases even an essential element. In the article I presented only one example of its effective use. But in fact, this kind of bookmarks can be used in many situations. The main thing is to understand their main idea.

Similar articles

 

 

 

 

Trending Now

 

 

 

 

Newest

Copyright © 2018 en.unansea.com. Theme powered by WordPress.