HTML and CSS Reference
In-Depth Information
servers are configured to recognize these extensions and handle the files appropriately, processing
different types of files in different ways.
You won't see a file name and extension in every URL you encounter. Most web servers are configured to
automatically locate a specially named file when a directory is requested without a specified file name.
This could be the file called index.html, default.html , or some other name, depending on the way the
server has been set up. Indeed, most of the various parts of the URL may be optional depending on the
particular server configuration.
The URL is the instrument that allows you to build links to other parts of the Web, including other parts of
your own site. You'll use URLs extensively in the HTML and CSS you author, which is why we've spent so
much time exploring them in this first chapter.
Absolute and Relative URLs
A URL can take either of two forms when it points to a resource elsewhere within the same site. An
absolute URL is one that includes the full string, including the protocol and hostname, leaving no question
as to where that resource is found on the Web. You'll use an absolute URL when you link to a site or file
outside your own site's domain, though internal URLs can also be absolute.
A relative URL is one that points to a resource within the same site by referencing only the path and/or file,
omitting the protocol and hostname because those can be safely assumed. It might look something like
If the destination file is kept within the same directory as the file where the URL occurs, the path can be
assumed as well so only the file name and extension are required, like so:
If the destination is in a directory above the source file, you can indicate that relative path with two dots
and a slash ( ../ ), instructing the browser to go up one level to find the resource. Each occurrence of ../
indicates one up-level directive, so a URL pointing two directories upwards might look like this:
Almost all web servers are configured to interpret a leading slash in a relative URL as the site root
directory, so URLs can be “site root relative,” showing the full path from the site root down:
Lastly, if the destination is a directory rather than a specific file, only the path is needed:
Search WWH ::

Custom Search