Prelude
If using Mac X – 1. use Word to write the HTML
2. save as text only with a html suffix [eg indexpage.html]
3. test using Safari or Firefox
If using Windows • Use Internet Explorer and View Source to access Notepad
• in Notepad save using html suffix
</head>
<body>
<div class="centre">
<div class="line">
<div class="l"> </div>
<p>Dr T's Wonderful Web Page</p>
<div id="navigation">
<h2> Main navigation</h2>
<p><a href = "example2css.html"> DR T Home </a></p>
<p><a href = "example1css.html"> example1css</a></p>
</div>
<div id="centerDoc">
<h1>Dr T's CSS Web page</h1>
<p>
Welcome to my web page
</p>
</div>
<div id="rightDoc">
<h2>Here is where the graphic goes</h2>
<img src = “smiley2.jpg” class = “figure” />
</div>
</body>
</html>
1
3. Create a css file [eg mycss1.css] to include style settings for each id
body {
p{
width: 80%; Setting styles for paragraph [p]
} line [li] headings [h1]
li {
list-style-type: none;
line-height: 150%;
list-style-image: url(images/arrowSmall.gif);
h1 {
font-family: Georgia, "Times New Roman", Times, serif;
font-size: 18px;
font-weight: bold;
color: #000000;
li :link {
color: #00CC00;
text-decoration: none;
font-weight: bold;
#navigation {
position: absolute;
width: 180 px;
height: 600px;
margin: 0;
margin-top: 50px;
border-right: 1px solid #C6EC8C;
font-weight: normal;
}
#centerDoc {
position: absolute;
padding: 0 0 20px 0; /*top right bottom left*/
margin-top: 50px;
margin-left: 215px;
}
#rightDoc {
position: absolute;
padding: 0 0 20px 0; /*top right bottom left*/
margin-top: 50px;
margin-left: 615px;
}
.figure{
float: left; Image settings
}
4. You can now use the css styles for all pages of your site.
Some Knowledge
• Core Attributes
class (.): elements covered by class may share aspects of presentation
[eg .info]
id (#): specifies a unique identifier for an element
[eg #intro]
style: specifies CSS properties for the element
* is a universal selector that applies to all elements in the document
[eg * {color: blue} would apply a blue foreground to all
element selector selects all instances of an element, specified by its tag name
[eg em {color: red;} gives every em element the same foreground colour.
Pseudo class selector (:)
combining selectors can narrow down what is being selected
[eg p.info {color: blue} selects only paragraphs belonging to the info class.
• In CSS a more specific selector trumps a less specific selector [eg class beats element]
3
Background graphic
Add the following code into your css file [for a background graphic called bg1.gif]
Within .Navigation identifier or style body [at top]
CSS
background-image: url(bg1.gif);
Containers
CSS
p {border-width: thin; border-style: solid; height: 100px; width: 100px; text-align: center}
p.red {background-color: red; position: relative; left: 0;}
p.white {background-color: white; position: relative; top: -100px; left: 50px;}
p.blue {background-color: blue; ; position: relative; top: -200px; left: 100px;}}
Absolute positioning
CSS
p {border-width: thin; border-style: solid; height: 100px; width: 100px; text-align: center}
p.red {background-color: red; position: relative; left: 0;}
p.white {background-color: white; position: relative; top: -100px; left: 50px;}
p.blue {background-color: blue; ; position: relative; top: -200px; left: 100px;}}