2. C S S
Cascading Style Sheets
Introduction
What is CSS?
CSS is an extension to basic HTML
that allows you to style
your web pages.
3. C S S
Cascading Style Sheets
Role of CSS
1. MULTIPLE style sheets can apply to the SAME Web page
2. SAME style sheets can apply to the MULTIPLE Web page
4. C S S
Cascading Style Sheets
How to use CSS?
There are 3 ways to use CSS
Internal Style SheetInline Style Sheet External Style Sheet
(inside the <head> tag)(inside HTML element)
5. C S S
Cascading Style Sheets
Rules in CSS
A CSS Style Sheet is basically a collection of rules,
describing how the browser should display HTML elements.
Each rule contains 2 parts:
1. A Selector, stating which element in the HTML a
rule applies to;
2. One or more Declarations, which describe how
these elements should be displayed
6. C S S
Cascading Style Sheets
Selector
For Example
{
font-family: Times, Georgia, serif;
font-size: 24px;
text-align: center;
}
h1
Declarations
Enclosed in curly brackets { }
Selector
7. C S S
Cascading Style Sheets
h1{
font-family: Times, Georgia, serif;
font-size: 24px;
text-align: center;
}
Declaration has also 2 Parts
Properties Values
Properties and values
separated with a colon
Each declaration separated
with a semi-colon
For Example
Declarations consist of 2 parts: a property and a value. Each declaration ends with
a semi-colon ( ; ). Properties and values are separated with a colon ( : )