Rel and target properties of HTML

Source: Internet
Author: User
Tags prev root directory

The question of target= "_blank" has been repeatedly debated on the Internet. Some say to stay, some say to be removed. Advocate to stay on the side is mainly considering the target= "_blank" of the property is not yet a good way to solve, and advocated to go to the side of the Rel and JS solution. Target= "_blank" whether the existence is necessary I think there are still many in a blind spot. I consulted the relevant literature, found that the situation is not what we think, in fact, target= "_blank" is not inconsistent with the standard, and the use of Rel and JS solution is not necessary, because this is a misunderstanding, As long as we understand the true meaning of rel and target, we know that there should be no controversy here. Let me share with you what I have learned by looking at the literature, and we will begin by looking at the meaning of target and rel:

Target, which allows you to specify where to display the content of the hyperlink that you have selected. That means the content of the link will be displayed in what window. Target's property value has four reserved names, respectively: _blank,_self,_parent,_top. Where _blank means that browsers always load target= "_blank" documents in a newly opened, unnamed window. Everyone here may not understand what "unnamed" means. In fact, Target is able to assign an ID to a newly opened window, for example: target= "Name" indicates that the document that is loaded through the target= "name" link will be displayed in a window called "name". If there is no window with ID "name", the browser creates a new window named "Name" to display the linked document. If the ID of the current window is "name," the linked document will be displayed in the current window, replacing the original content. And _self means that the current document,<a> the default goal is _self, this property value is generally not used. _parent is to make the linked document appear in the parent window, which is used only in the frame structure, and if the body is the top-level frame, the function is the same as _self. _top is also applied to the frame, but his effect is to clear the frame to display the target document. This is useful for moving from a frame structure to a frame-free structure.

Now that we know that target is one of the objects that the object displays is closely related to the browser. So what is rel, and why do many people think of him as the surrogate attribute of target? Now let's get to know rel. In fact, there's not only one rel. and a corresponding property called Rev, the two attributes are: from the source document to the target document relationship, from the target document to the source document relationship. The source document here can be understood as the current document in which the link is located, and the target document is the document that the link will open. We should be clear, in fact, rel and Rev is a link before the document, and not browser-related how to display the target document properties.

So what is the relationship between Rel and Rev? Here's a one by one column and explain what it means:

Next, link to the next document;
Prev, linking to the previous document;
Head, linking to the top-level document in the collection;
TOC, linked to the catalog of the collection;
Parent, link to the document above the source;
Child, link to the document below the source;
Index, linking to the indexes of this document;
Glossary, a glossary of links to this document;

Where next and Prev are a group. Indicates that the relationship between the current document and the target document is a sibling relationship, and can be written as such <a href= "movie_002.htm" Rel=next rev=prev>. The head and TOC can form a combination of the directory linked to the final document, or the document linked to the directory. Parent and child are a group that indicates that the current document is linked to a parent document or a subdocument. Index and glossary can be combined with head to form document to index, or index to document, document to glossary or glossary to document.

Perhaps this may not be very clear, for example: I have organized a film document resources, then I need to classify these resources, I divide the film into: Martial arts films, war films, love movies, horror films, documentaries. So when I need to link to the following subclasses in the movie root directory, then the link should be: Rel=child rev=parent, and if the current is a martial arts film channel page, I need to turn the love channel or other channels, then the link should be: Rel=next rev= Prev, when we are linked by a martial arts film link to the "Crouching Tiger, Hidden Dragon" The film's document links should be: Rel=head Rev=toc, when the "Crouching Tiger Hidden Dragon" link to the index when the link relationship has become: Rel=index rev=head.

Because the current CSS can not crawl rel and Rev property values, so there is no way to different relationships to provide a different style of links, so now rel and Rev is only used to make the Web page semantics more perfect.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.