cascading style sheets robin burke ect 270. outline midterm the layout debate css properties fonts...

44
Cascading Style Sheets Robin Burke ECT 270

Upload: garey-harper

Post on 04-Jan-2016

221 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Cascading Style Sheets Robin Burke ECT 270. Outline Midterm The Layout Debate CSS properties Fonts Alignment Color CSS selection selectors pseudo-classes

Cascading Style Sheets

Robin Burke

ECT 270

Page 2: Cascading Style Sheets Robin Burke ECT 270. Outline Midterm The Layout Debate CSS properties Fonts Alignment Color CSS selection selectors pseudo-classes

Outline

Midterm The Layout Debate CSS properties

Fonts Alignment Color

CSS selection selectors pseudo-classes classes, ids div and span

Page 3: Cascading Style Sheets Robin Burke ECT 270. Outline Midterm The Layout Debate CSS properties Fonts Alignment Color CSS selection selectors pseudo-classes

Midterm

10/20 5:45 pm

closed-bookHTML/CSS handout distributed

Page 4: Cascading Style Sheets Robin Burke ECT 270. Outline Midterm The Layout Debate CSS properties Fonts Alignment Color CSS selection selectors pseudo-classes

Group exercise

Part A

Page 5: Cascading Style Sheets Robin Burke ECT 270. Outline Midterm The Layout Debate CSS properties Fonts Alignment Color CSS selection selectors pseudo-classes

The Great Layout Debate

PuristW3C

Pragmatistweb designers

Page 6: Cascading Style Sheets Robin Burke ECT 270. Outline Midterm The Layout Debate CSS properties Fonts Alignment Color CSS selection selectors pseudo-classes

A solution

A separate standard for defining style Styles can be defined at different

placesdocumentsitelocal device or clientuser preference

Page 7: Cascading Style Sheets Robin Burke ECT 270. Outline Midterm The Layout Debate CSS properties Fonts Alignment Color CSS selection selectors pseudo-classes

What is a style?

An association between a set of display propertiesa logical unit of HTML content

Notdocument content

Some exceptionsnumbered lists, captions, etc.

Page 8: Cascading Style Sheets Robin Burke ECT 270. Outline Midterm The Layout Debate CSS properties Fonts Alignment Color CSS selection selectors pseudo-classes

Result

HTML goes back to defining structure Layout and display decisions encoded

in the stylesheet Designer can easily change page

format without affecting HTML

Page 9: Cascading Style Sheets Robin Burke ECT 270. Outline Midterm The Layout Debate CSS properties Fonts Alignment Color CSS selection selectors pseudo-classes

Cascading

Author User Client Also possible to label styles as

"important"

Page 10: Cascading Style Sheets Robin Burke ECT 270. Outline Midterm The Layout Debate CSS properties Fonts Alignment Color CSS selection selectors pseudo-classes

Inheritance

Elements inherit their stylessetting a style for the "body" element

changes the whole document

Page 11: Cascading Style Sheets Robin Burke ECT 270. Outline Midterm The Layout Debate CSS properties Fonts Alignment Color CSS selection selectors pseudo-classes

In-line styles

part of individual tags plus

benefits of new CSS attributesstyle declared where it is used

minusdoesn't separate content from displayglobal changes not simplified

Page 12: Cascading Style Sheets Robin Burke ECT 270. Outline Midterm The Layout Debate CSS properties Fonts Alignment Color CSS selection selectors pseudo-classes

Embedded style

style is declared within a given page plus

style information centralized minus

can't be reused on other pages

Page 13: Cascading Style Sheets Robin Burke ECT 270. Outline Midterm The Layout Debate CSS properties Fonts Alignment Color CSS selection selectors pseudo-classes

External

a separate document "style sheet" is useddocuments link to the style sheet

plusstyle can be shared across pages

minusanother document to manage &

distribute

Page 14: Cascading Style Sheets Robin Burke ECT 270. Outline Midterm The Layout Debate CSS properties Fonts Alignment Color CSS selection selectors pseudo-classes

Structure of CSS

selector { attribute:value; } Example

h1 { font-color:blue; } Multiple attribute/values pairs possible

