comp 1850 | introduction to web design and development

lecture five

agenda

  • style sheets review
  • firefox extensions
  • css advantages
  • css box model
  • css positioning properties
  • exercises
  • readings

style sheets review

  • three parts to a CSS rule parts
    1. selector
    2. property
    3. value
  • three types of selectors
    1. HTML - simplest and most straightforward
    2. class - identifies a number of elements as being part of a conceptual group; requires the use of the class attribute within your markup
    3. id - identifies a unique element within a document; requires the use of the id attribute within your markup
  • three places to put style information:
    1. external - linked from each page in a web site
    2. embedded - placed in the <head> of the document to apply only to that document
    3. inline - applied to a single element using the style attribute

div and span

div and span are tagsets which allow you to define your own blocks of code for styling. Both of them require either a class or id to be assigned.

Use div to define a block of code that can be styled and positioned using css. The div tag is a block-element tag.

<div class="contentblock">content</div>

Use span to define a block of code for styling. The span tag is an in-line tag, and thus is not appropriate for positioning.

<span class="tabledata">content</span>

firefox extensions

  • Firefox is a free, customizable web browser that is one of the most standards-compliant browser available today
  • learn more:
  • several extensions (small add-ons that add new functionality to Mozilla applications) make web development much easier
  • to view installed extensions and add new ones:
    • go to Tools > Add-ons to launch the Add-ons window
    • click "Get Add-ons" at top of window
    • you can browse installed Add-ons or click Browse All Add-ons to visit the Add-ons database online
  • other useful developer extensions:

css advantages

  • greater typography control
  • style is separate from structure
  • potentially smaller documents
  • easier site maintenance
  • increased page layout control
  • increased accessibility
  • ability to define styles for multiple media types

css box model

  • as far as a style sheet is concerned, everything in your HTML is inside a box
  • from the outside in it looks like this:
    margin
    border
    padding
    this is some content
  • content: text & web page elements in the container
  • padding: area between the content and the margin
  • border: between the padding and the margin
  • margin: determines the empty space between the element and adjacent elements
  • content width vs. visible width:
    • content width is the size of the visible content (text, images, etc.)
    • visible width, however, includes everything out to the edges of border

css positioning properties

  • Relative
    • Use to slightly change the location of an element in relation to where it would otherwise appear
    • Hands-on: Create a new XHTML document using the following embedded rules:
      h1 { background-color:#cccccc;
      padding:5px;
      color: #000000;
      }

      #myContent { position: relative;
      left:30px;
      font-family:Arial,sans-serif;
      }
  • Absolute
    • Use to precisely specify the location of an element in the browser window
    • Hands-on: Create a new XHTML document using the following embedded rules:
      h1 { background-color:#cccccc;
      padding:5px;
      color: #000000;
      }

      #content {position: absolute;
      left:200;
      top:100;
      font-family:Arial,sans-serif;
      width:300;
      }
  • As an example of using CSS for positioning compare this page which uses no styling, to the same page that has been linked to an external stylesheet.

textbook resources

See these pages for common CSS properties (1) and box model and positioning properties (2).

  1. Table 3.1 on page 78
  2. Table 6.1 on page 230-232
  3. Figure 6.4 on page 218
  4. 6.6 CSS debugging tips page 246

external resources

  1. A CSS property index
    By Brian Wilson (no not THAT Brian Wilson)
  2. W3Schools
    Tutorials and examples.
  3. Complete CSS Guide
    From Westciv.
  4. 50 Useful Coding Techniques
    CSS Layouts, Visual Effects and Forms - from Smashing Magazine.
  5. Lists, Floats and Selectors
    Great tutorials from MaxDesign
  6. Position is Everything
    Advanced CSS techniques for dealing with browserr issues.
  7. The Layout Reservoir
    From bluerobot.com.
  8. CSS Layout Techniques
    From glish.com.
  9. 10 CSS tricks you may not know.
    From webcredible.co.uk.
  10. Little Boxes
    More CSS layout techniques
  11. Rich In Style
    CSS Guides, free stylesheets, bug reports, example pages, etc.

in class exercises

Download materials from shared space on signalflare.

  1. Using the files in the ex1_223 folder, complete the code on page 223 in the textbook (Hands-on Practice 6.2).
  2. For exercise 2, follow along with your instructor using the files in the ex2 folder.
  3. Using the files in the ex3_242 folder, complete the code on page 242 in the textbook (Hands-on Practice 6.6).

optional exercises

  1. Hands-On Practice 6.4, page 233. Use the files in the ex4_233 folder
  2. Create an advanced list:
    Recreate the code required to produce the linked list. Use XHTML and verify that your code is valid.
  3. Turn a list into a navigation bar:
    Walk through the steps required to recreate a navigation bar described by Roger Johansson in his excellent tutorial.
home | readings | assignments | sample projects | resources | 01 | introduction | 02 | html & ftp | 03 | links & tables | 04 | xhtml & css | 05 | css techniques | 06 | site structure | 07 | design principles | 08 | layout & graphics | 09 | forms | 10 | client-side scripting | 11 | server-side scripting | dave tanchak | jeff parker | students on signalflare | textbook website | comp 1950 | my.bcit | bcit | bcit: computing |