Workshops
Web 2 Exercises
Exercise 1: Tables
Use this file: tablesample.html. Transfer it to your desktop and open it in your editor.
Add a <caption> that says: Sample Table for Web 2 Workshop
Add the following column headings:
- First Column
- Second Column
- Third Column
- Fourth Column
Define a thead, tbody and tfoot.
Add a new row at the bottom. Have it span all the columns. The text should read: This is a row in the tfoot section that is supposed to span all the columns
Check your work in Print Preview. You should see that the column headings repeat on the second page.
Exercise 2: First Stylesheet
- Make a new folder, called
styles - In HTML-Kit, make a new plain file and call it
main.css - Add this code to main.css
body {
font-family: arial, sans-serif;
}
Transfer the file ex2.html to your desktop and open it in HTML-Kit
In the head section, make a link to the stylesheet
<link rel="stylesheet" href="styles/main.css type="text/css" media="screen" />
Check your work in your browser.
Exercise 3: Font-Family
Change the font for the entire page
body {
font-family: verdana, sans-serif;
}
Now set the font for just the main heading
h1 {
font-family: "Courier New", monospace;
}
And set the font for paragraphs only
p {
font-family: times, "Times Roman", palatino, serif;
}
Try this one
p {
font-family: pristina;
}
What do you get?
Try changing it to
p {
font-family: pristina, cursive;
}
or
p {
font-family: ravie; fantasy;
}
Remove all font-family settings. Set body font to arial or sans-serif.
Exercise 4: Font Styles
- Make the h1 heading in normal font
- Make the h2 heading italicized
- Make the h3 heading in small-caps
- Make all list items boldfaced
Exercise 5: Font Size
- Make h1 be 2.5 times larger than the default
h1 {
font-size: 2.5em;
}
- Make list items be 0.8 times normal size.
li {
font-size: .8em;
}
- Set the body font size for the entire document to be .8em
body {
font-size: .8em;
}
What happened to the list items?
What happens when you don't specific a unit of measurement? Try it on the body font size. Just remove the "em".
Experiment more. When you are done, set the body font to Palatino or Times, the h1 tag to normal weight and 2.5 times normal size, and the h3 to small-caps.
Exercise 6: Units of Measurement
Experiment with different units of measurement. An easy one for comparison is to style paragraphs with one unit and a list with another unit. For example:
p {
font-size: 150%;
}
li {
font-size: 1.5em;
}
Now try
p {
font-size: 15pt;
}
li {
font-size: 15px;
}
What happens when you size the font up and down with your browser? (in IE, choose View, Text Size, … in FF just use Ctrl-+ and Ctrl--)
Exercise 7: Text Alignment
Right-align h2
h2 {
text-align: right;
}
Center h1
Exercise 8: Color
Set a dark background color
body { background-color: #500;}
Oops! We now need to set a light foreground color.
body {
background-color: #500;
color: #fff;
}
Here are some other colors to try
h1 { color #ff4; }
p {
background-color: #f7e4dd;
color: #000;
}
a { color: #8cc; }
Try setting colors for h2 and h3. For h2, make a different background color.
Exercise 9: List Styles
Make unordered lists use circles
Make ordered lists use upper-case letters
Now turn off all bullets and numbering on all lists
Final Exercise
Close all open programs; I want you to start from scratch.
Use the ex2 file from the workshop website
Add the following:
- A second-level heading of your name
- An image, from the /images folder, in the second paragraph
- Links to these files on the workshop website:
- unitsofmeasurement.html
- textalign.html
- lists.html
- Add a link to a main.css stylesheet into this file (ex2.html)
Add the following styles
- everything in Arial
- Set the background color of the page to some light color
- Make the level 1 heading a different color, centered
- Make the level 2 heading so that it is not in bold face, centered
- Make the level 3 headings in small caps
- Use circles for the bullets on unordered lists
