HTML & CSS Design & Build Websites-J. Duckett
HTML & CSS Design & Build Websites-J. Duckett
Published by 00818-8
John Wiley & Sons, Inc. 10475 Crosspoint Boulevard Indianapolis, IN 46256 Manufactured in the United States of America Published simultaneously in
www.wiley.com Canada
©2011 by John Wiley & Sons, Inc., Indianapolis, Indiana ISBN: 978-1-118- 10 9 8 7 6 5 4 3 2 1
No part of this publication may be reproduced, stored in a retrieval system or transmitted in any form or by any means, electronic,
mechanical, photocopying, recording, scanning or otherwise, except as permitted under Sections 107 or 108 of the 1976 United States
Copyright Act, without either the prior written permission of the Publisher, or authorization through payment of the appropriate per-copy
fee to the Copyright Clearance Center, 222 Rosewood Drive, Danvers, MA 01923, (978) 750-8400, fax (978) 646-8600. Requests to the
Publisher for permission should be addressed to the Permissions Department, John Wiley & Sons, Inc., 111 River Street, Hoboken, NJ
07030, (201) 748- 6011, fax (201) 748-6008, or online at http://www.wiley.com/go/permissions.
Limit of Liability/Disclaimer of Warranty: The publisher and the author make no representations or warranties with respect
to the accuracy or completeness of the contents of this work and specifically disclaim all warranties, including without limitation
warranties of fitness for a particular purpose. No warranty may be created or extended by sales or promotional materials. The advice
and strategies contained herein may not be suitable for every situation. This work is sold with the understanding that the publisher is
not engaged in rendering legal, accounting, or other professional services. If professional assistance is required, the services of a
competent professional person should be sought. Neither the publisher nor the author shall be liable for damages arising herefrom.
The fact that an organization or Web site is referred to in this work as a citation and/or a potential source of further information does
not mean that the author or the publisher endorses the information the organization or website may provide or recommendations it
may make. Further, readers should be aware that Internet websites listed in this work may have changed or disappeared between
when this work was written and when it is read.
For general information on our other products and services please contact our Customer Care Department within the United States at
(877) 762-2974, outside the United States at (317) 572-3993 or fax (317) 572-4002.
Wiley also publishes its books in a variety of electronic formats. Some content that appears in print may not be available in electronic
Trademarks: Wiley and the Wiley logo are trademarks or registered trademarks of John Wiley & Sons, Inc. and/or its
affiliates, in the United States and other countries, and may not be used without written permission. All other
trademarks are the property of their respective owners. John Wiley & Sons, Inc. is not associated with any product or
vendor mentioned in this book.
For John Wiley & Sons, Inc. Vice President and Author
Executive Publisher Jon Duckett
Executive Editor Barry Pruett
Carol Long Cover Designer
Associate Publisher Emme Stone
Marketing Manager Ashley Zurcher Jim Minatel
Design and Layout Jon Duckett
Production Manager Tim Tate Production Coordinator, Cover Emme Stone
Katie Crocker
PRODUCTION EDITOR Technical Editor Chris Mills
Daniel Scribner
TECHNICAL REVIEWERS Andy Stone
Vice President and Angela Shimell
Executive Group Publisher Richard Swadley Donna Watson
Martin Callanan
Rob Jacoby Photography flickr.com/photos/mindfire Jules Clancy
Tony Berry John Stewardson thestonesoup.com
Credits
johnstewardson.com Kylie Gusset
gusset.net
Additional Photography Hesperian Michael Stillwell
Joe Robertson beebo.org
Try out and download all of the code for this book
online at: http://www.htmlandcssbook.com/code/
Introduction 2
Chapter 1: Structure 12
Chapter 2: Text 40
Chapter 3: Lists 62
Chapter 4: Links 74
Chapter 5: Images 94
Chapter 6: Tables 126
Chapter 7: Forms 144
Chapter 8: Extra Markup Chapter 9: Flash, 176
Video & Audio Chapter 10: Introducing CSS 200
Chapter 11: Color 226
Chapter 12: Text 246
Chapter 13: Boxes 264
Contents 300
Chapter 14: Lists, Tables & Forms Chapter Chapter 17: HTML5 Layout Chapter 18:
15: Layout Process & Design Chapter 19: Practical
Chapter 16: Images Information Index
330 358 406 428 452 476 493
Introduction
⇪
About this book
⇪
How the web works
⇪
Learning from other pages
Firstly, thank you for picking up this
book. It has been written with two
very different types of people in
mind:
●
Those who want to learn how to design and build
websites from scratch
●
Anyone who has a website (that may be built using a
content management system, blogging software, or
an e-commerce platform) and wants more control
over the appearance of their pages
The only things you need in order to use this book are
a computer with a web browser and a text editor
(such as Notepad, which comes with Windows, or
TextEdit, which comes with Macs).
3 INTRODUCTION
Introduction pages come at the beginning of each chapter. The HTML code is shown in blue and CSS code is shown in
They introduce the key topics you will learn about. pink.
Reference pages introduce key pieces of HTML & CSS code.
Background pages appear on white; they explain the context of background. They provide a simple, visual reference to topics
the topics covered that are discussed in each chapter. discussed.
Diagram and infographics pages are shown on a dark
Example pages put together the topics you have learned and Summary pages come at the end of each chapter. They remind
demonstrate how they can be applied in each. you of the key topics that were covered in each chapter.
INTRODUCTION 4
Is it hard to Learn?
Many books that teach HTML and CSS redesigned this book from scratch.
resemble dull manuals. To make it easier I've focussed on the code you need to use 90% of the time and
omitted the code that you would rarely see even if writing websites
for you to learn, we threw away the is your full time job. By the end of the book, if you come across the
traditional template used by publishers and other 10% you will be able to Google it to find out what it means
quickly and easily.
At work, when people look at my screen Understanding HTML and CSS can help I have also added practical information
and see it full of code, it's not unusual to anyone who works with the web; on topics I am commonly asked about,
get a comment about it looking very designers can create more attractive such as how to prepare images, audio
complicated or how clever I must be to and usable sites, website editors can and video for the web, how to approach
understand it. The truth is, it's not that create better content, marketers can the design and build of a new site, how
hard to learn how to write web pages and communicate with their audience more to improve your rankings in search
read the code used to create them; you effectively, and managers can engines (SEO), and how to use Google
certainly don't have to be a commission better sites and get the best Analytics to learn about visitors to your
"programmer." out of their teams. site.
5 INTRODUCTION
where a paragraph begins and ends, I should warn you that the examples in
1: HTML and so on. the first nine chapters are not exciting to
We will spend the first chapter looking look at, yet they are the foundation of
at how HTML is used to create web The rest of this section every web page. The following chapters
pages. You will see that you start by introduces the tags you have at your on CSS will show you how to make your
writing down the words you want to disposal to create web pages, grouped pages look a lot more interesting.
appear on your page. You then add
tags or elements to the words so that
into chapters on: text, lists, links,
images, tables, forms, video audio and
2: CSS
the browser knows what is a heading, flash, and miscellaneous elements. We start this section with a chapter that
explains how CSS uses rules to enable Layout: How to control where the development at the time of writing).
you to control the styling and layout of different elements are positioned on the Before learning about these elements,
web pages. We then go on to look at screen. You will also learn several you need a good grasp of how CSS is
the wide variety of CSS properties you techniques that professionals use to used to control the design of web pages.
can use in your CSS rules. These make their pages more attractive. There is a chapter that talks you through
properties generally fall into one of two a design process that you might like to
categories:
3: Practical follow when creating a new website.
We end up with some helpful information
Presentation: How to control things that will assist you in building better Finally, we end up looking at topics
like the color of text, the fonts you want websites. that will help you once you have built
to use and the size of those fonts, how your site, such
to add background colors to pages (or We look at some new tags that will be as putting it on the web, search engine
parts of a page), and how to add introduced in HTML5 to help describe optimisation (SEO) and using analytics
background images. the structure of your pages. HTML5 is software to track who comes to your site
the latest version of HTML (still under and what they are looking at.
INTRODUCTION 6
How People
Access the Web
Browsers functionality offered in all browsers. use the services of a web hosting
company who charge a fee to host
People access websites using software You will learn how to tell which your site.
called a web browser. Popular browsers visitors use to access your
examples include Firefox, Internet website in Chapter 19.
Explorer, Safari, Chrome, and Opera. Devices
Web Servers
People are accessing websites on an
In order to view a web page, users When you ask your browser for a web increasing range of devices including
might type a web address into their page, the request is sent across the desktop computers, laptops, tablets, and
browser, follow a link from another site, Internet to a special mobile phones. It is important to
or use a bookmark. computer known as a web server remember that various devices have
which hosts the website. different screen sizes and some have
Software manufacturers regularly faster connections to the web than
release new versions of browsers with Web servers are special others.
new features and supporting new computers that are constantly connected Screen readers
additions to languages. It is important, to the Internet, and are optimized to
however, to remember that many send web pages out to people who Screen readers are programs that read
computer owners will not be running request them. out the contents of a computer screen
the latest versions of these browsers. to a user. They are commonly used by
Therefore you cannot rely on all visitors Some big companies run their own people with visual impairments.
to your site being able to use the latest web servers, but it is more common to
In the same way that many countries Throughout this book you will see It is interesting to note that technologies
have legislations that require public several references to screen readers. similar to those employed by screen
buildings to be accessible to those with These notes will help ensure that the readers are also being used in other
disabilities, many laws have also been sites you create are accessible to people areas where people are unable read a
passed that require websites be who use such software. screen, such as when they are driving
accessible to those with disabilities. or jogging.
7 INTRODUCTION
How Websites
Are Created
What you see How it is Created book should be enough to help you on
that road.
When you are looking at a website, it Small websites are often written just
HTML5 & CSS3
is most likely that your browser will be using HTML and CSS.
receiving HTML and CSS from the Since the web was first created there
web server that hosts the site. The Larger websites — in particular those have been several versions of HTML
web browser interprets the HTML and that are updated regularly and use a and CSS — each intended to be an
CSS code to create the page that you content management improvement on the previous version.
see. system (CMS), blogging tools, or e-
commerce software — often make use At the time of writing this book, HTML5
Most web pages also include extra of more complex technologies on the & CSS3 were still being developed.
content such as images, audio, video, or web server, but these technologies are Although they had not been finalized,
animations and this book will teach you actually used to produce HTML and many browsers were already
how to prepare them for use on the web CSS that is then sent to the browser. So, supporting some features of these
and then how to insert them into your if your site uses these technologies, you languages and a lot of people were
web pages. will be able to use your new HTML and using the latest code on their websites.
CSS knowledge to take more control I have therefore chosen to teach you
Some sites also send JavaScript or over how your site looks. these latest versions.
Flash to your browser, and you will see
how to add JavaScript and Flash in your Larger, more complex sites like these Because HTML5 and CSS3 build on
web pages. Both of these technologies may use a database to store data, and previous versions of these languages,
are advanced topics that you can go on programming languages such as PHP, learning these means you will also be
to learn more about once you have ASP.Net, Java, or Ruby on the web able to understand the earlier versions
mastered HTML and CSS, if you want server, but you do not need to know of them. I have added clear notes when
to. these technologies to improve what the the code is new and also when it might
user sees. The skills you'll learn in this not work in older browsers.
INTRODUCTION 8
How the Web Works
On this page you can see examples that ● when a web user in England wants to
A user in New York visits google.com
demonstrate how the web server that in San Francisco view the website of the Louvre art
hosts the website you are visiting can gallery in France which is located at
●
be anywhere in the world. It is the DNS A user in Stockholm visits www.louvre.fr. Firstly, the browser in
servers that tell your browser how to find qantas.com.au in Sydney Cambridge contacts a DNS server in
the website. London. The DNS server then tells the
●
●
A user in Barcelona visits sony.jp in A user in Vancouver visits airindia.in browser the location of the web server
Tokyo in Bangalore hosting the site in Paris.
On the right you can see what happens
9 INTRODUCTION
1 The unique number that the DNS server returns to your computer
allows your browser to contact the web server that hosts the
When you connect to the web, you do so via an Internet Service website you requested. A web server is a computer that is
Provider (ISP). You type a domain name or web address into your constantly connected to the web, and is set up especially to send
browser to visit a site; for example: google.com, bbc.co.uk, web pages to users.
microsoft.com. 2
Structure
1
⇪
Understanding structure
⇪
Learning about markup
⇪
Tags and elements
We come across all kinds of
documents every day of our lives.
Newspapers, insurance forms, shop
catalogues... the list goes on.
Many web pages act like electronic versions of these
documents. For example, newspapers show the same
stories in print as they do on websites; you can apply for
insurance over the web; and stores have online catalogs
and e-commerce facilities.
In all kinds of documents, structure is very important in
helping readers to understand the messages you are trying
to convey and to navigate around the document. So, in
order to learn how to write web pages, it is very important
to understand how to structure documents. In this chapter
you will:
●
See how HTML describes the structure of a web page
●
Learn how tags or elements are added to your
13 STRUCTURE
STRUCTURE 14
15 STRUCTURE
STRUCTURE 16
Structuring Word
Documents
The use of headings and subheadings This might be expanded upon under have a heading to describe what it
in any document often reflects a subheadings lower down on the page. covers.
hierarchy of information. For example, When using a word processor to create On the right, you can see a simple
a document might start with a large a document, we separate out the text to document in Microsoft Word. The
heading, followed by an introduction give it structure. Each topic might have different styles for the document, such
or the most important information. a new paragraph, and each section can as different levels of heading, are
shown in the drop down box. If you used the formatting toolbar or palette to
regularly use Word, you might have also do this.
17 STRUCTURE
STRUCTURE 18
On the previous page you saw
how structure was added to a
Word document to make it
easier to understand. We use
structure in the same way
when writing web pages.
19 STRUCTURE
You can see the HTML code for this page below. Don't worry about
what the code means yet. We start to look at it in more detail on the
next page. Note that the HTML code is in blue, and the text you see
on screen is in black.
<html>
<body>
<h1>This is the Main Heading</h1>
<p>This text might be an introduction to the rest of the page. And if the
page is a long one it might be split up into several sub-headings.<p>
<h2>This is a Sub-Heading</h2>
<p>Many long articles have sub-headings so to help you follow the structure
of what is being written. There may even be sub-sub-headings (or lower-level
headings).</p>
<h2>Another Sub-Heading</h2>
<p>Here you can see another sub-heading.</p> </body>
</html>
The HTML code (in blue) is made up of characters that live inside
angled brackets — these are called HTML elements. Elements are
usually made up of two tags: an opening tag and a closing tag. (The
closing tag has an extra forward slash in it.) Each HTML element
tells the browser something about the information that sits between
its opening and closing tags.
STRUCTURE 20
Code
<html>
<body>
<h2>This is a Sub-Heading</h2>
<h2>Another Sub-Heading</h2>
</body>
</html>
21 STRUCTURE
Tags act like containers. They tell you
something about the information that lies
between their opening and closing tags.
Description
The opening <html> tag indicates that anything between it and a closing </html> tag is HTML code.
The <body> tag indicates that anything between it and the closing
</body> tag should be shown inside the main browser window.
Here is another paragraph between opening <p> and closing </p> tags.
The closing </body> tag indicates the end of what should appear in the main browser
window. The closing </html> tag indicates that it is the end of the HTML code.
STRUCTURE 22
RIGHT-angle bracket
left-angle bracket Opening Tag
(less-than sign) (MORE-than sign)
The characters in the brackets indicate For example, in the tags above the p The closing tag has a forward slash
the tag's purpose. stands for paragraph. after the the < symbol.
23 STRUCTURE
</p>left-angle bracket
Character
RIGHT-angle bracket
(MORE-than sign)
(less-than sign)
Forward Slash
Closing Tag
The terms "tag" and "element" are often Strictly speaking, however, an element tag and the closing tag and any content
used interchangeably. comprises the opening that lies between them.
STRUCTURE 24
Attribute
Name
Attribute
Value
The attribute name indicates what kind The value is the information or setting Here an attribute called lang is used to
of extra information you are supplying for the attribute. It should be placed in indicate the language used in this
about the element's content. It should double quotes. Different attributes can element. The value of this attribute on
be written in lowercase. have different values. this page specifies it is in US English.
25 STRUCTURE
HTML5 allows you to use
uppercase attribute names and
omit the quotemarks, but this is
not recommended.
Attribute
Name
The majority of attributes can only be Most attribute values are either pre- The value of the lang attribute is an
used on certain elements, although a defined or follow a stipulated format. abbreviated way of specifying which
few attributes (such as lang) can We will look at the permitted values as language is used inside the element
appear on any element. we introduce each new attribute. that all browsers understand.
STRUCTURE 26
<head>
<body> <title>This is the Title of the Page</title> </head>
<body>
You met the <body> element in the first example we created. <h1>This is the Body of the Page</h1>
Everything inside this element is shown inside the main browser <p>Anything within the body of a web page is displayed in the main
window. browser window.</p> </body>
</html>
<head>
Before the <body> element you will often see a <head> element.
This contains information about the page (rather than information
that is shown within the main part of the browser window that is
highlighted in blue on the opposite page). You will usually find a
<title> element inside the <head> element.
<title>
The contents of the <title> element are either shown in the top of
the browser, above where you usually type in the URL of the page
you want to visit, or on the tab for that page (if your browser uses Result
tabs to allow you to view multiple pages at the same time).
/chapter-01/body-head-title.html HTML
<html>
27 STRUCTURE
Anything written between the
<title> tags will appear in the
title bar (or tabs) at the top of
the browser window, highlighted
in orange here.
You may know that HTML stands for page to another quickly and easily. A page, we add code around the original
HyperText Markup Language. The markup language allows you to annotate text we want to display and the browser
HyperText part refers to the fact that text, and these annotations provide then uses the code to display the page
HTML allows you to create links that additional meaning to the contents of a correctly. So the tags we add are the
allow visitors to move from one document. If you think of a web markup.
STRUCTURE 28
Article
STRUCTURE 30
STRUCTURE 32
Code in a Content
Management System
If you are working with a content management system on the opposite That is because they use a single
management system, blogging platform, page, you have a box 'template' to control all of the pages for a
or e-commerce application, you will that allows you to enter a title for the section of the site. (For example, an e-
probably log into a special administration page, another box for the main article, a commerce
section of the website to control it. The way to enter a publication date, and system might use the same template
tools provided in the administration something to indicate which section of to show all of their products.) The
sections of these sites usually allow you the site this page belongs in. information you supply is placed into
to edit parts of the page rather than the the templates.
entire page, which means you will rarely For an e-commerce store, you might
see the <html>, <head>, or <body> have boxes that allow you to enter a title The advantage of this approach is that
elements. for the product, a description of the people who do not know how to write
product, its price, and the quantity web pages can add information to a
Looking at the content available. website and it is also possible to change
the presentation of something in the every page that uses that template. If 1,000 items for sale, just
template, and it will automatically update you imagine an e-commerce store with
33 STRUCTURE
altering one template is a lot easier than Some content management systems
changing the page for each individual offer tools that also allow you to edit
product. In systems like this, when you the template files. If you do try to edit
have a large block of text that you can template files you need to check the
edit, such as a news article, blog entry or documentation for your CMS as they all
the description of a product in an e- differ from each other.
commerce store, you will often see a text You need to be careful when editing
editor displayed. template files because if you delete the
wrong piece of code or add something
Text editors usually have controls a in the wrong place the site may stop
little like those on your word processor, working entirely.
giving you different options to style
text, add links or insert images. Behind
the scenes these editors
are adding HTML code to your text, just
like the code you have seen earlier in
this chapter. Many of these editors will
have an option that allows you to see
(and edit) the code that they produce.
When the web was first taking off, one of Once you have opened this page, you code is below.
the most common ways to learn about can look for the View menu in your At first this code might look
HTML and discover new tips and browser, and select the option that says complicated but don't be discouraged.
techniques was to look at the source Source or View source. (The title By the time you have finished the next
code that made up web pages. changes depending on what browser you chapter of this book, you will be able to
are using.) understand it.
These days there are many more books
and online tutorials that teach HTML, but You should see a new window All of the examples for this book are on
you can still look at the code that a web appear, and it will contain the source the website, and you can use this simple
server sends to you. To try this out for code that was used to create this technique on any of the example pages
yourself, simply go to the sample code page. to see how they work.
for this chapter, at
www.htmlandcssbook.com/ code/ and click You can see this result in the You can also download all of the code
on the link called "View Source." photograph on the right. The page for this book from the same website by
you see is the window at the top; the clicking on the "Download" link.
35 STRUCTURE
STRUCTURE 36
Summary
STRUCTURE
2
Text
⇪
Headings and paragraphs
⇪
Bold, italic, emphasis
⇪
Structural and semantic markup
When creating a web page, you add
tags (known as markup) to the
contents of the page. These tags
provide extra meaning and allow
browsers to show users the
appropriate structure for the page.
In this chapter we focus on how to add markup to the text
that appears on your pages. You will learn about:
●
Structural markup: the elements that you can use
to describe both headings and paragraphs
●
Semantic markup: which provides extra information;
such as where emphasis is placed in a sentence, that
something you have written is a quotation (and who
said it), the meaning of acronyms, and so on
41 TEXT
TEXT 42
Headings
<h1> <h3>
<h2> <h4>
<h2>This is a Level 2 Heading</h2>
<h5> <h3>This is a Level 3 Heading</h3>
<h4>This is a Level 4 Heading</h4>
If there are further sections under the subheadings then the <h3>
element is used, and so on...
43 TEXT
Paragraphs
Article
HTML
chapter-02/paragraphs.html
<p>
HTML
<html>
<p>A paragraph consists of one or more sentences
that form a self-contained unit of discourse. The start of a paragraph is <p>Text is easier to understand when it is split up into units of text. For
indicated by a new line.</p> example, a book may have chapters. Chapters can have subheadings.
Under each heading there will be one or more TEXT 44
paragraphs.</p>
R esult
chapter-02/italic.html HTML
45 TEXT
Superscript &
Article
Subscript
HTML
chapter-02/superscript-and-subscript.html
<sup> <p>On the 4<sup>th</sup> of September
you will learn
about E=MC<sup>2</sup>.</p> The <sup> element is used to contain characters that should be
<p>The amount of CO<sub>2</sub> in the atmosphere grew by 2ppm in superscript such as the suffixes of dates or mathematical concepts
2009<sub>1</sub>.</p> like raising a number to a power such as 22.
<sub>
The <sub> element is used to contain characters that should be
R esult subscript. It is commonly used with foot notes or chemical formulas
such as H20.
TEXT 46
White Space
In order to make code easier to read, web page authors often add <p>The moon is drifting away from Earth.</p> <p>The moon is drifting away
extra spaces or start some elements on new lines. from Earth.</p> <p>The moon is drifting away from
When the browser comes across two or more spaces next to each Earth.</p>
other, it only displays one space. Similarly if it comes across a line
break, it treats that as a single space too. This is known as white
space collapsing.
You will often see that web page authors take advantage of white
space collapsing to indent their code in order to make it easier to
follow.
chapter-02/white-space.html HTML
R esult
47 TEXT
<br />
As you have already seen, the browser will automatically show
each new paragraph or heading on a new line. But if you wanted to
add a line break inside the middle of a paragraph you can use the
R esult line break tag <br />.
<hr />
To create a break between themes — such as a change of topic in
HTML chapter-02/horizontal-rules.html
a book or a new scene in a play — you can add a horizontal rule
<p>Venus is the only planet that rotates between sections using the <hr /> tag.
clockwise.</p>
<hr /> There are a few elements that do not have any words between an
<p>Jupiter is bigger than all the other planets combined.</p> opening and closing tag. They are known as empty elements and
they are written differently.
An empty element usually has only one tag. Before the closing
angled bracket of an empty element there will often be a space
R esult and a forward slash character. Some web page authors miss this
out but it is a good habit to get into.
TEXT 48
Visual editors often resemble word allow you to control the presentation ●
Headings are created by highlighting
processors. Although each editor will of text. text then using a drop-down box to
differ slightly, there are some features select a heading.
that are common to most editors that ●
Bold and italic text are created by
highlighting some text and pressing on a Mac) and then copy it from that
a b or i program and paste it into the visual
button. editor.
●
New paragraphs are created using
the return or the enter key.
●
Line breaks are created by pressing
the shift key and the return key at the
same time.
Code views show you the code
●
Horizontal rules are created using a created by the visual editor so you can
button with a straight line on it. manually edit it, or so you can just
If you copy and paste text from a enter new code yourself. It is often
program that allows you to format text activated using a button with an icon
(such as Word) into a visual editor, it that says HTML or has angled
may add extra markup. To prevent this brackets. White space may be added
copy the text into a plain text editor first to the code by the editor to make the
(such as Notepad on a PC or TextEdit code easier to read.
49 TEXT
Semantic Markup
There are some text elements that are not intended to affect the
structure of your web pages, but they do add extra information
to the pages — they are known as semantic markup.
In the rest of the chapter you will meet Browsers often display the contents The reason for using these elements is
some more elements that will help you of these elements in a different way. that other programs, such as screen
when you are adding text to web For example, the content of the <em> readers or search engines, can use this
pages. For example, you are going to element is shown in italics, and a extra information. For example, the
meet the <em> element that allows you <blockquote> is usually indented. But voice of a screen reader may add
to indicate where emphasis should be you should not use them to change the emphasis to the words inside the <em>
placed on selected words and the way that your text looks; their purpose is element, or a search engine might
<blockquote> element which indicates to describe the content of your web register that your page features a quote
that a block of text is a quotation. pages more accurately. if you use the <blockquote> element.
50TEXT
<strong> <em>
The use of the <strong> element indicates that its content has The <em> element indicates emphasis that subtly changes the
strong importance. For example, the words meaning of a sentence.
contained in this element might be said with strong emphasis.
By default browsers will show the contents of an <em> element in
By default, browsers will show the contents of a <strong> element in italic.
bold. chapter-02/strong.html HTML
51 TEXT R esult
Quotations
Article
<q>
The <q> element is used for shorter quotes that sit within a
paragraph. Browsers are supposed to put quotes around the <q>
quotations: element, however Internet Explorer does not — therefore many
people avoid using the <q> element. Both elements may use the cite attribute to indicate where the quote
is from. Its value should be a URL that will have more information
about the source of the quotation.
TEXT 52
Abbreviations &
Acronyms
53 TEXT
Citations &
Article
Definitions
<cite>
When you are referencing a piece of work such as a book, film or
research paper, the <cite> element can be used to indicate where
the citation is from.
R esult
In HTML5, <cite> should not really be used for a person's name —
but it was allowed in HTML 4, so most people are likely to continue
to use it.
<dfn>
HTML chapter-02/definitions.html
The first time you explain some new terminology (perhaps an
<p>A <dfn>black hole</dfn> is a region of space from which nothing, not
academic concept or some jargon) in a document, it is known as
even light, can escape.</p>
the defining instance of it.
TEXT 54
Author Details
It can contain a physical address, but it does not have to. For You may also be interested in something called the hCard
example, it may also contain a phone number or email address. microformat for adding physical address information to your
markup.
55 TEXT
Changes to ContentArticle
R esult R esult
content of a <del> element usually has a line through it.
<ins> <s>
<del> The <s> element indicates something that is no longer accurate or
relevant (but that should not be deleted).
The <ins> element can be used to show content that has been
Visually the content of an <s> element will usually be displayed with
inserted into a document, while the <del> element can show text
a line through the center.
that has been deleted from it.
Older versions of HTML had a <u> element for content that was
The content of a <ins> element is usually underlined, while the
underlined, but this is being phased out.
TEXT 56
57 TEXT
Example
TEXT
<html>
<head>
<title>Text</title>
</head>
<body>
<h1>The Story in the Book</h1>
<h2>Chapter 1</h2>
<p>Molly had been staring out of her window for about an hour now. On her
desk, lying between the copies of <i>Nature</i>, <i>New Scientist</i>, and
all the other scientific journals her work had appeared in, was a well
thumbed copy of <cite>On The Road</cite>. It had been Molly's favorite
book since college, and the longer she spent in these four walls the more
she felt she needed to be free.</p>
<p>She had spent the last ten years in this room, sitting under a poster with
an Oscar Wilde quote proclaiming that <q>Work is the refuge of people who
have nothing better to do</q>. Although many considered her pioneering
work, unraveling the secrets of the llama <abbr
title="Deoxyribonucleic acid">DNA</abbr>, to be an outstanding
achievement, Molly <em>did</em> think she had something better to
do.</p>
</body>
</html>
TEXT 58
Summary
TEXT
3
Numbered lists Bullet lists
⇪
Definition lists
Lists
There are lots of occasions when we
need to use lists. HTML provides us
with three different types:
●
Ordered lists are lists where each item in the list is
numbered. For example, the list might be a set of steps
for a recipe that must be performed in order, or a legal
contract where each point needs to be identified by a
section number.
●
Unordered lists are lists that begin with a bullet
point (rather than characters that indicate order).
●
Definition lists are made up of a set of terms along with
the definitions for each of those terms.
63 LISTS
LISTS 64
Ordered Lists
<ol>
The ordered list is created with the <ol> element.
<li>Chop potatoes into quarters</li>
<li>Simmer in salted water for 15-20
Sometimes you may see a type attribute used with the <ol> element
to specify the type of numbering (numbers, letters, roman
Result
65 LISTS
Unordered Lists
Article
HTML chapter-03/unordered-lists.html
<ul>
<li>1kg King Edward potatoes</li>
<li>100ml milk</li>
<ul>
<li>50g salted butter</li>
<li>Freshly grated nutmeg</li>
<li>Salt and pepper to taste</li>
</ul>
The unordered list is created with the <ul> element.
<li>
Result Each item in the list is placed between an opening <li> tag and a
closing </li> tag. (The li stands for list item.)
LISTS 66
Definition Lists
<dt>
This is used to contain the term being defined (the definition term).
<dd>
This is used to contain the definition.
Sometimes you might see a list where there are two terms used for
the same definition or two different definitions for the same term.
chapter-03/definition-lists.html HTML
<dl>
<dt>Sashimi</dt>
<dd>Sliced raw fish that is served with
condiments such as shredded daikon radish or ginger root, wasabi and soy
sauce</dd> <dt>Scale</dt>
Result
67 LISTS
Nested
ListsArticl
e
Example
LIST
S
LISTS 70
Summary
LISTS
⇪ There are three types of HTML lists:
ordered, unordered, and definition.
⇪ Ordered lists use numbers.
one another.