Page 15: Cascading Style Sheets Robin Burke ECT 270. Outline Midterm The Layout Debate CSS properties Fonts Alignment Color CSS selection selectors pseudo-classes

Examples

in-line style embedded style linked style

Page 16: Cascading Style Sheets Robin Burke ECT 270. Outline Midterm The Layout Debate CSS properties Fonts Alignment Color CSS selection selectors pseudo-classes

CSS Rules: Fonts

Fonts are very complex platform-specific copyrighted different standards

Multi-dimensional size weight style ornament family

Page 17: Cascading Style Sheets Robin Burke ECT 270. Outline Midterm The Layout Debate CSS properties Fonts Alignment Color CSS selection selectors pseudo-classes

Font families

Categories serif sans-serif monospace cursive

Specific fonts Times Roman Arial Courier

Page 18: Cascading Style Sheets Robin Burke ECT 270. Outline Midterm The Layout Debate CSS properties Fonts Alignment Color CSS selection selectors pseudo-classes

font-family styles

Best practicePC font, Mac font, generic font;

Examplefont-family: Arial, Helvetica, sans-serif;

Page 19: Cascading Style Sheets Robin Burke ECT 270. Outline Midterm The Layout Debate CSS properties Fonts Alignment Color CSS selection selectors pseudo-classes

Font sizes

Options Relative Absolute Units

• in, px, em, pt, pc Examples

font-size: larger font-size: 12 pt font-size: 50 px font-size: small

Page 20: Cascading Style Sheets Robin Burke ECT 270. Outline Midterm The Layout Debate CSS properties Fonts Alignment Color CSS selection selectors pseudo-classes

Spacing

Can control letter and line spacingletter-spacingword-spacingline-height

Page 21: Cascading Style Sheets Robin Burke ECT 270. Outline Midterm The Layout Debate CSS properties Fonts Alignment Color CSS selection selectors pseudo-classes

Alignment

text-alignhorizontal alignmentlike "align" attribute

vertical-alignlike "valign" attributebut more possibilities

Page 22: Cascading Style Sheets Robin Burke ECT 270. Outline Midterm The Layout Debate CSS properties Fonts Alignment Color CSS selection selectors pseudo-classes

Other font style choices

text-weight controls boldness

text-decoration underlining, strike-through

text-transform uppercase, lowercase

font-variant small-caps

font-style italic

Page 23: Cascading Style Sheets Robin Burke ECT 270. Outline Midterm The Layout Debate CSS properties Fonts Alignment Color CSS selection selectors pseudo-classes

CSS Rules: Colors

What can be colored?textbackgroundlinks

Optionscolor namesRGB triplets

• hex or decimal

Page 24: Cascading Style Sheets Robin Burke ECT 270. Outline Midterm The Layout Debate CSS properties Fonts Alignment Color CSS selection selectors pseudo-classes

Text and link color

color changes the text color example

• color: rgb(153,102,6)• color: #FFEECC

links can have state-dependent colors link – unvisited visited – visited active – while being clicked hover – while the cursor is there

Page 25: Cascading Style Sheets Robin Burke ECT 270. Outline Midterm The Layout Debate CSS properties Fonts Alignment Color CSS selection selectors pseudo-classes

Link colors

Handled via "pseudo-classes" relative to a elementa:linka:visited

Examplea:link { color: red; }a:visited { color: blue; }

Page 26: Cascading Style Sheets Robin Burke ECT 270. Outline Midterm The Layout Debate CSS properties Fonts Alignment Color CSS selection selectors pseudo-classes

Link color example

a:link { color: red; }

a:visited { color: blue; text-decoration: none; }

a:active { font-weight: bolder; }

a:hover { color: green; }

Page 27: Cascading Style Sheets Robin Burke ECT 270. Outline Midterm The Layout Debate CSS properties Fonts Alignment Color CSS selection selectors pseudo-classes

Background color

Background of any element can be setnot true in HTML

Page 28: Cascading Style Sheets Robin Burke ECT 270. Outline Midterm The Layout Debate CSS properties Fonts Alignment Color CSS selection selectors pseudo-classes

Background images

Background imageslimited in HTML

• either large or tiled

With CSSTotal control over the background

image

