Professional Documents
Culture Documents
CSS
CSS
Outline
5.1 Introduction
5.2 Inline Styles
5.3 Embedded Style Sheets
5.4 Conflicting Styles
5.5 Linking External Style Sheets
5.6 Web Resources
1
Objectives
2
5.1 Introduction
3
5.2 Inline Styles
Declare an individual element’s format
Attribute style
CSS property followed by a colon and a value
i.e: style = “font-size:20pt”
4
Example1: Inline styles: inline.html
5
5.3 Embedded Style Sheets
Property Description
background-color Specifies the background color
font-family Specifies the name of the font to use
font-size Specifies a 14-point font
6
Example2: Embedded style sheets: declared.html
<h1>Clients</h1>
<p class = "special"> The company's clients include
many <em>Fortune 1000 companies</em>,
government agencies, branches ….
and World Wide Web courses.</p>
7
5.4 Conflicting Styles
Inheritance
Descendant’s properties have greater specificity
than ancestor’s properties
8
Example3: Inheritance in style sheets: advanced.html
<style type = "text/css">
a.nodec { text-decoration: none }
a:hover { text-decoration: underline;color: red;background-color: #ccffcc }
li em { color: red;font-weight: bold }
ul { margin-left: 75px }
ul ul { text-decoration: underline; margin-left: 15px }
</style>
11
Example4: External style sheets: styles.css
a { text-decoration: none }
ul { margin-left: 2cm }
12
Example4: Linking external style sheets: external.html
<head>
<link rel = "stylesheet" type = "text/css" href = "styles.css" />
</head>
<body>
<h1>Shopping list for <em>Monday</em>:</h1>
<ul>
<li>Milk</li>
<li>Bread
<ul>
<li>White bread</li>
<li>Rye bread</li>
<li>Whole wheat bread</li>
</ul>
</li>
<li>Rice</li>
<li>Potatoes</li>
<li>Pizza <em>with mushrooms</em></li>
</ul>
<p>
<a href = "http://www.food.com">Go to the Grocery store</a>
13
</p>
</body>
14
5.6 Web Resources
www.w3.org/TR/css3-roadmap
www.ddj.com/webreview/style
tech.irt.org/articles/css.htm
15