Lecture 05 CSS
Lecture 05 CSS
CSS
1 9/15/2024
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.
2 9/15/2024
CSS
• CSS Rule
3 9/15/2024
CSS
• CSS Rule
– The previous rule indicates that all elements should
be shown in the Arial typeface.
Declaration
5 9/15/2024
CSS
7 9/15/2024
CSS
8 9/15/2024
CSS
9 9/15/2024
Internal CSS
10 9/15/2024
Internal CSS
11 9/15/2024
External CSS
12 9/15/2024
External CSS
• <LINK>
– The <link> element can be used in an HTML document to tell the browser where
to find the CSS file used to style the page. It lives inside the <head> element. It
should use three attributes:
– href
• This specifies the path to the CSS file (which is often placed in a
folder called css or styles).
– type
• Attribute specifies the type of document being linked to. The
value should be text/css.
– rel
• Specifies the relationship between the HTML page and the file it
is linked to. The value should be stylesheet when linking to a
CSS file.
13 9/15/2024
External CSS
CSS
HTML
14 9/15/2024
CSS Selectors
15 9/15/2024
CSS selectors
16 9/15/2024
CSS Selector
17 9/15/2024
Rules for Applying CSS
18 9/15/2024
• 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.
19 9/15/2024
SPECIFICITY
If one selector is more
specific than the others, the
more specific rule will take
precedence over more
general ones. In this
example:
20 9/15/2024
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.
21 9/15/2024
SELECTORS
22 9/15/2024
Border
• border-width
– The border-width property is used to control the
width of a border. The value of this property can
either be given in pixels or using one of the following
values:
• thin
• medium
• thick
23 9/15/2024
Border
• border-width
– You can control the individual size of borders using
four separate properties:
• border-top-width
• border-right-width
• border-bottom-width
• border-left-width
– You can also specify different widths for the four
border values in one property, like so:
• border-width: 2px 1px 1px 2px;
24 9/15/2024
Example
25 9/15/2024
output
26 9/15/2024
Border Style Example
27 9/15/2024
• output
28 9/15/2024
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
30 9/15/2024
List: Example
31 9/15/2024
32 9/15/2024
Table Example
33 9/15/2024
Table Example
34 9/15/2024
Table example
• Output
35 9/15/2024
Page Padding
36 9/15/2024
CSS Box Model
37 9/15/2024
Example
38 9/15/2024
Output
39 9/15/2024
LAYOUT ELEMENTS
• Websites often display content in multiple columns
40 9/15/2024
WEBSITE LAYOUT
41 9/15/2024
WEBSITE LAYOUT
42 9/15/2024
WEBSITE LAYOUT
43 9/15/2024
CONTENT
• 1-column (often used for mobile browsers)
• 2-column (often used for tablets and laptops)
• 3-column layout (only used for desktops)
44 9/15/2024
WEBSITE LAYOUT
45 9/15/2024
WEBSITE LAYOUT
46 9/15/2024
WEBSITE LAYOUT
47 9/15/2024
WEBSITE LAYOUT
48 9/15/2024
WEBSITE LAYOUT
49 9/15/2024
WEBSITE LAYOUT
50 9/15/2024
IMAGES
51 9/15/2024
IMAGES
52 9/15/2024
IMAGES
53 9/15/2024
IMAGES
54 9/15/2024
IMAGES
55 9/15/2024
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.
56 9/15/2024
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.
57 9/15/2024
COLORS
58 9/15/2024
COLORS
59 9/15/2024
HTML CSS – Visual Studio
60 9/15/2024
HTML CSS – Visual Studio
61 9/15/2024
HTML CSS – Visual Studio
62 9/15/2024
HTML CSS – Visual Studio
63 9/15/2024
HTML Page – Visual Studio
64 9/15/2024
HTML CSS – Visual Studio
65 9/15/2024
HTML CSS – Visual Studio
66 9/15/2024
HTML CSS – Visual Studio
67 9/15/2024
HTML CSS – Visual Studio
68 9/15/2024
HTML CSS – Visual Studio
69 9/15/2024
HTML Page – Visual Studio
70 9/15/2024