Professional Documents
Culture Documents
CASCADING
STYLE SHEET
Cascading Style Sheet (CSS)
4
Selectors
5
Universal Selector
7
Example
* {text-align: center;}
hr {width: 50%;}
<body>
<h1>This is a heading</h1>
<hr>
</body>
8
Example
* {text-align: center;}
hr {width: 50%;}
h1 {
font-style: italic;
color: blue;
}
9
Class Selector
10
11
Class Selector with Element Type
12
○ What will the following rules do?
*.big-warning {
font-size: x-large;
color: red;
}
13
ID Selector
14
span and div Elements
15
Style Priority
16
Style Priority
Highest to Lowest
1. In element’s style attribute
2. In style element in head section
3. In external file
4. In user setting within web browser
5. In the web browser defaults
CSS Specificity
span.green {
color: red;}
<div>
.green { <p>
This <span class="green">is
color: darkblue;}
</span> yet another text
</p>
span { </div>
color: brown;}
div p span.green {
color: yellow;} 19
Box Model
21
Sizes
22
CSS Units (w3schools.com)
Sizes
Unit Description
px Pixel size of the device
% Relative to the parent element
em Relative to the font-size of the element (2em means 2
times the size of the current font)
rem Relative to font-size of the root element
vw Relative to 1% of the width of the viewport*
vh Relative to 1% of the height of the viewport*
vmin Relative to 1% of viewport's* smaller dimension
vmax Relative to 1% of viewport's* larger dimension
23
Font Properties
24
Custom Font Family
@font-face {
font-family: Delicious;
src: url('Delicious-Roman.otf’);
}
25
Google Font
26
Shorthand Property
○ none : invisible
○ inline : elements will be added in single line
<span>, <q>, <strong>
○ block : elements will be added as new line
<p>, <div>, <ul>
○ inline-block : a block but displayed as inline
Display Property
○ Inline
Width or height cannot be controlled. Padding and
margin might behave differently.
29
Display Property
○ Block
The element will have width and height. Padding and
margin are respected.
Note: block will takes up entire line
○ Inline-block
Just like block, but it does not takes up entire line
30
Reset CSS
31
Reset CSS
33
34
Color Properties
36
Color Properties
37
Font Properties
○ font-style :
□ normal : normal character
□ oblique : slant the characters
□ italic : cursive font
38
Font Properties
○ font-variant :
□ normal : normal character
□ small-caps : smaller-capital for lowercase
39
Font Properties
○ font-weight :
□ normal, bold : normal or bold, depends on the
browser
□ bolder, lighter : bolder or lighter depends
on the surrounding text
□ 100, 200, …, 900 : normal is 400, bold is 700
○ font-family :
□ monospace : Courier New
□ serif : Times New Roman
□ sans-serif : Arial
□ cursive : Monotype Corsiva
□ fantasy : Impact
41
THANKS!
Any questions?
42