Lab 5: CSS: Text, Colors & Backgrounds

Goals

Learn...

  1. how to apply CSS to HTML documents
  2. about font and text-related CSS properties
  3. how colors are defined and applied
  4. applying background images and patterns.

Key Concept

Cascading Style Sheets (CSS) can be used define almost every aspect of an HTML document's visual presentation. The beauty of CSS is that all the pages of a logical website can share the same stylesheet, which allows a designer to change the appearance of many web pages by changing the code in one file.

Pre-lab

Pre-lab Reading

  • Textbook pp 207-222

Pre-lab Activity

  1. exercise 11-1
  2. exercise 11-2

Use reading and activity to answer the Pre-lab Questions. Be sure to complete the activity and answer the pre-lab questions in Blackboard before the start of the lab period.

In-lab

Preparation

  • Always make sure you save your lab files in the appropriate folder, i.e., lab5.
  • For file names, only use lowercase letter and never use spaces.

1. Formatting Menus

  • Download menu.html and save it to your lab5 folder.
  • Use the menu.htmlfile and complete exercise 12-1 through 12-7 using Notepad++. Refer to pages 225-258 for help.
  • It is OK to peek at the solution if you get lost, but do not look at it until you try to do all parts of the activity.
  • Make sure menu.html validates at http://validator.w3.org/#validate_by_upload
  • Show your instructor that menu.html is finished and validates.

2. Font & Text Questions

  • In Notepad++, create a webpage called lab5.html
  • Remember to include the basic HTML document structure shown on page 56 (Figure 4-7).
  • Answer the following questions and use HTML and CSS to appropriately markup and style your answers according to the instructions in the questions below.
  • Font & Text:

    1. What is the name of the CSS property for changing the font type. Use the HTML span tag with class="answer" to markup your answer below. Then use embedded CSS so that .answer uses the Georgia font.
    2. What is the name of the CSS property to make the font italic. Use the HTML span tag with class="answer" to markup your answer below. Then use embedded CSS so that .answer will be italic.
    3. What is the name of the CSS property to change the text color. Use the HTML span tag with class="answer" to markup your answer below. Then use embedded CSS so that .answer will have red text.
    4. What is the name of the CSS property to make text bold. Use the HTML span tag with class="answer" to markup your answer below. Then use embedded CSS so that .answer will have bold text.
  • Save your lab5.html file. We will answer more questions at the end of the lab.

3. Adding Color

4. Color & Background Questions

  • Continue to answer the following questions in yourlab5.htmlfile.
  • Font & Text:

    1. What is the HTML color code (#hexcode) for yellow. Use the HTML span tag with class="answer" to markup your answer below. Then use embedded CSS so that .answer will have a background color of yellow.
    2. What is the CSS property for specifying a background image. You do not have to use this property, just name it.
    3. What is the CSS code to position a background image so that it does not repeat and is centered horizontally at the top. You do not have to use this property, just write the code.
  • Deliverables

    Upload lab5.html to Blackboard.