We will use an external Cascading Style Sheet (.css) to affect the style of a small web site. In the process we will learn how to link a web page to such a sheet, how to read such a document and how to modify it.
lab06_start
into your Desktop.protocols.html
We want the page http.html
to look like
the smtp.html
page.
lab06_start/documents/smtp.html
page in your browser,
and see how it looks.
link tag
, and examine it.http.html
document to the same external style sheet.
http.html
in your browser. Does it look different now?
http.html
to make it look
like the model (smtp.html)?
The link tag
(inserted into the head of an html document), points to a
css document
which is responsible for the appearance of the web page.
In our case, the css styling document is named protocols_style.css
and is
located in the same folder as the html documents. Of course, this one styling
document, can be used (pointed to, or linked to) to control the style
of many different web pages.
This is very important, as you can understand, and demonstrates a basic principle in
Computer Science, called Code Modularity
.
protocols_style.css
file in your text editor.
Examine the css code there.
The first four sets of rules are responsible for setting the appearance of the body, all the headers of level 1 and 2 and all the images.
color
and background-color
to the level 2 headers.
size
of the level 1 headers.
float
to the right of its surrounding text.If you want to see what else you can do to affect the appearance of those elements (and many more), check the w3schools documentation on css.
img.maroonBorder { padding: 10px; margin-right: 20px; border-style:solid; border-color: #993300; border-width:6px; }defines a
class
of images, named maroonBorder
, with certain characteristics: border color,
width, space around it, etc.
This technique of defining classes of elements is useful when we want to apply certain styling to some -but not all- the elements in a group. For example, we may want to style one or two images in a document, and not all of them. To make this work, you need to:
http.html
page.You will need to add some code in the
protocols_style.css
as well as in the
http.html
itself.In this part, we will try to arrange for the 2-column layout you see
in the smtp.html
page. Can you reverse-engineer the workings of this part?
Hint 1: the tag div
defines a division or part in an html document.
Hint 2: What does the float
rule do? You have seen this before!
documents
level? What other changes would you have to make so that everything is working as before?
If you want to check your work, here are some of my relvant files:
For the html files above, check the sourse code.