WE Lecture03
WE Lecture03
CSS
CSS
• What is CSS
– CSS is a document that defines rules for layout of
web application frontend.
– For example,
• you can specify that the background of the page is cream,
all paragraphs should appear in gray using the Arial
typeface, or that all level one headings should be in a blue,
italic, Times typeface.
CSS
• CSS Rule
3 05/01/2025
CSS
• CSS Rule
– The previous rule indicates that all elements should
be shown in the Arial typeface.
Declaration
5 05/01/2025
CSS
• Example CSS
• Output
7 05/01/2025
CSS
• output
9 05/01/2025
CSS
10 05/01/2025
CSS
11 05/01/2025
CSS
12 05/01/2025
CSS
14 05/01/2025
CSS
15 05/01/2025
CSS
16 05/01/2025
CSS
17 05/01/2025
CSS
18 05/01/2025
CSS
19 05/01/2025
CSS
• Universal selector
– The universal selector (*) selects all HTML elements
on the page.
20 05/01/2025
CSS
• Grouping Selector
– The grouping selector selects all the HTML elements
with the same style definitions.
21 05/01/2025
CSS
• Combinators selector
– select elements based on a specific relationship
between them
– Example
• descendant selector (space)
• child selector (>)
• adjacent sibling selector (+)
• general sibling selector (~)
22 05/01/2025
CSS
• Combinator
– Descendent selector
• The descendant selector matches all elements that are
descendants of a specified element.
23 05/01/2025
CSS
• Combinator
– Child selector
• The child selector selects all elements that are the children of a
specified element.
24 05/01/2025
CSS
• Combinator
– Adjacent Sibling Selector
• The adjacent sibling selector selects all elements that are
the adjacent siblings of a specified element.
• Sibling elements must have the same parent element, and
"adjacent" means "immediately following".
25 05/01/2025
CSS
• Combinator
– Adjacent Sibling Selector
26 05/01/2025
CSS
• Combinator
– General Sibling Selector
• The general sibling selector selects all elements that are
siblings of a specified element.
27 05/01/2025
CSS
• Combinator
– General Sibling OR following sibling
28 05/01/2025
CSS
29 05/01/2025
CSS
• Pseudo-class selectors
– select elements based on a certain state
– A pseudo-class is used to define a special state of an
element.
– For example, it can be used to:
• Style an element when a mouse hover over it
• Style visited and unvisited links differently
• Style an element when it gets focus
– Syntax
selector : pseudo-class {
property:value;
}
30 05/01/2025
CSS
• Pseudo-class selectors
– Anchor Pseudo-classes
• a:link
– Describes properties associated with hyperlink
• a:visited
– Color of hyperlink once it is visited
• a:hover
– Color of hyperlink once user hovers over it
• a:active
– Color of hyperlink once clicked
31 05/01/2025
CSS
• Example
32 05/01/2025
CSS
• Pseudo-class
– Example (Tooltip Hover)
33 05/01/2025
Summary: CSS selectors
34 05/01/2025
Summary: CSS selectors
35 05/01/2025
Rules for Applying CSS
36 05/01/2025
• If there are two or more
rules that apply to the
same element, it is
important to understand
which will take
precedence.
• LAST RULE
• If the two selectors
are identical, the latter
of the two will take
precedence. Here you
can see the second i
selector takes
precedence over the
first.
37 05/01/2025
SPECIFICITY
If one selector is more
specific than the others, the
more specific rule will take
precedence over more
general ones. In this
example:
38 05/01/2025
IMPORTANT
You can add !important after
any property value to indicate
that it should be considered
more important than other
rules that apply to the same
element.
39 05/01/2025
Borders
40 05/01/2025
Borders
41 05/01/2025
List: Example
42 05/01/2025
Page Padding
• Example
43 05/01/2025
Page Padding
• Page Padding
44 05/01/2025
CSS
• Example
45 05/01/2025
CSS
46 05/01/2025
List Property
• Ordered List
– For an ordered (numbered) list you can use the following values:
– decimal
• 123
– decimal-leading-zero
• 01 02 03
– lower-alpha
• abc
– upper-alpha
• ABC
– lower-roman
• i. ii. iii.
– upper-roman
• I II III
48 05/01/2025
49 05/01/2025
Home Task
50 05/01/2025
Home Task
51 05/01/2025
Home Task
• Output
52 05/01/2025
LAYOUT ELEMENTS
• Websites often display content in multiple columns
53 05/01/2025
Page Layout
54 05/01/2025
Output
55 05/01/2025
WEBSITE LAYOUT
56 05/01/2025
WEBSITE LAYOUT
57 05/01/2025
WEBSITE LAYOUT
58 05/01/2025
CONTENT
• 1-column (often used for mobile browsers)
• 2-column (often used for tablets and laptops)
• 3-column layout (only used for desktops)
59 05/01/2025
WEBSITE LAYOUT
60 05/01/2025
WEBSITE LAYOUT
61 05/01/2025
WEBSITE LAYOUT
62 05/01/2025
WEBSITE LAYOUT
63 05/01/2025
WEBSITE LAYOUT
64 05/01/2025
WEBSITE LAYOUT
65 05/01/2025
IMAGES
66 05/01/2025
IMAGES
67 05/01/2025
IMAGES
68 05/01/2025
IMAGES
69 05/01/2025
IMAGES
70 05/01/2025
COLORS
102 red value of the red, 102, is There are 147 color names
205 green expressed as 66 supported by browsers
170 blue 205 of the green is expressed
as cd
the 170 of blue equates to aa.
71 05/01/2025
COLORS
HUE SATURATION BRIGHTNESS
Hue is near to the Saturation refers to the Brightness (or "value") refers
colloquial idea of color. amount of gray in a color. to how much black is in a color.
72 05/01/2025
COLORS
73 05/01/2025
COLORS
74 05/01/2025
HTML CSS – Visual Studio
75 05/01/2025
HTML CSS – Visual Studio
76 05/01/2025
HTML CSS – Visual Studio
77 05/01/2025
HTML CSS – Visual Studio
78 05/01/2025
HTML Page – Visual Studio
79 05/01/2025
HTML CSS – Visual Studio
80 05/01/2025
HTML CSS – Visual Studio
81 05/01/2025
HTML CSS – Visual Studio
82 05/01/2025
HTML CSS – Visual Studio
83 05/01/2025
HTML CSS – Visual Studio
84 05/01/2025
HTML Page – Visual Studio
85 05/01/2025