Cascading Style Sheets
Cascading Style Sheets
*To create a style sheet, create a file using Notepad (PC) or Text
Edit (Mac), save it as a .css document and start writing the CSS
code (see right).
CSS BENEFITS
External css
ATTACHING A STYLE SHEET
Document
<style type=“text/css”>
Rule_list
</style>
CSS RULE STRUCTURE
declaration
SELECTORS
body {
*CSS code can be written in a
background: purple; linear format (above) or in a block
color: green; format (below).
}
GROUPING SELECTORS
Group the same selector with different declarations
together on one line.
h1 {color: black;}
h1 {font-weight: bold;}
h1 {background: white;}
h1 {
color: black;
font-weight: bold;
background: white;
}
GROUPING SELECTORS
Group different selectors with the same declaration on
one line.
h1 {color: yellow;}
h2 {color: yellow;}
h3 {color: yellow;}
<p class=“normal”>
A paragraph text is presentedin ‘normal’ </p>
<p class=“warning”>
A paragraph text is presents a warning message.</p>
GENERIC SELECTOR
* {color:red;}
COLOR PROPERTIES
Color
Background-color
SPAN & DIV TAG