Home  >  Article  >  Web Front-end  >  Detailed explanation of the difference between rel and target of links_Experience exchange

Detailed explanation of the difference between rel and target of links_Experience exchange

WBOY
WBOYOriginal
2016-05-16 12:05:341872browse

Whether the existence of target="_blank" is necessary or not, I think there are still many people in a blind spot. I checked the relevant literature and found that the situation is not what we thought. In fact, target="_blank" is not substandard, and the solution using rel and JS is not necessary because this is a misunderstanding. As long as we understand the true meaning of rel and target, we will understand that there should not be any controversy here. Below I will share with you the knowledge I gained from reviewing the literature. Let's first understand the meaning of target and rel:

target allows you to specify where to display the selected hyperlink content. That is to say in what window the linked content will be displayed. The attribute value of target has four reserved names, namely: _blank, _self, _parent, _top. _blank means that the browser always loads the document linked by target="_blank" in a newly opened, unnamed window. You may not understand what "unnamed" means here. In fact, target can assign an ID to the newly opened window, for example: target="name" This means that the document loaded through the target="name" link will be displayed in a window called "name". If there is no window with the ID "name", the browser will create a new window named "name" to display the linked document. If the ID of the current window is "name", then the linked document will be displayed in the current window replacing the original content. _self actually means the current document, and the default target of is _self. This attribute value is generally not used. _parent causes the linked document to be displayed in the parent window. This attribute value is only used in the frame structure. If it is a top-level frame, its function is the same as _self. _top is also applied in the frame, but its effect is to clear the frame to display the target document. This is useful for moving from frame to frameless structures.

Now we know that target is an attribute displayed by a target that is closely related to the browser. So what is rel? Why do many people regard it as an alternative attribute of target? Now let’s get to know rel. In fact, there is not only one rel but also a corresponding attribute called rev. The meanings of these two attributes are: the relationship from the source document to the target document; the relationship from the target document to the source document. The source document here can be understood as the current document where the link is located, and the target document is the document that the link will open. We should be clear at this point. In fact, rel and rev are a link relationship before the document, rather than browser-related attributes of how to display the target document.

So what is the relationship between rel and rev? The following will list them one by one and explain their meanings:

next, links to the next document;
prev, links to the previous document;
head, links to the top-level document in the collection;
toc, links to the table of contents of the collection;
parent, links to the document above the source;
Child, links to the document below the source;
index, links to the index of this document;
glossary, a glossary linked to this document;

where next and prev are a group.It shows that the previous relationship between the current document and the target document is a same-level relationship, which can be written like this

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn