Professional Documents
Culture Documents
XHTML:
<head>
<title> sample document</title> The value “text/css”
<style type=“text/css”> defines the style
h1 {color: red;} language as
</style></head> Cascading Style Sheets
<body>
<h1>section title1</h1>
…….
Principles of Web Design, Third Edition 9
<h1>section title2</h1>
External style sheet
• /* ……….. */ adding comments in CSS
<head>
<title> sample document</title>
<link type="text/css" href="color.css" rel="stylesheet"/>
</head>
<head>
<title> sample document</title>
<style type="text/css">
h1{color: white; background-color: green;}
h2{color: red;}
</style>
</head>
<body>
<h1>Section Title1</h1>
<h2>Section Title2</h2>
</body>
Principles of Web Design, Third Edition 13
</html>
Principles of Web Design, Third Edition 14
basic.htm
<head>
<title>A Basic Document</title>
<style type="text/css">
h1 {text-align: center;}
p {font-family: sans-serif;}
</style>
</head>
<body>
<h1>CSS Basics</h1>
<p>CSS is based on a syntax)…..</p>
</body>
<p>
<style type=“text/css”>
body {color: red;}
</style>
<style type=”text/css”>
h1, h2 {color: green;}
</style>
<style type=”text/css”>
p b {color: blue;}
</style>
<style type=”text/css”>
ul li b {color: blue;}
</style>
Principles of Web Design, Third Edition 23
descendant.xhtml
<head>
<title>Descendant</title>
<style type="text/css">
p b {color: blue;}
</style>
</head>
<body>
<p>CSS is based on a syntax that is designed
to be easy to <b>write</b> and
<b>read</b>.</p>
<div>With CSS, you write style rules that
<b>select</b> an HTML element and
<b>declare</b> style characteristics for
the element.</div>
</body>
Principles of Web Design, Third Edition 24
Principles of Web Design, Third Edition 25
Using the Basic Selection Techniques
(oz1.htm)
<head>
<title>The Wizard of OZ by Frank L.
Baum</title>
<style>
h3 {text-align: right; color: gray;}
h1, h2 {margin-left: 20px; font-family:sans-
serif;}
h1 {border: 1px solid; padding: 5px;}
p {margin-left: 20px; font-family: serif;
font-size: 14pt;}
</style>
</head>
Principles of Web Design, Third Edition 26
oz1.htm
<body>
<h3>An excerpt from The Wizard of OZ</h3>
<h2>Chapter 1</h2>
<h1>The Cyclone</h1>
<p>From the far north they heard a low wail
of the wind, ………...</p>
<p>Suddenly Uncle Henry stood up.</p>
<p>"There's a cyclone coming, Em," he called
to his wife. ………...</p>
<p>Aunt Em dropped her work and came to the
door. ……….</p>
<p>"Quick, Dorothy!" she screamed. …</p>
</body>
Principles of Web Design, Third Edition 27
oz1.htm
h3 {text-align: right;
h1, h2 {margin-left: 20px; color: gray;}
font-family:sans-serif;}
p {margin-left: 20px;
font-family: serif;
font-size: 14pt;}
Principles of Web Design, Third Edition 28
Understanding Advanced Selection Techniques
<style type=”text/css”>
div.introduction {color:red;}
</style>
OR
<style type=”text/css”>
.introduction {color:red;}
</style>
<style type=”text/css”>
span.logo {color:red;}
</style>
• Then use the class attribute to specify the exact type of span.
• In the following example, the code defines the <span> element as the
special class named “logo.”
<body> section
Welcome to the <span class=“logo”>Wonder
Software</span> Web site.