UMass Lowell Dept. of Computer Science

91.461 GUI Programming I

Fall 2015 Semester, Section 201

Prof. Jesse M. Heines

Notes for Class No. 4

Introduction to CSS Structure and Syntax

Thursday, September 10, 2015

A video of this class is (or will be) posted at:   http://echo360.uml.edu/heines201516/guiprogramming1.html


Handouts and Materials


Openings / Announcements / Reminders

Assignment No. 3 is now posted


Class Notes

Related reading for this class:  CSS3:TMM Ch. 3


HTML5 and CSS Learning Resources

http://www.littlewebhut.com/html5/

http://www.littlewebhut.com/css/tutorials/

Also, there is starting to be a significant level of communication on Piazza


Critical concepts to remember


Introduction to CSS

Continuing from last class...

What are styles? 

New material begins here...

Purpose:  To define the rendering of HTML objects

The C of CSS stands for cascade

Assignment No. 3 “What You Are To Do”

  1. Read the first two chapters of the textbook carefully and Chapter 3 up to at least the middle of page 68 (page 57 in the 2nd edition).  Then read Chapter 6.  I strongly advise you to do the tutorial that begins on page 178 (page 138 in the 2nd edition), at least through page 188 (page 144 in the 2nd edition).  It will really help you learn.

  2. To solidify your knowledge, watch relevant parts of the CSS Tutorials on http://www.littlewebhut.com/css/.

    The important things to focus on in both the reading and the videos are the numerous techniques for specifying CSS selectors.

    • This is what we will be working on in class.
    • Writing CSS rules for things like colors and text styles is relatively easy, but using selectors to specify the precise objects you want to affect is not.
    • Also, note that jQuery and now even the latest version of JavaScript use the exact same selector mechanism, so it is absolutely critical that you master these techniques.
       
  3. Redo the page that you created for Assignment No. 2 or create a totally new page from scratch.  The page you choose must be “rich” enough to provide you with ample opportunities to style elements.  You may even wish to use a page created by someone else and add styling to that page.  Of course, if you choose a page that you did not initially create yourself, identify its source and author (or company if you cannot find an author named).


Inline Styles vs. Internal vs. External Style Sheets

Advantages and disadvantages of each

Inline Styles

<p style="color: red">This is red text.</p>

This is red text.

<p style="color: red ; font-style: italic ; text-decoration: underline">This is red, italic, underlined text.</p>

This is red, italic, underlined text.

Internal Style Sheets

<style type="text/css">
  ... rules go here ...
</style>

<style type="text/css">
  p.riu {  /* this rule applies to all p tags whose class is riu (red, italic, underline) */
    color: red ;
    font-style: italic ;
    text-decoration: underline
  }

</style>

External Style Sheets

<link rel="stylesheet" type="text/css" href="../css/LectureNotes.css">

<style type="text/css">
  @import url( ../css/LectureNotes.css ) ;  /* note that there are no quotes here */
</style>

p.riu {  /* this rule applies to all p tags whose class is riu (red, italic, underline) */
  color: red ;
  font-style: italic ;
  text-decoration: underline
}

A Comment on Comments


CSS Rules

The following material is covered in David Sawyer McFarland’s JavaScript & jQuery: The Missing Manual book (Chapter 4), but it is covered in much more detail in Chapter 3 of his CSS: The Missing Manual book.


[figure source:  CSS: The Missing Manual by David Sawyer McFarland, Figure 2-2, 2nd edition: page 33, 3rd edition: p. 38]


Organizing the CSS on Your Website


Formatting Text  (CSS:TMM, Chapter 6)

CSS Properties Reference

http://w3schools.com/cssref/default.asp


Basic Concepts


Question to Answer for Next Class

What is meant by a “CSS reset”?

 



This is document http://jesseheines.com:8080/~heines/91.461/91.461-2015-16f/461-lecs/lecture04.jsp.  It was last modified on Friday, August 26, 2022 at 4:09 PM.
Copyright © 2022 by Jesse M. Heines.  All rights reserved.  May be freely copied or excerpted for educational purposes with credit to the author.