Professional Documents
Culture Documents
- Level 2
Your Classroom Learning experience is just one part of the New Horizons learning solution; an enriching, dynamic
and valuable experience that includes Web-based resources during and after class.
The New Horizons learning solution includes online resources such as assessments, eCourseware and self-study
tutorials, making it the finest and most robust learning environment available.
A full electronic version of the user manual - eCourseware - is available for reference and use post-class. Updates to
the content within the eCourseware manual are automatic, providing you with access to the latest version of the
course material at all times.
To access eCourseware and other online resources for this class, visit www.newhorizons.com and select Student
Resources. New Horizons Learning Port a hosted, Web-based platform supports the delivery and management of
your post-class resources. For more information about other available learning options, contact your local New
Horizons Computer Learning Center.
(Note: Access keys are case-sensitive and must be entered exactly as displayed.)
Username:
Password:
This login provides access to class resources only. When creating your “Username” enter something unique such as adding the
letters ILT (Instructor Led Training) to the end of the name. This will set it apart from logins that you may use for other types of
online training.
Web Design with XHTML, HTML, and
CSS - Level 2
Part Number: NH85961 (CWEE)
Course Edition: 1.0
ACKNOWLEDGMENTS
Project Team
Content Developer: Praveena Jaipal • Content Manager: Harleen Sethi • Graphic Designer: Ganeshkumar B • Project
Manager: Lamayu A • Media Instructional Designer: Praveena Jaipal • Content Editor: Tayub Refai • Materials Editor: Arul M
• Quality Assurance Specialist: Shobana TS • Technical Reviewer: Jaron J Rubenstein • Project Technical Support: Mike
Toscano
NOTICES
DISCLAIMER: While Element K Corporation takes care to ensure the accuracy and quality of these materials, we cannot guarantee their accuracy, and all materials are provided without any warranty
whatsoever, including, but not limited to, the implied warranties of merchantability or fitness for a particular purpose. The name used in the data files for this course is that of a fictitious company. Any
resemblance to current or future companies is purely coincidental. We do not believe we have used anyone’s name in creating this course, but if we have, please notify us and we will change the name in
the next revision of the course. Element K is an independent provider of integrated training solutions for individuals, businesses, educational institutions, and government agencies. Use of screenshots,
photographs of another entity’s products, or another entity’s product name or service in this book is for editorial purposes only. No such use should be construed to imply sponsorship or endorsement of
the book by, nor any affiliation of such entity with Element K. This courseware may contain links to sites on the Internet that are owned and operated by third parties (the ″External Sites″). Element K is
not responsible for the availability of, or the content located on or through, any External Site. Please contact Element K if you have any concerns regarding such links or External Sites.
TRADEMARK NOTICES: Element K and the Element K logo are trademarks of Element K Corporation and its affiliates.
Microsoft® Internet Explorer 7 is a registered trademark of Microsoft Corporation in the U.S. and other countries; the Microsoft products and services discussed or described may be trademarks of the
Microsoft Corporation. All other product names and services used throughout this course may be common law or registered trademarks of their respective proprietors.
Mozilla Firefox™ 2 is a registered trademark of Mozilla Foundation in the U.S. and other countries; the Mozilla products and services discussed or described may be trademarks of Mozilla Foundation. All
other product names and services used throughout this course may be common law or registered trademarks of their respective proprietors.
Copyright © 2008 © 2008 Element K Corporation. All rights reserved. Screenshots used for illustrative purposes are the property of the software proprietor. This publication, or any part thereof, may not
be reproduced or transmitted in any form or by any means, electronic or mechanical, including photocopying, recording, storage in an information retrieval system, or otherwise, without express written
permission of Element K, 500 Canal View Boulevard, Rochester, NY 14623, (585) 240-7500, (800) 478-7788. Element K Courseware’s World Wide Web site is located at
www.elementkcourseware.com.
This book conveys no rights in the software or other products about which it was written; all use or licensing of such software or other products is the responsibility of the user according to terms and
conditions of the owner. Do not make illegal copies of books or software. If you believe that this book, related materials, or any other Element K materials are being reproduced or transmitted without
permission, please call (800) 478-7788.
Contents iii
CONTENTS
LESSON 3 - TESTING A WEBSITE
A. Test Markup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
The W3C® Markup Validation Service . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
B. Test CSS . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
The W3C® CSS Validation Service . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 68
INDEX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153
Course Description
Target Student
This course is designed for persons who understand the fundamentals of XHTML, HTML, and
CSS and have used the three technologies to create basic web pages. It is aimed at individuals
interested in using these technologies to create advanced web pages and test their validity.
Course Prerequisites
Students should be familiar with using personal computers with a mouse and keyboard. Basic
typing skills are mandatory. You should be comfortable in the Windows environment and be
able to use Windows to manage information on your computer. Specifically, you should be
able to launch and close programs; navigate to information stored on the computer; and man-
age files and folders. Familiarity with Internet Explorer 7 and Firefox is an advantage. Apart
from these, the user should be familiar with Web Design with XHTML, HTML, and CSS -
Level 1.
Introduction v
INTRODUCTION
How to Use This Book
As a Learning Guide
Each lesson covers one broad topic or set of related topics. Lessons are arranged in order of
increasing proficiency with XHTML, HTML, and CSS; skills you acquire in one lesson are used
and developed in subsequent lessons. For this reason, you should work through the lessons in
sequence.
We organized each lesson into results-oriented topics. Topics include all the relevant and sup-
porting information you need to master XHTML, HTML, and CSS, and activities allow you to
apply this information to practical hands-on examples.
You get to try out each new skill on a specially prepared sample file. This saves you typing
time and allows you to concentrate on the skill at hand. Through the use of sample files,
hands-on activities, illustrations that give you feedback at crucial steps, and supporting back-
ground information, this book provides you with the foundation and structure to learn XHTML,
HTML, and CSS quickly and easily.
As a Review Tool
Any method of instruction is only as effective as the time and effort you are willing to invest
in it. In addition, some of the information that you learn in class may not be important to you
immediately, but it may become important later on. For this reason, we encourage you to
spend some time reviewing the topics and activities after the course. For additional challenge
when reviewing activities, try the ″What You Do″ column before looking at the ″How You Do
It″ column.
As a Reference
The organization and layout of the book make it easy to use as a learning tool and as an after-
class reference. You can use this book as a first source for definitions of terms, background
information on given topics, and summaries of procedures.
Course Objectives
In this course, you will create advanced web pages and test their validity.
You will:
• create web page layouts.
• manage CSS.
• test a website.
• create advanced navigation.
• incorporate meta-content and multimedia.
Software
• Microsoft® Windows® XP Professional with Service Pack 2
• Microsoft® Internet Explorer 7
• Mozilla Firefox™ 2 or above
• A source code editor, Notepad++ 4.6
• QuickTime Player 7 or above
• Adobe® Flash® Player plug-in for Internet Explorer
• Adobe® Flash® Player plug-in for Firefox
Class Setup
1. Install Windows XP Professional on the C drive using the following parameters:
a. Accept the license agreement.
b. Create a 4 GB partition on the C drive.
c. Format the C partition to NTFS.
d. Select the appropriate regional and language settings.
e. Enter the appropriate name and organization for your environment.
f. Enter the product key.
g. For each student computer, configure the settings:
— Name of computer: Computer# (where # is a unique integer representing the
student computer)
— Administrator password: password
— Select your time zone
— Select the Typical network configuration
2. Install Service Pack 2 for Windows XP.
Introduction vii
INTRODUCTION
3. Download and install Windows Internet Explorer 7 or Mozilla Firefox 2.0 or above.
— Windows Internet Explorer 7 can be downloaded at http://www.microsoft.com/
windows/downloads/ie/getitnow.mspx?wt_svl=20510a&mg_id=20510b.
— Mozilla Firefox 2.0 or above can be downloaded at http://www.mozilla.com/en-US/
firefox/.
4. Display the file extensions of your documents.
a. Choose Start→All Programs→Accessories→Windows Explorer.
b. In Windows Explorer, choose Tools→Folder Options.
c. Select the View tab and uncheck the Hide extensions for known file types check
box.
5. Install Notepad++ 4.6.
a. Open http://notepad-plus.sourceforge.net/uk/site.htm in Internet Explorer.
b. Click the Download link.
c. Under the Binary files heading, click the Download Notepad++ executable files
link.
d. In the SourceForge.net window, expand npp 4.6 bin.
e. Click the npp.4.6 Installer.exe link.
f. If you experience problems with the download, click the this direct link link.
g. In the File Download Security Warning dialog box, click Run.
h. In the Internet Explorer-Security Warning dialog box, click Run.
i. In the Installer Language dialog box, verify if English is selected and click OK.
j. In the Notepad++v.6 setup dialog box, click Next.
k. In the License Agreement dialog box, click I agree.
l. In the Choose Install Location dialog box, click Browse.
m. In the Browse For Folder dialog box, click Make New Folder and name it as
Notepad++ and click OK.
n. Click Next.
o. In the Choose Components dialog box, check the As default html viewer check
box.
p. Click Install.
q. Click Finish.
6. Install QuickTime Player 7.
a. Open http://www.apple.com/quicktime/download in Internet Explorer.
b. In the Download the free player pane, select the QuickTime 7.4.1 for Windows
XP or Vista option.
c. Click the Free Download Now link.
d. In the File Download - Security Warning message box, click Save.
e. Download and install the EXE file.
7. Install the Adobe® Flash® Player plug-in for Internet Explorer.
a. Open http://www.adobe.com in Internet Explorer.
b. Click the Get Adobe® Flash® Player link.
c. Follow the instructions on the web page to install the plug-in.
Introduction ix
x Web Design with XHTML, HTML, and CSS - Level 2
LESSON 1
TOPIC A
Group Content
Web pages display content such as paragraphs of text, images, and hyperlinks. Sometimes you
need to apply a particular set of styles to several elements collectively or drill down to the
desired contents of a specific tag. In this topic, you will group content.
Suppose you want to apply certain styles to the first two paragraphs of your web page, or for-
mat particular letters or words in a paragraph. Using multiple inline styles is not good practice
as they are redundant and time-consuming to update, and they increase the likelihood of errors.
It would be far more convenient and efficient to apply the desired formatting to the specific
section of content in one go.
<div> Tags
The intent of the <div> container element, comprising an opening and closing tag, is to
enable web designers to logically group elements. In other words, it is used to divide one set
of related content from other content. These sections of content are called layers or logical
divisions. Formatting applied to a <div> tag is inherited by the elements it encapsulates. The
only visible effect of using the <div> element on its own is a line break at both the start and
end of the layer. This is because it is a block-level tag.
Child Elements
The elements within a container element, such as a <div> element, are its children or
child elements. The container element is the parent of these children. If any of these
child elements are container elements, they can contain child elements too.
overflow: visible; Instructs the browser to show all the content even if it overflows the area
of the container. This value is the default.
overflow: auto; Allows the browser to determine the best way to display all the content. If
the content extends beyond the size of the region, scroll bars are displayed.
If the content is small enough to fit within the region, it’s displayed nor-
mally.
<span> Tags
The <span> element, comprising an opening and closing tag, gives web designers a means to
group content without affecting page layout. Because it is an inline tag, browsers do not add
extra whitespace before or after it, as they would with block-level tags. You can apply CSS to
a <span> tag so that particular letters or words in your document are formatted as desired.
The style settings of the <span> tag override the styles these characters would normally
inherit from the tags that contain them or their parent elements.
Line breaks are not needed for grouping content using the <div> element. However, they help
make the code more readable.
Scenario:
You have created a few basic pages for the Everything for Coffee website. You have received
input that the year on the History page needs to be formatted so that it stands out and the
lengthy text on the Trademarks page should be made scrollable.
Line numbers have been provided, but if any extra lines are added to the code, these numbers will no longer be
accurate. Ensure that you type the code correctly; otherwise, the results of the activity will not match the solu-
tions provided. Notepad++ does not provide any tools to quickly locate typing errors.
1. Group the text “600 A.D.” within a. Choose Run→launch in IE to view the
<span> tags and format it. web page in Internet Explorer.
Code Sample 1
<p id="bodytext"><strong>History of Coffee</strong><br />
The origin of coffee dates back to <span class="special_formatting">600 A.D.
Code Sample 2
.special_formatting{
font-weight: bold;
font-style: italic;
font-size: 14px;
color: #990000;
}
</style>
Code Sample 3
<div id="bodytext">
<strong>Copyright</strong><br />
Code Sample 4
#bodytext{
width: 770px;
height: 250px;
overflow: auto;
padding-left: 10px;
}
e. Maximize Firefox.
TOPIC B
Create Box Layouts
You have grouped content in web pages. These sections of content should be positioned in a
logical and visually appealing manner. In this topic, you will create box layouts.
Your web page might have great content. But, it loses its edge if this content is not presented
clearly. More importantly, it could lose users’ attention. A well-designed layout with proper
spacing, positioning, and alignment engages users’ interest and is more likely to keep them on
your page.
Fluid Layouts
Fluid layouts have cross-browser compatibility issues. A fluid layout that looks great in
Firefox can look completely different in Internet Explorer. Issues vary with the brows-
er’s version as well.
Table Layouts
In the early days of web development, tables were a popular option for building lay-
outs. However, tables were never intended for this purpose and table layouts confuse
accessibility devices. Moreover, such layouts are difficult to update and their use is
discouraged. Web developers generally do not use them to create layouts.
Frames
Frames were used to create layouts that partition the browser window into independent
sections that can load different web pages. They are created by a frameset document,
an XHTML document in which the <body> tags are replaced by <frameset> tags,
that specifies how the browser window is to be divided. According to the XHTML 1.0
specification, frames are not valid under the strict and transitional DTDs. But the
frameset DTD allows you to use frames.
Since each frame loads a different page, they cause many problems. If you try pasting
a copied URL in a browser’s address bar, you simply open the frameset document, not
the appropriate pages within each frame. Similarly, they cause problems with book-
marks and launching a website from a search engine. They are difficult to print and are
problematic for accessibility devices. Furthermore, they increase the technical complex-
ity of a website. Thus, frames are considered bad practice and are not used to create
layouts.
Floating Content
Floating content is any content that appears next to an element in the browser. In order
to float on a particular side, the float property need not be applied to the content.
Consider a web page that has two <p> elements with some text. By default, they
would appear one below the other in the browser. Applying the style rule float:
left; to the first <p> element will make both <p> elements appear side-by-side,
although you have not set the float property for the second <p> element. So the
second <p> element is floating content even though the float property has not been
applied to it. If you apply the style rule clear: left; to the second <p> element
it would appear on the second line. Alternatively, applying the style rule clear:
right; to the first <p> element would have the same effect.
If inline styles have been set, you can set the clear property inline. However, it is better prac-
tice to use an embedded style sheet.
Scenario:
After taking a look at how the website is coming along, your manager asks you to organize the
content into a box layout for a more professional appearance. Your manager needs to approve
the layout before it is applied to all web pages of the website, so you will create a sample lay-
out comprising three rows for just one web page. Since the appearance of the web page will
require new style rules, you have deleted the unnecessary style rules in the embedded style
sheet.
1. Group content in layers correspond- a. Scroll down so that the closing </html>
ing to the header, footer, and parent tag is visible.
container.
b. Select the code in line 34, the line below
the <body> tag, and delete it.
c. Type
<div id="header" ⇒
title="Everything for ⇒
Coffee.com"> </div> to create a
layer that will replace the deleted code.
Code Sample 1
<body>
<p><img src="images/Banner1.png" alt="Everything For Coffee.com" width=
"778" height="152" /></p>
<div id="content">
Code Sample 2
<body>
<div id="header" title="Everything for Coffee.com"> </div>
<div id="content">
Code Sample 3
</div>
<hr /><p>
<a href="index.html">Home</a>
Code Sample 4
<body>
<div id="container">
Code Sample 5
</div>
</div>
<p class="footer-note">
Code Sample 6
#container{
width: 778px;
margin: 0 auto;
background-color: #FFFFFF;
}
</style>
Code Sample 7
#header{
width: 100%;
height: 151px;
float: left;
background: url(images/Banner1.png) no-repeat left top;
3. View the layout in Internet Explorer a. Launch the web page in Internet Explorer
and Firefox. and maximize the window.
Scenario:
After you submit your first layout design, your manager requests an alternative design so that
the clients can choose the layout they prefer. You decide to alter your first design by incorpo-
rating columns instead of rows below the header image. You have deleted the styles that will
not be required in this design.
1. Group content into two columns a. Scroll down so that the closing </html>
below the header. tag is visible.
Code Sample 1
<div id="content">
<div id="left_panel"> </div>
<h2>Copyright</h2>
Code Sample 2
<div id="content">
<div id="left_panel"> </div>
<div id="right_col">
<h2>Copyright</h2>
Code Sample 3
<div id="footer">
</div>
</div> <!--closing tag of the layer with id="container"-->
<p class="footer-note"><a href="index.html">Home</a> |<a href=
"copyright.html">Trademarks & Copyrights</a>
|<a href="history.html">History of Coffee</a>
This website represents a fictitious organization and is used for training
purposes.</p>
Code Sample 4
</div> <!--closing tag of the layer with id="content"-->
<hr />
<div id="footer">
</div>
</div> <!--closing tag of the layer with id="container"-->
Code Sample 5
#content{
width: 100%;
background-color: #FFFFFF;
clear: both;
}
Code Sample 6
#left_panel{
width: 196px;
height: 345px;
background-color: #88775B;
float: left;
}
</style>
Code Sample 7
#right_col{
width: 552px;
height: 300px;
padding-top: 15px;
padding-right: 15px;
4. View the layout in Internet Explorer a. Launch the file in Internet Explorer and
and Firefox. maximize the window.
e. Close Firefox.
Code Sample 8
<div class="clear"></div>
</div> <!--closing tag of the layer with id="content"-->
Code Sample 9
.clear{
clear: both;
}
</style>
ACTIVITY 1-4
Creating a Layout with a Header, Two Columns, and a
Footer
Data Files:
• copyright.html
Scenario:
The clients have seen both the layouts and they have requested a layout that combines features
from both of them. Specifically, they want the layout with columns modified to include the
footer from the first design.
1. Create the footer layer. a. Scroll down so that the closing </html>
tag is visible.
Code Sample 1
<div id="footer">
</div>
</div> <!--closing tag of the layer with id="container"-->
2. Place the hypertext links in the a. Click at the beginning of line 93, below
footer layer. the code <p class="footer-note">.
Code Sample 2
<div id="footer">
<a href="index.html">Home</a> |<a href="copyright.html"> ⇒
Trademarks & Copyrights</a>
|<a href="history.html">History of Coffee</a>
</div>
</div> <!--closing tag of the layer with id="container"-->
Code Sample 3
#footer{
color: #FFFFFF;
background-color: #3C0C0C;
text-align: center;
font-size: 11px;
line-height: 24px;
clear: both;
}
</style>
4. View the modified layout in Internet a. Launch the file in Internet Explorer and
Explorer and Firefox. maximize the window.
2. How will you use web page layouts to enhance the presentation of content in a web
page?
Managing CSS
In this lesson, you will manage CSS.
You will:
• Apply advanced CSS selectors.
• Create an external CSS.
• Apply a CSS to multiple pages.
• Apply browser-specific CSS.
• Provide alternate CSS.
TOPIC A
Apply Advanced CSS Selectors
CSS are used to control the visual appearance of all elements on a web page. Some situations
call for specific formatting of particular elements. In this topic, you will apply advanced CSS
selectors.
You might need to apply specific formatting to the first child element of every <div> tag, or
to the last child element of a certain element. Perhaps every child element of elements with a
particular id or class attribute requires unique formatting. In such cases, advanced selectors
allow you to easily refer to the elements that are to be formatted.
Selector Description
#myid p Selects any <p> element that is the child of an
element with id="myid". This selector is sup-
ported by IE 6 and IE 7.
.myclass p Selects any <p> element that is the child of an
element with class="myclass". This selector
is supported by IE 6 and IE 7.
* Selects all elements on the page. This selector is
supported by versions of IE below IE 7.
body > p Selects any <p> element that is a direct child of
the <body> element. It does not apply to a <p>
element within a <div> element in the <body>
section as it is not a direct child of the <body>
element. This selector is not supported by versions
of IE earlier than IE 7.
ACTIVITY 2-1
Applying Advanced CSS Selectors
Data Files:
• copyright.html
Scenario:
You have noticed that the hypertext links in the footer of the Trademarks page are the wrong
color. You need to correct this error in the file’s embedded CSS. You also decide to ensure that
the styles apply only to hypertext links in the page’s footer, in case other hypertext links are
later added to different sections of the web page that require different styles.
Code Sample 1
#footer a
</style>
Code Sample 2
#footer a{
color: #FFFFFF;
font-size: 11px;
text-decoration: none;
padding: 0 10px;
}
</style>
f. Close Firefox.
TOPIC B
Create an External CSS
You have applied advanced CSS selectors within an embedded CSS. However, consolidating
styles in one location is more efficient than implementing multiple style sheets. In this topic,
you will create an external CSS.
When each page contains the styles relevant to it, you are restricted to altering their appear-
ance individually. If the same styles have been applied to several pages, embedded style sheets
are redundant. Moreover, multiple styles in disparate locations are error prone and time con-
suming to debug and update. Placing all styles in a single consolidated location avoids such
difficulties.
External CSS
An external CSS is a file with the extension .css that contains styles to be applied to a web
page or multiple web pages. Styles in an external CSS are not enclosed within <style> tags.
In order to apply an external CSS to a web page, you must link it to the web page. An exter-
nal CSS can be linked to many web pages. You can also link multiple external CSS to the
same page. A change in the external CSS affects all the pages that are linked to it.
Early versions of browsers malfunctioned when they encountered CSS rules that they did not support. Such
browsers were also unable to recognize the @import rule, whereas more advanced browser versions could rec-
ognize it. Web designers took advantage of this functionality using the @import rule to hide style sheets from
browsers that did not support them. However, this is no longer an issue with current browser versions. So, the
@import rule is no longer used for this purpose.
Figure 2-2: Precedence of an inline style over embedded and external style sheets.
You can save the external CSS in another folder but it is usually saved in the same folder as the
web page.
5. In the .html file, delete the <style> element and all the styles within it.
6. Link the external CSS to the web page.
• In the <head> element below the <title> element, type
<link rel="stylesheet" type="text/css" href="filename.css" />
• In the <head> element below the <title> element, type
@import "filename.css";
• Or, in the <head> element below the <title> element, type
@import url(filename.css);
The code filename.css will have to include the relative path of the external CSS as well as
the file name if the external CSS is not in the same folder as the web page.
If the styles do not seem to be in effect, check the syntax of the code linking the external CSS to
the web page. If the syntax is correct and styles still seem to be missing when the page displays,
you have forgotten to add those styles to the external CSS. If you make a change in the external
CSS, you must save the style sheet before viewing the web page in a browser in order to see the
effect of this change.
Scenario:
Now that you have finalized the layout and style of the Trademarks page, the file contains a
lot of code corresponding to the style rules. You need to make this code more manageable so
that the appearance of the web page can be easily updated.
3. Link the external CSS to the web a. In the blank line above the closing
page. </head> tag, type
<link rel="stylesheet" ⇒
type="text/css" ⇒
href="style.css" />
Code Sample 1
<title>Trademarks | Everything for Coffee</title>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
Scenario:
You have applied the layout comprising a header, two columns, and a footer to all the pages of
your website, resulting in redundant styles in the embedded style sheets of the History and
Trademarks pages. Your manager asks you to make the styles of the website more efficient
and easier to update so that other developers can work on them as required.
1. View the History and Home pages in a. Launch the history.html file in Internet
Internet Explorer. Explorer and maximize the window.
3. Add the unique styles of the Home a. Select the index.html tab.
page to the external CSS.
b. Scroll down to line 80, the line with the
code #img1. The closing </style> tag
should also be visible.
5. Link the external CSS to the web a. In line 6, the blank line above the closing
pages. </head> tag, type
<link rel="stylesheet" ⇒
type="text/css" ⇒
href="style.css" />
Code Sample 1
<title>Home | Everything for Coffee</title>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
Code Sample 2
<title>History | Everything for Coffee</title>
<link rel="stylesheet" type="text/css" href="style.css" />
</head>
Conditional Comments
Conditional comments are comments used to demarcate code that targets or bypasses Internet
Explorer. They are supported by Internet Explorer 5 upwards. These comments can be included
in the <head> or <body> sections of XHTML documents. But they cannot be used in exter-
nal CSS.
Syntax Description
<!--[if IE]> The encapsulated code is executed only by IE, not
code for IE other browsers.
<![endif]-->
<!--[if gte IE 5.5]> The encapsulated code is executed by IE 5.5 and
code for IE 5.5 and higher higher versions of IE.
<![endif]-->
<!--[if gt IE 5.5]> The encapsulated code is executed by IE 6 and
code for IE 5.5 and higher higher versions of IE.
<![endif]-->
<!--[if lte IE 6]> The encapsulated code is executed by IE 6 and
code for IE 6 and lower lower versions of IE.
<![endif]-->
<!--[if lt IE 6]> The encapsulated code is executed by versions of
code for IE versions lower than 6 IE lower than IE 6.
<![endif]-->
<!--[if !IE]> The encapsulated code is ignored by IE as well as
code other browsers.
<![endif]-->
<!--[if !IE]> <--> The encapsulated code is ignored by IE. It is
code for browsers other than IE executed by browsers other than IE.
<!--> <![endif]--> You can also exclude the code <!--> before
<![endif]--> in the last line. This code has
been included in the last line as it affects the for-
matting of the code in Notepad++, making it
harder to read.
When a minor fix is required on a single page, an embedded style sheet is used because it
would be redundant to create another style sheet that is almost identical to the page’s
original style sheet. However, you can make the fix using another external CSS if you wish.
3. If you have made the fixes in an external CSS, link this new external CSS to a
web page that requires it.
4. Encapsulate the style sheet intended for Internet Explorer in a conditional com-
ment as follows.
<!--[if IE]>
code linking the style sheet for IE or embedded style sheet for IE
<![endif]-->
5. Encapsulate the style sheet intended for browsers other than Internet Explorer in a
conditional comment as follows.
<!--[if !IE]> <-->
code linking the style sheet for browsers other than IE or
embedded style sheet for browser other than IE
<!--> <![endif]-->
6. Save the web page.
7. If the issue is global, repeat this encapsulation within conditional comments for
all pages of the website and save the changes made.
8. View the web page(s) in different browsers to verify that the discrepancy has been
resolved.
Scenario:
The horizontal rule on the Trademarks page appears differently in Internet Explorer and
Firefox. You need to ensure that the horizontal rule looks the same in both browsers.
e. Close Firefox.
Code Sample 1
<!--[if !IE]> <-->
<style type="text/css">
</style>
<!--> <![endif]-->
</head>
c. Close Firefox.
5. Correct the amount of space above a. In line 24, the line below the code <h2>
the horizontal rule in the browser- Copyright</h2>, set the attribute
specific CSS. id="p1" for the <p> tag.
Code Sample 2
#p1{
padding-bottom: 8px;
}
</style>
<!--> <![endif]-->
TOPIC E
Provide Alternate CSS
You have applied browser-specific CSS to overcome a browser’s faulty rendering of CSS.
However, you should also take users with accessibility issues into consideration when design-
ing a website. In this topic, you will provide alternate CSS.
Some users with visual accessibility issues require larger font sizes and more spacing between
elements of a web page. A certain percentage of users will not perceive colors as intended.
They might not be able to distinguish between colors that are the same shade. You can help
such users access the content on your website by providing the choice of alternate styles that
cater to their requirements.
Alternate CSS
An alternate CSS is simply an external CSS linked with the rel attribute of the <link> tag
set to "alternate stylesheet". More than one alternate style sheet can be linked to a
web page. However, as they are mutually exclusive, only one can be applied to the web page
at a time. They can be used to provide a different color scheme or a high contrast look to your
web page, giving the user more control over the page’s appearance. The styles within an alter-
nate style sheet do not come into effect when the page loads in the browser window.
The alternate CSS does not have to be specified below the other style sheets. This positioning is
to place the code in logical order for readability.
4. If necessary, link more alternate CSS to the web page using the same syntax.
5. Set unique titles for each alternate CSS, if you wish to provide them as mutually
exclusive choices. If you want to apply several alternate CSS collectively, give
them the same title.
6. Save the web page.
7. Similarly, link the alternate CSS to the other pages of the website and save the
changes in their code.
8. Launch the web page in Firefox.
9. Choose View→Page Styles and choose the desired alternate CSS to modify the
web page’s appearance.
ACTIVITY 2-5
Providing an Alternate CSS
Data Files:
• index.html
• history.html
• copyright.html
• contrast.css
Scenario:
Your manager has asked you to make provisions for users with visual accessibility issues in
the Everything for Coffee website so that it reaches a wider audience. You have been provided
with a style sheet contrast.css, containing styles that cater to such users. You need to provide a
choice of styles for the website.
1. Link the alternate CSS to the pages a. In the index.html file, place the insertion
of the website. point at the end of line 6 and press Enter.
Line 6 contains the code linking the style
sheet style.css.
b. Type
<link rel="alternate ⇒
stylesheet" ⇒
type="text/css" ⇒
title="High Contrast" ⇒
href="contrast.css" /> to link the
alternate CSS to this web page.
Code Sample 1
<link rel="alternate stylesheet" type="text/css" ⇒
title="High Contrast" href="contrast.css" />
</head>
c. Close Firefox.
Lesson 2 Follow-up
In this lesson, you managed CSS. This facilitates efficient website design that is supported
across different browsers, reaching a wider audience.
1. Will implementing external CSS make your job easier? How?
Testing a Website
In this lesson, you will test a website.
You will:
• Test markup.
• Test CSS.
TOPIC A
Test Markup
Valid code is important to the quality of your website. However, most browsers overlook
errors in tags. In this topic, you will test markup.
Most browsers can successfully render incorrect markup, allowing errors to pass undetected.
Fortunately, there are validators that allow you to identify and fix such errors. This helps
ensure that your website contains valid markup that meets W3C standards.
Common Mistakes
Typing mistakes, incorrect syntax, and using deprecated code are the most common
mistakes made by web developers. The W3C validator is limited to identifying such
issues. If code is syntactically correct, but logically incorrect, the validator will not
spot the mistake. For example suppose you have specified the wrong path in an
<img> element’s src attribute, the validator will not be able to help you fix such a
mistake.
Although selecting all the web page’s code might include embedded CSS, this valida-
tion service ignores any CSS. So only the page’s markup is validated.
3. If necessary, click More Options and select the desired options for validation.
4. Click Check so that the results of validation are displayed.
5. Based on the validation results, fix any errors in the page’s markup, save the
changes, and try validating it again.
If you are validating markup by uploading the file or specifying the URL, you must save the
changes before validating again. However, when using the Direct Input facility, you do not have
to save the changes before validating the markup again, as you are copying the updated markup.
In this case, you can save the changes after the markup validates. The same goes for validating
CSS.
Scenario:
In the interest of future compatibility with evolving W3C standards, management has decided
to ensure that all projects contain XHTML that meets W3C standards. Your website should
contain markup that meets these standards and is displayed properly by browsers. As only one
page can be validated at a time, you will start with the Trademarks page.
3. Fix the errors in the page’s markup. a. In Internet Explorer, scroll down so that
the text “Validation Output: 13 Errors” is
visible.
e. Switch to Notepad++.
5. Fix the remaining errors in the a. Scroll down so that the text “Validation
markup. Output: 7 Errors” is visible at the top of
the window.
Certain browser versions might be unable to cope if a large chunk of code is pasted via the direct input facility.
In such cases, you can simply upload the file for validation.
3. If necessary, click More Options and select the desired options for validation.
4. Click Check so that the results of validation are displayed.
5. Based on the validation results, fix any errors in the CSS, save the changes, and
try validating it again.
Inline Styles
Inline styles are difficult to validate. You need to copy the code between the double
quotation marks of a tag’s style attribute and validate it by direct input.
ACTIVITY 3-2
Validating CSS
Data Files:
• style.css
• copyright.html
• index.html
• history.html
Scenario:
You have been temporarily assigned to a new project as the original developer is on leave for
a few days. The Everything for Coffee website is not displaying correctly in browsers and you
need to fix the problem before continuing with development. A colleague suggests using the
CSS validation service provided by the W3C to locate the source of the issue.
1. View the pages of the website in a. Launch the copyright.html file in Internet
Internet Explorer and Firefox. Explorer and maximize the window.
Code Sample 1
background-color: #3C0C0C;
text-align: center;
font-size: 11px;
Lesson 3 Follow-up
In this lesson, you tested a website. This helps you provide a better quality website with error-
free code that complies with W3C standards.
1. How will testing your website improve its quality?
2. What are the common syntax mistakes most web designers make?
Creating Advanced
Navigation
In this lesson, you will create advanced navigation.
You will:
• Create CSS-based menus from lists.
• Incorporate images in CSS-based menus.
• Create image maps.
TOPIC A
Create CSS-Based Menus
A means of navigation is essential for users to get from one page to another on your website.
However, you might wish to provide visitors with more structured navigation options that are
clearly visible. In this topic, you will create CSS-based menus.
Visitors to websites often waste a great deal of time trying to navigate to content they are
interested in, or simply trying to find their way around a website. Hypertext links are not par-
ticularly noticeable and could be overlooked, especially if the website contains a lot of textual
content. Moreover, they are not particularly feasible when sites comprise many pages. Provid-
ing clear-cut, well-positioned, and visually attractive navigation options is professional practice
that avoids such problems.
The same method is used to create both horizontal and vertical menus. Styles can control
whether the menu options are displayed horizontally or vertically.
The unordered list includes all the list items within it and the hypertext links in each list item.
3. If all menu options require submenus, this placement of list items in unordered
lists is not required but a class or id attribute set as parent_ul for the top-
level <ul> containing the main menu options.
4. Under the appropriate main menu option, create an unordered list for the
submenu.
5. Within the submenu unordered list, create list items containing the required
hyperlinks and set the same attribute class="myclass" for these hyperlinks.
6. Similarly, create the other submenus under the appropriate menu options. Set the
same attribute class="myclass" for the hyperlinks in these submenus.
7. Save the file.
8. Create a new external CSS to apply styles to the updated menu.
9. Apply styles to the main menu options that have submenus.
• Apply the following styles if some main menu options have submenus.
ul.myclass{
display: block;
position: relative;
list-style-type: none;
float: left;
width: value in pixels;
padding: value in pixels;
margin: value in pixels;
}
• Apply the following styles if all menu options have submenus.
ul.parent_ul li{
display: block;
position: relative;
list-style-type: none;
width: value in pixels;
padding: value in pixels;
margin: value in pixels;
}
If all main menu options have submenus, the selector will be ul.parent_ul ul. Although
the coordinates are absolute, they are absolute relative to the parent element because this parent
element has the setting position: relative;.
11. Apply styles to display the submenu when the mouse pointer is over the appropri-
ate main menu option.
li:hover ul{
display: block;
}
A more specific selector may be used if certain list items contain <ul> elements that have differ-
ent display settings.
12. Apply styles to set the appearance of the hyperlinks within the submenus. If nec-
essary, set styles for rollovers.
13. Save the external CSS and link it to the web page.
14. If necessary, link the external CSS to the other pages of the website and copy the
updated menu structure to these pages. Save the changes.
It is not possible to cover all possible methods of creating popup submenus in a single proce-
dure. This procedure attempts to list the generic steps involved when all main menu options
require submenus and when some main menu options require submenus. Different approaches
can be used.
Scenario:
There are many pages on the Everything for Coffee website, so you need to provide navigation
options that allow visitors to access them. You will provide these options on the Home page
and submit it for the manager’s approval before incorporating them in all pages of the website.
1. Add the navigation options to the a. Place the insertion point in line 13, the
Home page as an unordered list. blank line below <div id=
"left_panel">.
Code Sample 1
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="coffeemakers.html">Coffee Makers</a></li>
<li><a href="gourmetbeans.html">Gourmet Beans</a></li>
<li><a href="filtersandcups.html">Filters and Cups</a></li>
<li><a href="history.html">History of Coffee</a></li>
<li><a href="about.html">About Us</a></li>
</ul>
2. View the navigation options in a. Launch the file in Internet Explorer and
Internet Explorer. maximize the window.
Scenario:
Since there are many pages on the Everything for Coffee website, the client requests a menu
that groups the Coffee Makers, Gourmet Beans, and Filters and Cups pages under the menu
option Our Store. You decide to make the changes on one page so that the design can be
approved before it is applied to the entire website.
1. Add the hyperlinks corresponding to a. Place the insertion point in line 19, the
the submenu. blank line below <li><a href="#">
Our Store</a> and press Tab.
e. Type
<li><a class="menu" href=
"coffeemakers.html"> Coffee Makers
</a></li>to create a list item
containing a hyperlink to the
coffeemakers.html page.
Code Sample 1
<li><a href="#">Our Store</a>
<ul>
<li><a class="menu" href="coffeemakers.html">Coffee Makers</a></li>
<li><a class="menu" href="gourmetbeans.html">Gourmet Beans</a></li>
<li><a class="menu" href="filtersandcups.html">Filters and Cups</a></li>
</ul>
li:hover ul{
display: block;
}
The code in the step is specific to list items
that are children of <ul> with class=
"menu". The code in this note applies to all
list items irrespective of their parents. Both
selectors have the same effect because all ele-
ments are already displayed, except for the
submenu. So the submenu is made visible
when the mouse pointer is over Our Store and
no other element is affected. However, if certain
elements under list items are displayed as
inline elements, you would use the selector
with the class value.
Code Sample 2
ul.menu{
display: block;
position: relative;
list-style-type: none;
float: left;
width: 176px;
padding: 0px;
margin: 0px;
}
Code Sample 3
margin: 0px;
}
ul.menu ul{
position: absolute;
left: 160px;
top: -10px;
z-index: 10;
display: none;
margin: 0;
3. Link the new style sheet to the Home a. Select the index.html tab.
page.
b. Place the insertion point in line 7, the
blank line above the closing </head> tag.
If the web page contains an embedded style sheet, you do not have to open any other file.
6. If necessary, in the style sheet, delete any styles that are no longer required.
7. Create a selector for the first menu option based on the value of its class or id
attributes.
8. Under this selector, create styles that set the display property, the appearance
of the menu option’s text, its size, and its background image.
.classname{
display: block;
background-image: url(relative location of the file);
background-repeat: no-repeat;
background-position: left top;
}
Scenario:
You have received feedback from the client requesting the use of images to make the menu
options more attractive. The graphic designer has sent you the required images and you have
placed them in the images folder of the website.
1. Set class attributes for each menu a. In line 14, click after "index.html" and
option. press Spacebar.
Code Sample 1
outline: none;
}
.home_link{
display: block;
background-image: url(images/home_dn.jpg);
background-repeat: no-repeat;
background-position: left top;
width: 160px;
font-family: Arial, Helvetica, sans-serif;
font-size: 12px;
text-indent: 60px
height: 45px;
line-height: 45px;
color: #FFFFFF;
text-decoration: none;
}
Code Sample 2
text-decoration: none;
Code Sample 3
Code Sample 5
.gourmet_link{
display: block;
background-image: url(images/beans_dn.jpg);
Code Sample 6
.gourmet_link:hover{
}
.cups_link:hover{
}
.history_link{
}
.history_link:hover{
}
.about_link{
}
.about_link:hover{
}
Code Sample 8
.cups_link{
display: block;
background-image: url(images/cups_dn.jpg);
background-repeat: no-repeat;
Code Sample 9
.history_link{
display: block;
background-image: url(images/history_dn.jpg);
background-repeat: no-repeat;
Code Sample 10
.about_link{
display: block;
background-image: url(images/about_dn.jpg);
background-repeat: no-repeat;
Code Sample 11
.cups_link:hover{
display: block;
background-image: url(images/cups_up.jpg);
background-repeat: no-repeat;
Code Sample 12
.history_link:hover{
display: block;
background-image: url(images/history_up.jpg);
background-repeat: no-repeat;
Code Sample 13
.about_link:hover{
display: block;
Image Maps
Definition:
An image map is a graphic within which sections have been coded to behave as
hyperlinks to different locations. These clickable sections are known as hotspots and
they may be circular, rectangular, or polygonal. An image map must contain at least
one hotspot. Specifying a circular hotspot requires the coordinates of its center and the
value of its radius. A rectangular hotspot requires the top-left and bottom-right coordi-
nates of the shape within the image. A polygonal hotspot requires the coordinates of
each vertex in clockwise order.
Example:
The <img> element requires an alt attribute for the file to validate successfully. Since alt text is usually pro-
vided for each hotspot, and we do not want Internet Explorer to display a tooltip for sections of the image other
than hotspots, a blank alt attribute is set.
The blank alt attribute is required for the file to validate successfully. The value of the usemap
attribute must start with #.
Hotspot Coordinates
Creating an image map requires the coordinates of its hotspots. You can get these coor-
dinates by opening the image in a graphics editing software such as Microsoft® Paint,
and placing the mouse pointer over a particular point. The coordinates of this point
will be displayed on the status bar at the bottom of the window. You can note down all
the required coordinates and use them to create the hotspots.
ACTIVITY 4-4
Creating an Image Map
Data Files:
• index.html
• coordinates.txt
• home_1.png
Scenario:
The client has requested that you make the Home page more fun and interactive. A colleague
suggests using an image map. The graphic designer has created an image and sent you the
coordinates of the hotspots. You have saved these coordinates in a .txt file along with other
details.
1. In the Home page, add the image to a. Place the insertion point at the end of line
be used as the image map. 12 after the code <div id="img1">.
b. Type
<img src="images/home_1.png" alt=
"" width="778" height="353" /> to
display the image home_1.png in this
page.
Code Sample 1
<area shape="rect" coords="" href="history.html" alt="History" />
<area shape="rect" coords="" href="coffeemakers.html" alt="Coffee Makers" />
<area shape="circle" coords="" href="gourmetbeans.html" alt="Gourmet Beans"
/>
<area shape="poly" coords="" href="about.html" alt="About Us" />
<area shape="poly" coords="" href="filtersandcups.html" alt="Cups" />
</map>
Lesson 4 Follow-up
In this lesson, you created advanced navigation. This provides a website’s visitors with an easy
means to browse to different locations within the website without getting lost.
1. How would you use CSS-based menus to enhance a website’s navigation?
Incorporating Meta-
Content and Multimedia
In this lesson, you will incorporate meta-content and multimedia.
You will:
• Refresh and redirect pages.
• Link media to a web page.
• Embed media in a web page.
TOPIC A
Refresh and Redirect Pages
Interactive, rich content enhances the appeal of your website. However, you would not want
users looking at stale versions of your website when updated content is available. In this topic,
you will refresh and redirect pages.
Pages on the Internet do not remain unchanged, they get updated periodically with new con-
tent. When updates happen every few minutes, users stand a chance of missing this new
content unless the page is refreshed. But stale news is not as bad as losing your address on the
Internet. This is a very real possibility in the event of your website shifting to another URL,
particularly if the new URL is a lengthy string that is hard to remember. Fortunately, you can
point users to the new URL from the old one rather than expecting them to memorize the
address.
<meta> Tags
The <meta> tag is an element that must be placed in the <head> section of an XHTML
document. Though it does not have a closing tag, it must be properly closed. The
http-equiv attribute can be set to refresh. The content attribute specifies the refresh
rate in seconds. The page reloads periodically in the browser window based on the refresh rate.
The content attribute also allows you to specify an address to which the page gets redi-
rected after a set time period.
However, browsers allow users to disable the refresh triggered by a <meta> tag so that the web page would not
be able to refresh or redirect.
3. In the <body> section, provide a hyperlink to the address that the page should
redirect to.
The hyperlink is provided in case a user has automatic refresh by <meta> tags disabled in the
browser.
Scenario:
The content on the About Us page will be updated periodically with new content. To ensure
that users see this updated content sooner rather than later, you decide to make the page
refresh itself periodically. After writing the code, you will test the web page to make sure it
works.
1. Add code to refresh the About Us a. In line 5, place the insertion point after
page every 10 seconds. the closing </title> tag. Press Enter to
create a blank line.
c. Switch to Notepad++.
Scenario:
The Everything for Coffee website has moved to another address, so you need to redirect users
from the old address to the new one. You should also provide a hyperlink to the new address
in case a user’s browser does not allow automatic refresh from <meta> tags.
1. Add code that redirects the web page a. In line 5, place the mouse pointer after
to the new address. the closing </title> tag. Press Enter to
create a blank line.
b. Type
<meta http-equiv="refresh"
content="5; url=
http://www.everythingforcoffee.com" />
so that the page gets redirected to the
specified address after five seconds.
d. Type
<a href=⇒
"http://www.everythingforcoffee.com">
TOPIC B
Link Media
You have refreshed and redirected pages on your website. In addition to providing up-to-date
content, you might wish to add interactive content that captures the user’s attention to your
web page. In this topic, you will link media.
Images and words are the basic means of presenting content. Now, add sound and video to the
mix. This makes for a far more interesting, interactive, and attractive web page that is likely to
keep visitors coming back.
RealPlayer
RealPlayer is a popular player. It has its own proprietary formats, but it can also play
other file formats that are commonly used.
ACTIVITY 5-3
Linking a Media File
Data Files:
• about.html
• video.wmv
Scenario:
In order to make the website more attractive so that visitors come back to it, the client has
decided to incorporate a video file. This file will be available on the About Us page, and you
have placed this file in the media folder of the website.
1. Create a hyperlink that links the a. Place the insertion point at the end of line
video file to the About Us page. 25 and press Enter. Line 25 contains the
code <p>Enjoy the taste of
Everything for Coffee!</p>.
b. Type
<a href="media/video.wmv">⇒
Click here for a video clip.</a>
to create a hyperlink to the video file.
2. View the updated web page in a. Launch the file in Internet Explorer and
Internet Explorer. maximize the window.
Plug-ins
A plug-in extends the functionality of a software application. Browsers require plug-ins to play
media files that have been embedded in web pages. The plug-in required depends on the for-
mat of the embedded media file. In some cases, different browsers may use different plug-ins
to play the same format, such as MP3 files. Files with the extension .swf require the Adobe
Flash Player plug-in. However, plug-ins are usually browser specific. So there is a Flash Player
plug-in for Internet Explorer and another plug-in by the same name for Firefox. Sometimes
installing the appropriate player provides the plug-ins needed. This is the case with Apple’s
QuickTime Player and MOV files. Some plug-ins are provided by default; for instance, most
systems have an older version of the Flash Player plug-in for Internet Explorer.
Streaming
When a web page contains a hyperlink to a media file, the file downloads to a user’s computer
and plays after the download is complete. When media files are available from a server, they
can be streamed. Streamed media files start playing as they download instead of waiting for the
entire file to download before playback begins. The advantage of streaming is that media files
do not get saved locally on a user’s machine. However, a user’s Internet connection must have
sufficient bandwidth to support streaming. Bandwidth is the amount of data transmitted per
unit of time.
Compression
Since media files are usually quite large, they are compressed before transmission and
de-compressed at the receiving end. If files are not compressed, far too much band-
width would be required to download the file.
Setting width="320" and height="45" displays only the controls of the Windows Media
Player as there is no video to be seen.
You need to provide a <param> tag because not all browsers understand the data attribute of
the <object> element.
Change the value of the codebase attribute to the version of Flash Player you require.
2. Two lines below the opening <object> tag, type </object> to close the ele-
ment.
3. Place the insertion point in the blank line within the <object> element.
4. Type <param name="src" value="relative location of the
file" /> to specify the file to be embedded.
5. If necessary, in the next line, type <param name="quality" value=
"high" /> to set the quality of the file.
6. In the next line, create an <object> element that Firefox recognizes within the
first <object> element. Hide the element from Internet Explorer using a condi-
tional comment.
<!--[if !IE]> <-->
<object data="relative location of the file" width="numeric
value" height="numeric value" type=
"application/x-shockwave-flash">
<param name="quality" value="high" />
</object>
<!--> <![endif]-->
Scenario:
The client has requested that the video file play in the web page instead of opening locally on
a user’s computer. This prevents users from saving a local copy of the file. You need to make
this change in the About Us page.
1. In the About Us page, delete the a. In line 26, select the code
hyperlink to the video file.
<a href="media/video.wmv"> ⇒
Click here for a video clip.</a>
Code Sample 1
<p>Enjoy the taste of Everything for Coffee!</p>
<a href="media/video.wmv">Click here for a video clip.</a>
</div>
d. Type
<param name="src" ⇒
value="media/video.wmv" /> to
specify the location of the video file to be
embedded in the web page.
f. Type
<param name="autostart" ⇒
value="false" /> so that the video file
does not start playing when the page
loads.
Code Sample 2
<param name="autostart" value="false" />
<param name="ShowControls" value="true" />
</object>
ACTIVITY 5-5
Embedding an MP3 File
Data Files:
• about.html
• coffee.mp3
Scenario:
The client has decided that regularly updating the content of the About Us page will draw
visitors back to the website. They have provided an audio file to replace the embedded video
file. You have placed this file in the website’s media folder.
1. In the About Us page, update the a. In line 26, select the opening <object>
code to embed the audio file. tag and delete it.
b. Type
<object ⇒
standby="Loading audio..." ⇒
type="application/x-mplayer2" ⇒
data="media/coffee.mp3" The type
attribute tells the browser to use Win-
dows Media Player to play the file, and
the data attribute specifies the path to
the file.
Code Sample 1
<p>Enjoy the taste of Everything for Coffee!</p>
<object width="320" height="240" standby="Loading video..." type=
"video/x-ms-wmv">
<param name="src" value="media/video.wmv">
Code Sample 2
width="320" height="45" >
<param name="src" value="media/coffee.mp3">
<param name="autostart" value="false">
Code Sample 3
2. View the About Us page in Internet a. Launch the file in Internet Explorer and
Explorer. maximize the window.
ACTIVITY 5-6
Embedding an MOV File
Data Files:
• about.html
• code.txt
• coffee.mov
Scenario:
After a week, the client provides a QuickTime movie to be placed on the About Us page. You
have placed it in the website’s media folder and deleted the code that embedded the audio file
in the About Us page. You have documented the values required for the classid and
codebase attributes.
1. Create an <object> element and a. Place the insertion point in line 26, the
set its classid and codebase blank line below <p>Enjoy the taste
attributes. of Everything for Coffee!</p>.
Code Sample 1
<p>Enjoy the taste of Everything for Coffee!</p>
<object classid=""
codebase="">
</object>
Code Sample 2
<object classid="clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B"
codebase="http://www.apple.com/qtactivex/qtplugin.cab" width="320" height=
"255">
</object>
b. Type
<param name="src" ⇒
value="media/coffee.mov" /> This tag
specifies the media file to be embedded.
d. Type
<param name="autostart" ⇒
value="false" /> so that the movie
does not start playing when the page
loads.
Code Sample 3
codebase="http://www.apple.com/qtactivex/qtplugin.cab" width="320" height=
"255">
<param name="src" value="media/coffee.mov" />
<param name="autostart" value="false" />
</object>
Code Sample 4
<param name="autostart" value="false" />
<object>
</object>
</object>
Code Sample 5
<object type="video/quicktime" data="media/coffee.mov" width="320" height=
"255" id="IEhide">
</object>
</object>
Code Sample 6
<object type="video/quicktime" data="media/coffee.mov" width="320" height=
"255" id="IEhide">
<param name="autostart" value="false" />
</object>
Code Sample 7
<link rel="stylesheet" type="text/css" href="style.css" />
<!--[if IE]>
<style type="text/css">
</style>
<![endif]-->
</head>
Code Sample 8
<style type="text/css">
#IEhide{ display: none;}
</style>
Scenario:
The client has asked for the banner image at the top of each page to be animated so that the
website is more attractive and appealing. You have placed the animated SWF file in the media
folder. You decide to embed the file on the Home page for the client’s approval rather than
embedding it in every web page.
1. In the Home page, create an a. Place the insertion point in line 11, the
<object> element and set its blank line below <div id="header"
attributes. title="Everything for
Coffee.com">.
b. Type
<object type=
"application/x-shockwave-flash" ⇒
data="media/topBanner.swf" ⇒
width="779" height="180">
Code Sample 1
<div id="header" title="Everything for Coffee.com">
<object type="application/x-shockwave-flash" data="media/topBanner.swf"
width="779" height="180"
classid=""
codebase="">
c. Type
<param name="quality" ⇒
value="high" /> to set the quality of
the embedded file.
Code Sample 2
<param name="quality" value="high" />
<!--> <![endif]-->
Code Sample 3
<!--[if !IE]> <-->
<object data="media/topBanner.swf" width="779" height="180" ⇒
type="application/x-shockwave-flash">
</object>
<!--> <![endif]-->
g. Close Firefox.
Lesson 5 Follow-up
In this lesson, you incorporated meta-content and multimedia. This ensures that your website
offers engaging, up-to-date content that helps make your website more successful by drawing
visitors back to it.
1. What circumstances would prompt you to periodically refresh a web page?
2. What are the different ways in which you can use CSS to enhance your website?
3. How would you design a website that draws visitors back to it?
What’s Next?
Web Design with XHTML, HTML, and CSS - Level 3 is the next course in this series.
139
NOTES
LESSON LABS
Due to classroom setup constraints, some labs cannot be keyed in sequence immediately fol-
lowing their associated lesson. Your instructor will tell you whether your labs can be practiced
immediately following the lesson or whether they require separate setup from the main lesson
content. Lesson-level lab setup information is listed in the front of this manual in the course
setup section.
LESSON 1 LAB 1
Creating Web Page Layouts
Activity Time:
20 minutes
Data Files:
• index.html
Scenario:
The graphic designer has finalized the look of the home page of the Citizens Information Cen-
ter website and the client has approved the design. You need to code the home page to match
the design’s layout comprising a header with an image, a navigation row containing
hyperlinks, and a third layer for the remainder of the content; all centered within the browser
window.
1. Group content into four layers with id attributes set as container, header,
navigation, and content.
Comments have been provided in the data file to help you create the layers in the correct locations.
3. Within the <style> element, delete the styles under the selectors
p.content_txt and p#colorstrip.
4. Apply styles to the <span> element with class="spl_format" so that the text
is 12 px, bold, and its color is #061B61.
5. Apply styles to the <body> element so that its margins and padding are 0. Set a
repeating background image using the settings given below.
6. Apply styles to the layer with id="container" using the settings given in the
table.
7. Apply styles to the layer with id="content" so that its width, height, and pad-
ding are 758 px, 310 px, and 10 px, respectively. No floating content should be
allowed on both sides of the layer.
11. Apply styles to the layer with id="navigation" to set its height as 22 px and its
background color as #E3E3E3. No floating content should be allowed on both
sides of the layer and the text should be bold.
12. Apply styles to the horizontal rule using the settings given in the table.
13. Save the file and view the web page in Internet Explorer.
LESSON 2 LAB 1
Managing CSS
Activity Time:
5 minutes
Data Files:
• index.html
• contact.html
Scenario:
Your manager has asked you to separate styles from content and reduce the amount of code in
the website if possible, so that the code can be managed more efficiently. A colleague suggests
using advanced CSS selectors to reduce the number of id or class attributes in the web
pages.
2. Copy all the code within the <style> element and save it in an external CSS
named style.css in the same folder as the web pages.
3. In index.html, delete the embedded style sheet, link the external CSS to the web
page, and save the file.
4. Similarly, in contact.html, replace the embedded style sheet with a link to the
external CSS, and save the file.
LESSON 3 LAB 1
Testing a Website
Activity Time:
10 minutes
Data Files:
• index.html
• contact.html
• style.css
Scenario:
Due to a quality decision by management, all websites must be validated using the W3C®
Markup Validation Service as well as the W3C® CSS Validation Service. You must also make
sure that website is displayed properly by the browser.
1. Validate the markup of the contact.html file using the Direct Input facility of the
W3C® Markup Validation Service.
4. Validate the code of the style.css file using the file upload facility of the W3C®
CSS Validation Service.
5. Identify the error based on the validation output, fix the error, save the changes,
and validate the styles again.
6. View the pages of the website in Internet Explorer to verify that they are dis-
played as intended.
LESSON 4 LAB 1
Creating Advanced Navigation
Activity Time:
15 minutes
Data Files:
• index.html
• style.css
• coordinates.txt
Scenario:
The Citizens Information Center website is complete in terms of content, but the navigation
options, comprising hypertext links in an unordered list, need to be enhanced for a more pro-
fessional appearance. The client has also requested the use of images as a means of navigation
so that the website is more interactive.
2. Apply the style line-height: 45px; to the list items in the unordered list.
3. Apply styles to the anchor tags that are children of the list items in the unordered
list, which is in turn a child of an element with id="left_col" using the set-
tings given in the table. On rollover, the color of the hyperlinks should change to
#E88725.
5. In the index.html file, in the layer with id="img_map", create an image map
with polygonal hotspots that link to the contact.html and newsroom.html web
pages, using the coordinates from the coordinates.txt file.
6. Save the index.html file and launch it in Internet Explorer. Test the menu options
and the image map.
Data Files:
• newsroom.html
• index.html
• audio.mp3
Scenario:
Since the content on the Newsroom page will be updated periodically, the client has requested
that the web page get refreshed automatically every 6 seconds. To enhance the interactivity and
appeal of the website, the client has also provided an audio file to be embedded on the Home
page.
1. In the newsroom.html file, add code that refreshes the web page every 6 seconds
and save the file.
2. In the index.html file, add code that embeds the audio file so that it starts playing
in Windows Media Player when the web page loads.
3. Save the index.html file and launch it in Internet Explorer to listen to the audio
file.
4. Navigate to the Newsroom page to view the green bar that appears on the status
bar when the page gets refreshed every 6 seconds.
Solutions 149
NOTES
GLOSSARY
alternate CSS persistent style sheet
An external CSS linked with the rel attribute A style sheet linked with the default syntax of
of the <link> tag set to “alternate stylesheet”. the <link> tag.
image map
A graphic within which sections have been
coded to behave as hyperlinks to different
locations.
Media MIME types
(Multipurpose Internet Mail Extensions) Iden-
tify the file format of media files embedded in
web pages.
Glossary 151
NOTES
INDEX
A S
alternate CSS, 54 streamed media files, 119
style sheets
C persistent, 38
conditional comments, 48 preferred
CSS menus, 75
T
E tags
external CSS, 37, 39 <div>, 2
<link>, 38
F
<span>, 5
floating content, 14
frames, 12 W
W3C® CSS Validation Service, 68
H
W3C® Markup Validation Service, 62
hotspots, 102
Z
I
z-index, 14
image maps, 102
@import rule, 38
L
layouts
fixed, 11
fluid
box
M
<meta> tags, 110
multimedia, 115
P
plug-ins, 118
properties
clear, 13
display, 74
overflow, 3
position, 13
Index 153