Page 29: Cascading Style Sheets Robin Burke ECT 270. Outline Midterm The Layout Debate CSS properties Fonts Alignment Color CSS selection selectors pseudo-classes

Example

Background options

Page 30: Cascading Style Sheets Robin Burke ECT 270. Outline Midterm The Layout Debate CSS properties Fonts Alignment Color CSS selection selectors pseudo-classes

Lists

can choose different kinds of bullets can control nesting behavior Example

Page 31: Cascading Style Sheets Robin Burke ECT 270. Outline Midterm The Layout Debate CSS properties Fonts Alignment Color CSS selection selectors pseudo-classes

CSS Rules: Selectors

any html element name element with particular attribute

td[align="center"] not implemented in IE 6.0

element relationshipsa ba > ba + b

designer-defined classes

Page 32: Cascading Style Sheets Robin Burke ECT 270. Outline Midterm The Layout Debate CSS properties Fonts Alignment Color CSS selection selectors pseudo-classes

CSS Pseudo-elements

Pseudo-elementsa class name that is pre-defined but

isn't an HTML tag Example

first-linefirst-letter

Page 33: Cascading Style Sheets Robin Burke ECT 270. Outline Midterm The Layout Debate CSS properties Fonts Alignment Color CSS selection selectors pseudo-classes

Example

table caption { background-color: blue;

color: white; }

tr td { background-color: yellow; }

th:first-letter { font-size:large; color: red; }

Page 34: Cascading Style Sheets Robin Burke ECT 270. Outline Midterm The Layout Debate CSS properties Fonts Alignment Color CSS selection selectors pseudo-classes

CSS Classes and Ids

A class is a user-defined name identifies certain elements for styling

• li.yes

Another example code in <pre> elements

ID must be unique in document use for identify a single element to have a

particular style #id

Page 35: Cascading Style Sheets Robin Burke ECT 270. Outline Midterm The Layout Debate CSS properties Fonts Alignment Color CSS selection selectors pseudo-classes

CSS Blocks

What if I have a segment that isn't an HTML element?

Examplescaption and program listingemphasized text

Page 36: Cascading Style Sheets Robin Burke ECT 270. Outline Midterm The Layout Debate CSS properties Fonts Alignment Color CSS selection selectors pseudo-classes

Alignment and positioning

padding

border

margin

Block-level element

Page 37: Cascading Style Sheets Robin Burke ECT 270. Outline Midterm The Layout Debate CSS properties Fonts Alignment Color CSS selection selectors pseudo-classes

Layering

Boxes can overlap each othertransparent regions will show throughlayering

• negative margin does this

Boxes can be positioned absolutelyalso causes layering

• position: absolute• specific position on page

Page 38: Cascading Style Sheets Robin Burke ECT 270. Outline Midterm The Layout Debate CSS properties Fonts Alignment Color CSS selection selectors pseudo-classes

Examples

layering with margins layering with absolute positioning

Page 39: Cascading Style Sheets Robin Burke ECT 270. Outline Midterm The Layout Debate CSS properties Fonts Alignment Color CSS selection selectors pseudo-classes

Frames

We can get "frame-like" appearancewith absolute positioning

Page 40: Cascading Style Sheets Robin Burke ECT 270. Outline Midterm The Layout Debate CSS properties Fonts Alignment Color CSS selection selectors pseudo-classes

Example

Frame

Page 41: Cascading Style Sheets Robin Burke ECT 270. Outline Midterm The Layout Debate CSS properties Fonts Alignment Color CSS selection selectors pseudo-classes

Exercise

Page 42: Cascading Style Sheets Robin Burke ECT 270. Outline Midterm The Layout Debate CSS properties Fonts Alignment Color CSS selection selectors pseudo-classes

Elements

bullet.gif

picture7.gif

circlesbg.gif

confetti.gif

Page 43: Cascading Style Sheets Robin Burke ECT 270. Outline Midterm The Layout Debate CSS properties Fonts Alignment Color CSS selection selectors pseudo-classes

Group exercise

Part B

Page 44: Cascading Style Sheets Robin Burke ECT 270. Outline Midterm The Layout Debate CSS properties Fonts Alignment Color CSS selection selectors pseudo-classes

Next week

Midterm Web design