The hyperlink a tag represents a link point and is the abbreviation of an anchor in English. Its function is to connect the text or picture at the current location to other pages, text or images, which is well known, but the syntax structure may be a little unknown about it, and to use it to live, it is necessary to understand its syntax structure. The hyperlink <a> tag represents a link point and is abbreviated for an English anchor (anchor). Its purpose is to connect the text or picture at the current location to other pages, text or images, which is well known, but the syntax structure may be a little bit unknown about it, and to use it to live, it is necessary to understand its syntax structure. The basic syntax structure of the <a> tag is:
<a
class=type
id=value
href=reference
name=value
rel=same|next|parent|previous
rev=value
target=window
style=value
title=title
onclick=function
onmouseout=function
onMouseOver=function> </a>
From the syntax structure of the tag, it can be seen that there are many parameters to choose from when setting a hyperlink to achieve different link effects, right? !
The class and id options are used to set the type and assigned ID number to which the link point belongs, and are usually not set. The two most commonly used parameters are href and name. where href is an abbreviation of hypertext reference, which is used to set the link address. The link address must be a url address. If no specific path is given, the default path is the same as the path of the current page. The linked files are also divided into several situations: if it is an HTML file, it will be opened directly in the current browser; if it is an executable file (.exe file), it will be executed or downloaded directly. The file we provide downloaded is made with this feature; if it is a text file such as a word format file, it will be opened in the browser and can be edited and processed.
rel: indicates the relationship between setting links: rel=same means that the file to be linked is the same as this file, rel=next means that the file to be linked is the next page, rel=parent means that the file to be linked is the parent file, and rel=previous means that the file to be linked is the previous page.
rev: is used to set backlinks.
target: It is to set which window to link to when using a frame window, and target=_bank means to open a new window to open a web page.
title: Used to set the title to display when the link point is selected.
onclick: Corresponding to an event. When the link point is clicked, this event will be triggered and the corresponding subroutine will be executed.
onmouseover: Similar to onclick, the corresponding event is triggered when the mouse moves to the link point.
onmouseout: The corresponding event is triggered after the mouse is moved out of the town contact.
Give a few examples: <a href=index.htm>Back to home page</a>
<a href=sound.wav>Play voice file</a>
<a href=javascipt.open()>Execute the corresponding program</a>
<a herf=document.doc>Open the corresponding document for processing</a>
Application Tips
1. Provide download files
Many netizens wrote to ask how to provide the download effect. In fact, it is still a hyperlink, but the files for download must be uploaded to the website. Example: There is a web page skills file package for download. The file name is homepagejq.zip and has been uploaded to the website. The code for this link can be written like this: <a href=homepagejq.zip>Click here to download the web page skills file package</a>.
2. Open the linked web page in a new window
Set the value of target to _blank. Example: Open the web page aboutme.htm in a new window. The code that produces this effect is: <a href=aboutme.htm target=_blank>About me...</a>.
3. Move the mouse to the link and display a line of instructions
Set the title parameter value to obtain this effect. Example: When the mouse is moved to the Wulin.com link, it shows that this is a professional website that introduces web page production skills. The code for this link is as follows: <a href=hscf.htm title=This is a professional website that introduces web page production skills>Wulin.com</a>.
4. Move the mouse to a link and a window pops up
This is the effect obtained by setting the onmouseover parameter. Example: When the mouse moves to a link, a window pops up and displays a mouse hover effect demonstration in the window! . The code for this link is as follows: <a href=other web pages.htm onmouseover=alert('mouseover effect demonstration!')>Link</a>. In a similar way, you can create the effect of popping up the presentation window after the mouse is pressed and popping up the presentation window when the mouse leaves.
5. Link to the specified contents of this page
To link to a part of this page (that is, jump in the file), you must use the parameter name to specify the name of the link point. When you select a piece of text, you can name it with the name parameter for linking. The so-called jump in the same file means that when the reader is reading a very long file, if he is only interested in a certain part of the content, he can use a jump reading method. Its basic format is:
<a href=#link point name>Part 2</a>Part 1 content...
....................................................................
<a name=link point name></a>The actual content of the second part...
....................................................................
In this way, when you click on the hyperlink in the second part, you will automatically transfer to the actual content of the second part. The link point name defined by the name parameter can be taken at will, but the link point name in the linked href parameter must be consistent with it. Don't forget to add # in front of it.
6. The specified content location linked to other pages
The method is similar to the above example, but the file name of the web page must be added before the link point name in the href parameter. Example: There are two web pages page1.htm and page2.htm, each page has two parts of content. Now you want to create a hyperlink in page1.htm. After pressing the link, you will go to the second part of page2.htm. Then we can do this, first write a code like this at the beginning of the second part of page2.htm: <a name=link point name></a>; write a link code like this in page1.htm: <a href=pagw2.htm#link point name> Part 2 of page2</a>.
7. Link to E_mail
After clicking a hyperlink, the email management software on the client will be started to write to you. For example, this line of code: <a href=mailto:[email protected]>Please write me</a>. Once you click on this link, please write to me. The email management software (such as OE) will automatically start the letter writing function and the email address has been added to the address bar of the recipient.
The link can not only use text as a carrier, but also image as a carrier, but also use a certain part of the picture as a carrier, and both of the above effects can be achieved. The methods are the same, but the difference is the carrier, that is, the part between the two pairs of square brackets of the link, so no other example will be given.