Last week we practiced using some basic html to structure the content of a web page. Today we will add hyper text (links) and images to our web pages.
Here is
the html code
to add the above image, stored in the file "green-tea.jpg"
,
on the web page:
<img src="green-tea.jpg" alt="a cup of green tea">
Note: This will only work when the image file and the html document are saved in the same directory/folder.
src
and alt
are called attributes
.
The img
element can take more attributes, like height
and width
.
The <a>
element is used to create Hyper Text, i.e. to link
web pages together. Consider the following html code that will display a "driving
directions"
label, that, when clicked, will take us to the "directions.html" web
page (relative URL):
<a href="directions.html"> driving directions</a>
Click to see it at work: driving directions
href
attribute specifies the destination of the link. Note: This will only work when the destination file and the document that contains the link are saved in the same directory/folder.
Now, consider the following code, that links to a web page in any server (absolute URL):
<a href="http://cs.wellesley.edu/~cs111/labs/lab1/lab01.html"> cs111 lab</a>
and here it is at work: cs111 lab.
They consist of the following parts:
http://
|
cs.wellesley.edu/ |
~cs111/labs/ |
lab01.html |
protocol | server.domain | path | filename |
As you know, operating systems (like Macs, and Windows), organize the contents of a computer's hard drive into folders, also called directories. Folders and files form a tree structure, because of the ability of directories to contain other directories.
Here's an example for a website about musical instruments. We might have the following organization of files and folders, as we would draw it on the board:
We can use these relationships to form a shorthand way of specifying a URL. This is called a relative URL, because we specify the location of a file relative to a known file. Here are the basic rules:
Relative URLs are only for files on the same server. Therefore, we can leave off the protocol and server name.
Your main task for today will be to create a small web site about the new CS Lounge! The contents of the page(s) are not important for this lab. What's important is that you get practice with links, images, relative URLs and uploading your work to the cs server.
csLounge
csLounge
folder, create a sub-folder named images
and one named documents
.lounge.html
and save it in your csLounge
folder.
Your folder structure should look like this at this point:Your lounge.html
page should contain the following:
When you are ready to upload your stuff to the server, use Fetch to connect to your cs account.
Within your public_html
folder there, create a new folder, named csLounge
folder into the newly created lab2
one.
Make modifications to your web page, re-upload it to the server, view it on a browser over the web, as time permits.