Академический Документы
Профессиональный Документы
Культура Документы
To CSS
HTML Review
What
Lesson 1: Examples of
CSS
Example 1: http://www.csszengarden.com/
Example 2: http://w3schools.com/css/demo_default.htm
If you notice each time we click on a different CSS style sheet
on the two pages above the look and feel of each page
changes dramatically but the content stays the same.
HTML did not offer us this option.
HTML was never intended to contain tags for formatting a
document.
HTML was intended to define the content of a document, like:
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
When tags like <font>, and color attributes were added to the
HTML 3.2 specification, it started a nightmare for web
developers. Development of large web sites, where fonts and
color information were added to every single page, became a
long and expensive process.
To solve this problem, the World Wide Web Consortium (W3C)
created CSS.
selector
property/value
declaration
declaration block
curly braces
Selector
Definition: identifies the HTML elements
that the rule will be applied to, identified
by the actual element name, e.g. <body>,
or by other means such as class attribute
values.
Example:
Declaration
Definition: Each CSS line that includes
property and value
Declaration Block
Definition: multiple declaration lines
including the curly braces
Curly Braces
Definition: the curly braces contain the
properties of the element you want to
manipulate, and the values that you want
to change them to. The curly braces plus
their content is called a declaration block.
Example:
Lesson 2 Assignment:
Lets Create Our First CSS Page
Open Notepad
Type the following Code
<html>
<head>
<style type="text/css">
p {color:red; text-align:center;}
</style>
</head>
<body>
<p>Hello World!</p>
<p>This paragraph is styled with CSS.</p>
</body>
</html>
Instructor
#para1 {text-align:center;color:red;}
.center {text-align:center;}
Lesson 3 Assignment:
Lets Create A CSS Page that uses id
Open Notepad
Type the following Code
<html>
<head>
<style type="text/css">
#para1
{
text-align:center;
color:red;
}
</style>
</head>
Instructor
<body>
<p id="para1">Hello World!</p>
<p>This paragraph is not affected by the style.</p>
</body>
</html>
Lesson 3 Assignment:
Lets Create A CSS Page that uses class
Open Notepad
Type the following Code
<html>
<head>
<style type="text/css">
.center
{
text-align:center;
}
</style>
</head>
Instructor
<body>
<h1 class="center">Center-aligned heading</h1>
<p class="center">Center-aligned paragraph.</p>
</body>
</html>
Lesson 3 Comments
Comments are used to explain your code, and may help you when
you edit the source code at a later date. Comments are ignored by
browsers.
Comments can span several lines, and the browser will ignore these
lines.
Example:
/*This is a comment*/
p{ text-align:center; color:black; font-family:arial;}
Lesson 3 Assignment:
Lets Add A Comment
<html>
<head>
<body>
<p id="para1">Hello World!</p>
<p>This paragraph is not affected by the style.</p>
</body>
</html>
Inline style
Internal style sheet
External style sheet
CSS
Applies styles directly to the elements
by adding declarations into the style
For Example:
<p style=color: red;> This is a simple
paragraph and the inline style makes
it red.</p>
Colors
In the previous lesson you have seen
a few CSS styles that included color
like: <p style=color: red;>
There are a few ways that you can set
colors in CSS:
Keywords, Hex values, RGB, HSL(a)
Colors: Keywords
Using the keywords like: red, fuchsia,
yellow, blue, green you can specify what
color you would like the CSS rule to display.
For example:
p{color:red}
h2{color:yellow}
There are 17 of these keyword colors you
can use in CSS.
Hex
aqua
#00ffff
black
#000000
blue
#0000ff
fuchsia
#ff00ff
gray
#808080
green
#008000
lime
#00ff00
maroon
#800000
navy
#000080
olive
#808000
#ffa500
purple
#800080
red
#ff0000
silver
#c0c0c0
teal
#008080
white
#ffffff
yellow
#ffff00
Lesson 5 Assignment:
CSS Using Color
<html>
<body>
<p style="background-color:#FFF111">
Color set by using hex value
</p>
<p style="background-color:rgb(0,255,0);">
Color set by using rgb value
</p>
<p style="background-color:red">
Color set by using color name
</p>
Instructor
</body>
</html>
Save Your File as css-color.html into your folder called CSS
Essential
Questions Review