Introduction To CSS (Cascading Style Sheets) : Technological University of The Philippines Cavite Campus
Introduction To CSS (Cascading Style Sheets) : Technological University of The Philippines Cavite Campus
Web Development 1
BTTE-CP-4A
October 5, 2022
IPT-C
08:00 a.m. – 11:00 a.m.
Prepared by:
Checked by:
This should be Sir Arnold, your CT
Prof. Julieta Fajardo
In-Campus Teaching Professor
I. OBJECTIVES
At the end of the lesson, the students should be able to:
2. Review
The teacher will ask the students about the past lesson:
a. What is HTML?
b. Why we use HTML Style Attribute?
c. Give an example of HTML Formatting Elements
3. Motivation
Title: Guessing Game
Instruction: This activity will be conducted on Google Meet. Students
are required to type their surname first in the comment
box before answering. If your surname was called, you
have 3 seconds to answer. Anyone who tried to answer
without their surname being called will be disqualified and
will have deduction in their activity.
2. Lesson Proper
CSS (Cascading Style Sheets)
- is used to apply styles to web pages. Cascading Style Sheets are fondly
referred to as CSS. It is used to make web pages presentable. The reason for
using this is to simplify the process of making web pages presentable. It
allows you to apply styles on web pages. More importantly, it enables you to
do this independently of the HTML that makes up each web page.
Basic Format: It is the basic structure of CSS style of a webpage.
body {
background-color: lightgray;
}
h1 {
color: green;
text-align: center;
}
p {
font-family: sans-serif;
font-size: 16px;
}
There are three types of CSS which are given below:
Example:
<html>
<head>
<style>
body {
background-color: lightblue;
}
h2 {
color: blue;
text-align: center;
}
</style>
</head>
<body>
<h2>CSS types</h2>
<p>Cascading Style sheet types: inline, external and internal</p>
</body>
</html>
Example:
HTML CODE
<html>
<head>
<link rel="stylesheet" href="mystyle.css">
</head>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
CSS CODE
body {
background-color: lightblue;
}
h1 {
color: navy;
margin-left: 20px;
}
3. Inline CSS is used to style a specific HTML element. Add a style attribute to
each HTML tag without using the selectors. Managing a website may
difficult if we use only inline CSS. However, Inline CSS in HTML is useful in
some situations. We have not access the CSS files or to apply styles to
element.
Example:
<html>
<body style="background-color:black;">
<h1 style="color:Red;padding:20px;">CSS Tutorials</h1>
<p style="color:blue;">It will be useful here.</p>
</body>
</html>
CSS COMMENTS
Comments are used to explain the code, and may help when you
edit the source code at a later date.
Comments are ignored by browsers.
A CSS comment is placed inside the <style> element, and starts
with /* and ends with */:
Example:
/* This is a single-line comment */
p {
color: red;
}
You can add comments wherever you want in the code:
Example:
p {
color: red; /* Set text color to red */
}
Example:
/* This is
a multi-line
comment */
p {
color: red;
}
CSS COLORS
Colors are specified using predefined color names, or RGB, HEX, HSL, RGBA, HSLA values.
CSS Color Names
In CSS, a color can be specified by using a predefined color name:
Tomato
Orange
DodgerBlue
MediumSeaGreen
Gray
SlateBlue
Violet
CSS RGB Colors
RGB Value
rgb(red, green, blue)
Each parameter (red, green, and blue) defines the intensity of the color between 0 and
255.
For example, rgb(255, 0, 0) is displayed as red, because red is set to its highest value
(255) and the others are set to 0.
To display black, set all color parameters to 0, like this: rgb(0, 0, 0).
To display white, set all color parameters to 255, like this: rgb(255, 255, 255).
#ff6347
Example:
#ff0000
#0000ff
#3cb371
#ee82ee
#ffa500
#6a5acd
CSS HSL Colors
HSL stands for hue, saturation, and lightness.
HSL Value
In CSS, a color can be specified using hue, saturation, and lightness (HSL) in the
form:
hsl(hue, saturation, lightness)
Hue is a degree on the color wheel from 0 to 360. 0 is red, 120 is green, and 240
is blue.
Saturation is a percentage value. 0% means a shade of gray, and 100% is the full
color.
Lightness is also a percentage. 0% is black, 50% is neither light or dark, 100% is
white
Experiment by mixing the HSL values below:
Example:
hsl(0, 100%, 50%)
hsl(240, 100%, 50%)
hsl(147, 50%, 47%)
hsl(300, 76%, 72%)
hsl(39, 100%, 50%)
hsl(248, 53%, 58%)
Saturation
Saturation can be described as the intensity of a color.
100% is pure color, no shades of gray.
50% is 50% gray, but you can still see the color.
0% is completely gray; you can no longer see the color.
Example:
hsl(0, 100%, 50%)
hsl(0, 80%, 50%)
hsl(0, 60%, 50%)
hsl(0, 40%, 50%)
hsl(0, 20%, 50%)
hsl(0, 0%, 50%)
Lightness
The lightness of a color can be described as how much light you want to give the
color, where 0% means no light (black), 50% means 50% light (neither dark nor
light) and 100% means full lightness (white).
Example:
hsl(0, 100%, 0%)
hsl(0, 100%, 25%)
hsl(0, 100%, 50%)
hsl(0, 100%, 75%)
hsl(0, 100%, 90%)
hsl(0, 100%, 100%)
3. Application
The teacher will ask the students to answer the activity using the sample code
below. They can use CodePen to run their code, after they answer the activity,
they should screenshot their answer and turn in it on the link provided. The
allotted time for this activity will be 10 minutes.
<head>
_____
</head>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph</p>
<p>This is a paragraph</p>
</body>
2. Set the page's background color to red, by using an inline style. (1 point)
_____
<body ="background-color: red">
<h1>This is a heading</h1>
<p>This is a paragraph</p>
<p>This is a paragraph</p>
</body>
<style>
____
{
_______
red;
}
</style>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph</p>
<p>This is a paragraph</p>
</body>
4. Generalization
What are the three (3) types of CSS?
Give me an example of CSS Color.
Why do we need to learn CSS?
IV. EVALUATION
Direction: The teacher will give 5-item quiz via Google forms. Read the questions
carefully and choose the letter that best describe the answer.
Key to Correction
1. B
2. A
3. A
4. C
5. D
V. ASSIGNMENT
A. Follow-up Assignment
Direction: Create a simple website and implement 1 CSS style of your choice.
Submit your assignment in Google Classroom. Submission is until the next week,
Monday October 10, 2022, 11:59 p.m.
B. Advance Assignment
Direction: Search for the following questions:
1. What is CSS Backgrounds?
2. What are the Do’s and Don’ts in choosing CSS Background?
Use Microsoft Word and save your work in a pdf file format. Submission of
assignment is until Monday October 10, 2022, 11:59 pm only.
REFERENCES:
* deliver the lesson in English, however try to improve your communication skills.
Try watching movies In English or reading articles
* “so”