HTML5, CSS3, and JavaScript Fourth Edition

(Ben Green) #1

CHAPTER 6. USING EXTERNAL RESOURCES 60


We have been talking about images, which are generally done up as separate
files and then inserted into webpages.


Where do you put those files? There are three main answers.


Relative:Files that relate to just a particular webpage can easily be stored
in the same folder as the webpage itself. They can be simply identified by
name. For example:


src=mypic.jpg


Docroot: Files that relate to the whole website can best be stored in a
special folder or group of folders. For example:


src=/images/logo.png


The slash components in front of the filename are called the path.


Absolute:Files that are borrowed from elsewhere can be identified by their
full URL. For example:


https://commons.wikimedia.org/wiki/File:Stonehenge.jpg


6.1 Besides Images


Images are a good example of separate files, but there are a few other com-
mon examples of things that are separate.


External Style Sheetsare often identified by a docroot-style name, as
they typically apply to many pages in a website.


Internal Page Linksare mostly relative or docroot. They link to sepa-
rate webpages within the same website. Closely related pages are relative.
General pages are docroot.


External Page Linksare always absolute. They link to separate webpages
in a different website.


Webfontsare normally absolute. They are typically brought in from some-
place like Google as needed.


Scriptscan be imported from absolute locations, but for security purposes
they are often imported from within the same website as the page that uses
them.

Free download pdf