Links | text Links | pointers
Hypertext link Pointers are one of the most attractive features of HTML. The use of hypertext link pointers makes sequential files accessible to a certain degree of random access, which is more in line with the human way of thinking. People's thinking is jumping, cross, and each link pointer represents the author or reader's thinking jump. The well organized link pointer not only allows the reader to skip chapters that are not of interest to him (such as some boring data), but also helps to better understand the author's intentions.
A hypertext link pointer consists of two parts. One is the target being pointed to, which can be another part of the same file, a file on the other end of the world, animation or music, and a link pointer to a target.
The §3.1 Uniform Resource Locator URL Uniform Resource Locator (Uuiform Resource Locator) is an extension of the file name. In a stand-alone system, locating a file requires a path and file
Name, for Internet networks around the world, it is clear that you need to know which host of the network the files are on. Unlike stand-alone systems, where all files are managed by a unified operating system, there is no way to give access to the file, and on the Internet, the operating systems of each host are different, so you must specify a way to access the file. A URL contains all of the above information. Its composition is:
protocol://machine.name[:p ort]/directory/filename where protocol is the protocol used to access the resource, the method of accessing the resource, which can be:
HTTP Hypertext Transfer Protocol, the resource is an HTML file
File Transfer Protocol, accessing the resource with FTP
FTP file Transfer Protocol, accessing the resource with FTP
Gopher Gopher Protocol, the resource is a gopher file
News indicates that the resource is online journalism
Madcine.name is the IP address that hosts the resource, usually in characters, such as sun.ihep.ac.cn port number, which is the port number the server uses for the host. In general, the slogan does not need to be specified. Specified only if the port number used by the server is not the default port number.
Directory and filename are the path and file names for the resource.
A typical URL for http://www.ihep.ac.cn is that it represents the starting HTML file on the WWW server of CAS high energy. (The path and filename to which the file is stored depend on the configuration of the WWW server.)
As with the absolute path of a stand-alone system, the concept of relative paths is similar, and the Uniform Resource Locator also has an absolute URL and a relative URL. The absolute URL is described above. Relative URLs are relative to the URLs you have recently visited. For example, you are viewing a file with a URL of http://www.inep.ac.cn/index.html , If you want to see another file in the same directory china.html, you can use the china.html directly, then china.html is a relative URL, its absolute URL is http://www.ihep.ac.cn/china.html
§3.2 point to a target <a>
Use the link pointer in the HTML file to point to a target. The basic format is: <a href= "url" > string the Uniform Resource Locator (URL) in the property is the target to which the subsequent "string" acts as a pointer in the HTML file, which is generally shown as blue. When the reader uses the mouse to point this string, the browser will display the resource at the URL on the screen. For example:
<a href= "http://www:ihep.ac.cn" >ihep China homepage</a> users can see the introduction of the Chinese situation by using the mouse point Ihep. In this case, the pointer is Ihep China homepage, and here we'll see an example of using an image as a pointer.
When writing an HTML file, you need to know the URL of the destination. How do you get the URL for the target? For a file within its own host, its URL can be determined according to the actual circumstances of the file. For resources on Interner, when viewed in a browser, its URL is displayed in the browser's location column and copied down to your HTML file.
When writing HTML files, you should use a relative URL for a set of resources that have a definite relationship (for example, in the same directory), which simplifies your HTML files and facilitates maintenance. For example, when you need to move a directory whole to another place or move a host's resources to another host, HTML files written with a relative URL are not updated with the URL (as long as their relative relationship does not change). But if you write HTML with an absolute URL, you have to change the URL in each link pointer verbatim, which is tedious and error-prone. There is no fixed relationship between the resources, such as your HTML file is about the university situation, it points to the target distributed in the global host, then you can only use absolute URL.
At the end of this chapter, the author gives a complete HTML file that uses all the elements described in the first three chapters for the reader to understand.
§3.3 Mark a target
The link pointer mentioned in the previous section allows readers to easily link to the entire Interner Web site. But if you write a very long HTML file, read from beginning to end is a waste of time, can you create a link between the different parts of the same file and make it easy for users to jump between the upper and lower sides? The answer is yes. As mentioned earlier, a hypertext link pointer consists of two parts, one pointer to the target, and the other is the target being directed. For a complete file, we can use its URL to uniquely identify it, but how do we identify the different parts of the same file? The following section describes another use of the link pointer element, identifying the target.
The method that identifies a target is:
<a name= "Name" >text</a>
The Name property marks the place where the tag is placed as "name", which is a unique string of tokens in full text, and the text part is optional. In this way, we make a tag that is called "name" where the tag is placed.
After marking, you can point to it in the following ways, <a href= "Url#name" >text </a>url is the URL name of the HTML file where the markup is placed is the tag name, for the same
file, which can be written as <a href= "#name" >text </a> then you can click the text to jump to the section labeled name.
§3.4 target window
If you want the target to be pointed to appear in a new window, you can use the target property to decorate the linked pointer element.
<a href= "url" target= "window-name" >text </a> displays the resource represented by the URL in a new window named Window-name.
Note: For Netscape2.0 browsers only.
§3.5 image link Pointer image can also be used as a link pointer. The format is: <a href= "url" ></a> you can see that in the example above, the replaces the position of text in the link pointer.
is an image element that shows the image file represented by the URL, see the image chapter.
The following is a simple image link pointer.
<a href= "www.ihep.ac.cn" >china home page </a>
§3.6 (image map)
The image link pointer shown in the previous section can only point to one location, and an image map can divide the image into multiple areas, each of which points to a different location. You can use the image map to make a beautiful HTML file.
Using an image map is a little more complicated. The image map needs to be described not only in the HTML file, but also in a file with a. Map suffix, which describes the image partition and the URL it points to. The format of the partition information is described in the. map file as follows:
Rect URL upper-left corner coordinate, lower right corner coordinate
Poly URL each vertex coordinate
Circle URL diameter ends point coordinates
Default URL
RECT specifies a rectangular area that is described by the upper-left coordinate and the lower-right corner coordinates. Poly Specifies a polygon area where the location of the range is explained by the coordinates of each vertex. Circle specifies a circular area where the position of the region is explained by the intersection of the diameter of the center perpendicular to the circle. default Specifies the URL of the other part of the image map. The coordinates are written as follows: X,y, the coordinates of each point are separated by a space. Here is a complete description of the document,
Defaulthttp://www.ihep.ac.cn
Recthttp://www.ibm.com140,20 280,60
Polyhttp://www.microsoft.com180,80 200,140
Circlehttp://www.yahoo.com80,140 80,100
The image map requires a special handler Imagemap,imagemap placed in the/cgi-bin. The format of referencing an image map in an HTML file is: <a href= "/cgi-bin/imagemap/mymap.map" ></a> can see that this is a link pointer element that contains an image element. The image element indicates the URL of the image used for the image map and is described with the ismap attribute. What needs to be explained is the href attribute in the link pointer, which consists of two parts, the first part is/cgi-bin/imagemap, it indicates which program to use to deal with the image map, it must be written as is, the second part is the graphical map of the description file Mymap.map. /cgi-bin/imagemap/mymap.map never said
Mymap.map is in the/cgi-bin/imagemap directory. In Netscape extensions, image maps can be represented in a simpler way, which is the client image map. The user-side map writes the description file of the image map to the HTML file and does not require another program to process it. This allows the HTML author to write the image map in a way that is consistent with the other elements.
The client image map also has the advantage that when the mouse points to different areas of the image map, the browser can display the URLs that each area points to. However, only the netscape2.0 version supports this extension at this time.
The format of the client image map is: src= "url" specifies an image to use as a map of the image
The Usemap property indicates that this is the client image map "#mymap" is the tag name for the description part of the image file, and the browser looks for the <map> element with the name Mymap and obtains the partition information from the image map. The partition information for the client image map is illustrated with the <map name=mapname> element, the Name property name <map> element. Each area of the image map uses <area shape= "shape" coords= "coordinates" href= "url" > Description, the shape can be: Rect rectangle, with the upper left corner, the lower right corner of the coordinates, each coordinate value separated by commas; Poly Polygon, The coordinates of each vertex are represented by the circle Circle, with the center of the circle and the radius, the first two parameters are the horizontal and vertical axes of the center, and the third parameter is the radius. href= "url" that represents the URL of the resource to which the zone refers, or nohref, indicating that the mouse point in the area is invalid. Client-side image maps can overlap areas, overlapping areas with the first description of the entry, the following is an example:
SOURCE program:
<map name= "Face" >
<! Text botton> This row is a comment
<area shape= "Rect"
href= "Page.html"
coords= "140,20,280,60" >
<! Triangle botton>
<area shape= "Poly"
href= "Image.html"
coords= "100,100,180,80,200,140" >
<! Face>
<area shape= "Circle"
href= "Nes.html"
Coords= "80,100,60>
</map>