Sams Teach Yourself HTML and CSS in 24 Hours (7th Edition)
| The simplest way to organize web pages for an individual web site is to place them all in the same folder together. When files are stored together like this, you can link to them by simply providing the name of the file in the HRef attribute of the <a> tag. If you have many pages, you may want to put them in more than one folder for better organization. In that case, you still shouldn't use the full Internet address to link between them. You can use relative addresses, which include only enough information to find one page from another. A relative address describes the path from one web page to another, instead of a full (or absolute) Internet address. For instance, suppose you are creating a page named zoo.html in a directory folder named webpages on your hard drive. You want to include a link to a page named african.html, which is in a subfolder named elephants within webpages. The link would look like the following: <a href="elephants/african.html">learn about african elephants.</a>
The african.html page might contain a link back to the main zoo.html page: <a href="../zoo.html">return to the zoo.</a>
The double dot (..) is a special code that indicates the folder containing the current folderin other words, the parent folder. (The .. means the same thing in Windows, Macintosh, and UNIX.) In truth, specifying a filename by itself is also a form of relative addressing because you're saying that the file resides in the current folder. If you use relative addressing consistently throughout your web pages, you can move the pages to another folder, disk drive, or web server without changing the links. Or, using the example, everything will work as long as you always put african.html inside a subfolder named elephants.
Relative addresses can span quite complex directory structures if necessary; Hour 22, "Organizing and Managing a Web Site," offers more detailed advice for organizing and linking among large numbers of web pages. Try It Yourself You probably created a page or two of your own while working through Hour 2, "Create a Web Page Right Now." Now is a great time to add a few more pages and link them together:
|
Категории