Professional Documents
Culture Documents
Outline
In the previous lectures, we discussed:
Constructing individual CSS Style rules:
Creating Style-rule Selectors
Applying Style rules:
Via external and internal sheets, and individually.
Resolution of several conflicting styles (the Cascade).
In this Lecture, we continue our discussion of CSS
By considering Formatting with Styles:
Setting Font properties:
font-family, font-style, font-weight, font-size, etc.
We also touch on Setting Text properties:
Text color
With the remainder…
background, word-spacing, letter-spacing, etc
Covered next lecture.
Introduction
In the old days of HTML, tags were used for formatting:
For making text bold or italic (<b> and <i>)…
Or controlling font-size or color (e.g., <basefont>, <font>).
For complicated documents this becomes very messy…
Web programmers must wade through lots of code, to edit:
HTML does not support good code maintenance.
Instead of the set value, bold you may also choose to:
Apply a relative weight…
By choosing a value of lighter (= less bold) or bolder.
Select a weight between 100 and 900 (100’s only; 9 values).
Here, 400 is normal, while 700 is bold (Note: effects vary by font…)
Note: Bold formatting may be removed with: {font-weight:normal},
As is done above, for h1 and h2.
Note: The font-weight property is inherited.
Fonts 4: Setting the Font Size
You may control the size of fonts via the font-size property. Ex:
h1,h2{font-family:“Arial Black”,“Helvetica Bold”, sans-serif; font-weight:normal}
h1{font-size: 20px} h2{font-size: 14px}
p{font-family:Verdana, “Helvetica”, sans-serif ; font-size:12px}
.emph{font-style:italic; font-weight:bold}
a:hover{font-weight:bold} #toc{font-size: 12px}
Here, we set the font sizes to absolute values:
In pixels (px; most popular); For printing: cm, mm, points, picas.
Note: Avg. pixel value is 1/80th of an inch.
This is ‘Best Practice’: Except in IE6, allows users to tune the size:
View Text Size (Netscape, Firefox) or Zoom (Opera)
You may instead use a keyword to set absolute size :
7 values: xx-small, x-small, small, medium; large, x-large, xx-large
Relative units may also be used:
Via the em unit (y em = y times the parent’s font size).
Via a percentage value (x%; works just like ems (1em = 100%))
Via a relative keyword: larger or smaller.
z
Text 1: Setting Font Color
You may change the color of any text, via the color property:
Example (start from previous example’s markup + font format):