(Cascading-Style Sheet)
Week 2 Session 2
2
Outline
3
1. What is styling and why do we
need to style the HTML page?
4
Styling is ...
5
The importance of styling
6
What can be styled?
7
2. Inline Styling
8
Inline styling
9
An inline styling
11
3. Embedded styling
12
Embedded styling
13
<head>
<title>CSS Impact</title>
<style type="text/css">
h1 {
font-family: sans-serif;
<body>
}
<h1>
p {
CSS Impact
font-size: 12pt;
</h1>
font-family: arial, sans-serif;
<p>
}
This is a <b>normal</b> paragraph.
.special-p {
</p>
color: darkorchid;
<p class="special-p">
font-size: 200%;
This paragraph has been <b>styled</b>.
}
</p>
.special-a {
<a href="#">Ordinary Link</a>
text-decoration: none;
<a href="#" class="special-a">
background-color: green;
Styled Link
color: #ffffff;
</a>
}
</body>
</style>
</head>
14
An embedded styling
15
Problems with embedded styling
16
3. External styling
17
External styling
18
<head>
<title>CSS
h1 { Impact</title>
<style type="text/css">
font-family: sans-serif;
} h1 {
font-family: sans-serif;
<body>
}
p <head>
{ <h1>
pfont-size:
{
<title>CSS12pt;
Impact (External)</title>
CSS Impact
font-size:
font-family: 12pt;
arial, sans-serif;
<link rel="stylesheet"
</h1> href="style.css“ type="text/css">
font-family: arial, sans-serif;
} </head> <p>
}
This is a <b>normal</b> paragraph.
.special-p
.special-p { {
</p>
color: darkorchid;
color: darkorchid; <p class="special-p">
font-size:200%;
font-size: 200%;
This paragraph has been <b>styled</b>.
} }
</p>
.special-a {
<a href="#">Ordinary Link</a>
text-decoration:
.special-a { none;
<a href="#" class="special-a">
background-color:
text-decoration: green;
none;
Styled Link
color: #ffffff; green;
background-color: </a>
}color: #ffffff;
</body>
</style>
}
</head>
19
5. CSS Framework
20
CSS Framework [1]
• A framework provides a set of ready to use
components.
• Using framework will certainly:
– Improve code standard in a project.
– Faster development and page prototyping.
– Beautiful design.
• It also has some drawbacks, such as:
– Increase code dependency.
– Learning effort and time.
21
CSS Framework [2]
• Most commonly features:
– Premade basic layouts.
– Grid system that works similar to table but much
more flexible.
– Typography, icons.
– Page responsiveness.
• Most of the above features are wrapped in the
form of CSS classes.
• When using a CSS framework the most used
tag to structure the page is the div.
22
CSS Framework [3]
• Suggested frameworks:
– Bootstrap (https://getbootstrap.com/)
– Bulma (https://bulma.io/)
23
To do
24
EOF
25