The Absolute Beginner's Guide To HTML and CSS: A Step-by-Step Guide With Examples and Lab Exercises 1st Edition Kevin Wilson
The Absolute Beginner's Guide To HTML and CSS: A Step-by-Step Guide With Examples and Lab Exercises 1st Edition Kevin Wilson
The Absolute Beginner's Guide To HTML and CSS: A Step-by-Step Guide With Examples and Lab Exercises 1st Edition Kevin Wilson
https://ebookmass.com/product/postman-for-api-testing-a-
beginners-guide-learn-to-test-apis-like-a-pro-with-postman-with-
real-world-examples-and-step-by-step-guidance-parvin/
https://ebookmass.com/product/web-api-development-for-the-
absolute-beginner-a-step-by-step-approach-to-learning-the-
fundamentals-of-web-api-development-with-net-7-1st-edition-irina-
dominte/
https://ebookmass.com/product/kubernetes-fundamentals-a-step-by-
step-development-and-interview-guide-1st-edition-himanshu-
agrawal/
https://ebookmass.com/product/kubernetes-fundamentals-a-step-by-
step-development-and-interview-guide-1st-edition-himanshu-
agrawal-2/
Roblox Lua Scripting Essentials: A Step-by-Step Guide
1st Edition Coutinho
https://ebookmass.com/product/roblox-lua-scripting-essentials-a-
step-by-step-guide-1st-edition-coutinho/
https://ebookmass.com/product/game-theory-an-introduction-with-
step-by-step-examples-ana-espinola-arredondo/
https://ebookmass.com/product/how-to-use-spss-a-step-by-step-
guide-to-analysis-and-interpretation-10th-edition-ebook-pdf/
https://ebookmass.com/product/how-to-conduct-surveys-a-step-by-
step-guide-6th-edition-ebook-pdf-version/
https://ebookmass.com/product/the-okrs-field-book-ben-lamorte/
The Absolute
Beginner’s Guide
to HTML and CSS
A Step-by-Step Guide with
Examples and Lab Exercises
—
Kevin Wilson
The Absolute
Beginner’s Guide to
HTML and CSS
A Step-by-Step Guide
with Examples and
Lab Exercises
Kevin Wilson
The Absolute Beginner’s Guide to HTML and CSS: A Step-by-Step Guide
with Examples and Lab Exercises
Kevin Wilson
WIDNES, UK
Introduction���������������������������������������������������������������������������������������xiii
iii
Table of Contents
iv
Table of Contents
Adding Lists��������������������������������������������������������������������������������������������������������69
Unordered List�����������������������������������������������������������������������������������������������69
Ordered List���������������������������������������������������������������������������������������������������70
Structuring Your Web Page���������������������������������������������������������������������������������70
Lab Exercises������������������������������������������������������������������������������������������������������72
Summary������������������������������������������������������������������������������������������������������������73
v
Table of Contents
Chapter 6: Multimedia����������������������������������������������������������������������135
Adding Video�����������������������������������������������������������������������������������������������������135
Adding Audio�����������������������������������������������������������������������������������������������������139
Adding Image Maps������������������������������������������������������������������������������������������140
Lab Exercises����������������������������������������������������������������������������������������������������145
Summary����������������������������������������������������������������������������������������������������������146
vi
Table of Contents
Lab Exercises����������������������������������������������������������������������������������������������������166
Summary����������������������������������������������������������������������������������������������������������167
Index�������������������������������������������������������������������������������������������������235
vii
About the Author
With over 20 years of experience in the computer industry, Kevin Wilson
has made a career out of technology and is showing others how to use it.
After earning a master’s degree in computer science, software engineering,
and multimedia systems, Kevin has held various positions in the IT
industry including graphic and web design, digital film and photography,
programming and software engineering, developing and managing
corporate networks, building computer systems, and IT support. He
currently teaches computer science at college and works as an IT trainer in
England while researching for his Ph.D.
ix
About the Technical Reviewer
Jonathon Simpson is a product owner and engineer living in the UK. He
graduated from UCL in 2015. With many years of experience, he has
developed and run many successful projects both independently and in
large companies. He produces a popular software engineering blog called
fjolt.com and posts regular newsletters about the latest developments and
trends in JavaScript and web development.
xi
Introduction
The aim of this book is to provide a first course in the use of HTML
and CSS.
It provides a foundation for those who wish to develop their own
websites, and because the book is intended to be a primer, it allows the
beginner to become comfortable with basic HTML and CSS coding.
As it is a first course, no previous experience of computer
programming is assumed.
Throughout the book, we’ll explore HTML and CSS with worked
examples and lab exercises for you to complete yourself. We’ll also
introduce JavaScript and how it can be used to add interactivity to a
website, as well as using content management systems such as WordPress.
For this purpose, we’ve included all the source code for this book in
the following repository: https://github.com/Apress/The-Absolute-
Beginner-s-Guide-to-HTML-and-CSS
xiii
CHAPTER 1
Getting Started
Originally developed in the early 1990s by Tim Berners-Lee, HTML stands
for HyperText Markup Language and is a language used to lay out and
format documents for the World Wide Web that are designed to be displayed
in a web browser. In other words, the HTML code describes the structure of
a web page. HTML can be used with other technologies such as Cascading
Style Sheets (CSS) to style and format the document and scripting languages
such as JavaScript to provide functionality and interactive elements.
Basic knowledge of HTML is essential for students and anyone working
in web development. This will help you
2
Chapter 1 Getting Started
What Is a URL?
Each website on the World Wide Web has an address called a URL
(Figure 1-2) or Uniform Resource Locator.
The URL itself can be broken down into its basic elements. Let’s take a
closer look at an example:
https://www.ellumitechacademy.com
3
Chapter 1 Getting Started
mail.ellumitechacademy.com
shop.ellumitechacademy.com
www.ellumitechacademy.com/courses
www.ellumitechacademy.com/courses/html
If we want to access a web page or a file for download, we add the path
and file name of the file or document:
www.ellumitechacademy.com/aboutus.html
www.ellumitechacademy.com/downloads/menu.pdf
4
Chapter 1 Getting Started
Of course, these files and directories would need to exist in the public_
html or htdocs directory on the web server (Figure 1-3). Here, we can see
the courses and downloads directories on the server.
Index Pages
Websites are built inside directories on a web server. The index file is the
default page displayed if no other page is specified when a visitor enters
the URL into their web browser. This index file could be index.html, index.
php, or index.py depending on which language you’re using to develop
your site. For now, we’ll use index.html.
In our example, we have a directory structure on our web server
(Figure 1-4).
5
Chapter 1 Getting Started
www.ellumitechacademy.com/courses
the web server will look in the directory for the index.html file:
www.ellumitechacademy.com/courses/index.html
If the index.html file is missing, the web server will attempt to display a
list of files, or you’ll see an error message (Figure 1-5).
6
Chapter 1 Getting Started
HTML5
HTML5 brings device independence, meaning websites can be developed
for all different types of platforms, from PCs to smartphones, without the
need to endlessly install plugins on your browser or develop multiple
versions of a website for mobile devices as we can see in Figure 1-6.
HTML5 also introduces some new tags to handle page structure such
as <section>, <head>, <nav>, <aside>, and <footer> and some tags to
handle media such as <audio> or <video>.
We’ll take a look at some of the new HTML5 features later in this guide.
What Is CSS?
Cascading Style Sheets (CSS) are used to define and customize the styles
and layout for your web pages. This means you can create style sheets to
alter the design, layout, and responsiveness to different screen sizes on
various devices from computers to smartphones.
7
Chapter 1 Getting Started
You can either add your CSS declarations to the <head> section of
your HTML document between the <style>…</style> tags or add your CSS
declarations to a separate style.css file and add a link in the <head> section
of your HTML document using
This is a better way since it allows you to change the styles in one place
rather than in each HTML page you create.
We’ll take a closer look at CSS later in Chapter 4 of this book.
8
Chapter 1 Getting Started
Hosting
For hosting your website, you have three options:
aprelium.com/downloads
9
Chapter 1 Getting Started
Select the Windows version (or the Mac version if you’re using a Mac)
(Figure 1-9).
10
Chapter 1 Getting Started
Choose a directory where you want to install Abyss Web Server files.
Click “Install” (Figure 1-11).
On your start menu, click “Abyss Web Server X1” (Figure 1-12).
11
Chapter 1 Getting Started
Create your login details – don’t forget these. Enter a login username
(e.g., admin) and a password (Figure 1-14). Click OK when you’re done.
12
Chapter 1 Getting Started
When the browser asks you for a username and password, enter the
username and password you chose earlier (Figure 1-15).
13
Chapter 1 Getting Started
The server will appear in the system area on the bottom right-hand
side (Figure 1-17).
14
Chapter 1 Getting Started
Local Machine
If you have installed Abyss Web Server on your local machine, any pages
you develop on your website will be saved into the following folder:
You’ll find the folder in File Explorer on the C drive (Figure 1-18).
15
Chapter 1 Getting Started
Once the server is running, you’ll be able to access your web page from
a web browser by navigating to
http://localhost/pagename.html
or
http://127.0.0.1/pagename.html
http://localhost/index.html
http://localhost/store.html
filezilla-project.org/download.php
16
Chapter 1 Getting Started
Click “New site,” then enter the FTP hostname or IP address, then add
your username and password (Figure 1-20).
17
Chapter 1 Getting Started
In the pane on the left-hand side, navigate to the folder where you save
all your HTML files into. In the pane on the right-hand side, navigate to the
htdocs or public_html folder on the web server (Figure 1-21).
18
Chapter 1 Getting Started
wiki.filezilla-project.org/Documentation
19
Chapter 1 Getting Started
Another popular IDE is Visual Studio Code or VS Code for short. You
can download VS Code from the following website:
code.visualstudio.com
In Figure 1-24, we can see VS Code on the left-hand side showing our
HTML code with a browser preview open on the right showing the output
of the HTML code.
20
Chapter 1 Getting Started
Another code editor to try is Brackets. Brackets is a free editor that you
can download from the developer’s website:
www.brackets.io
In Figure 1-25, you can see the Brackets window open on the left-hand
side, and it makes quite a nice little editor for coding. On the right-hand
side, you can open up your live preview to see what your page looks like as
you’re writing your code.
21
Chapter 1 Getting Started
You can use any of these tools to write your code. Some of these IDEs
can be quite complex, so while you are learning, I suggest you stick with
Notepad and write the code manually so you can understand the structure
and meaning without distractions.
Throughout this book, we’ll be using Notepad/TextEdit to write our
code as shown in Figure 1-26; however, you can use any code editor you
like such as VS Code if you prefer.
22
Chapter 1 Getting Started
Lab Demo
In this demo, we’re going to explore how web servers work.
In Figure 1-27, the machine on the right has our web server installed.
A web server is a program that runs on the machine and serves web
pages (such as Abyss that we installed earlier). The web server software is
bound to a port. A port is a number used to identify a service running on a
machine. In this case, the service is a web server and is bound to port 80.
This machine is connected to a small network using cat5 cables through a
network switch.
23
Chapter 1 Getting Started
The web server running on the machine on the right is pointing at the
public_html or htdocs directory stored on the machine’s hard drive. Here,
we can see we have an index.html file in the public_html directory on our
server (Figure 1-28). This is called the document root.
• IP address: 192.168.0.100
• Port: 80
24
Chapter 1 Getting Started
This laptop connects to the web server using the IP address allocated
to the machine running the web server. On the laptop, we can type this
IP address into the address bar at the top of the browser: 192.168.0.100
(Figure 1-30).
The laptop will connect to the web server using the server’s IP address
through port 80 (Figure 1-31).
25
Chapter 1 Getting Started
The IP address and the port number form a socket. There will be a
socket on the server and one on the laptop (client). Each socket is unique
and bidirectional, so applications can send and receive data (Figure 1-33).
26
Chapter 1 Getting Started
27
Chapter 1 Getting Started
Your computer (i.e., the laptop) then uses this IP address to connect to
the web server as before.
Lab Exercises
1. Set up your personal web server on your computer
or get access to a web host to host your HTML files.
3. What is hypertext?
4. What is a URL?
5. What is HTML?
28
Chapter 1 Getting Started
6. What is CSS?
9. What is an IP address?
Summary
• Web pages are all linked together using clickable text or
images, called hyperlinks.
• VS Code
• Dreamweaver
• Brackets
29
CHAPTER 2
Introduction to HTML
In this chapter, we’ll take a look at the basics of an HTML document.
The basic structure of an HTML document has three parts:
• Document header
• Body
At the top on the first line, we have the document type declaration.
Underneath, we have the first <html> element. This defines the start of
the HTML page.
Inside the <html> elements, we have the <head> element. This
contains information about the page as well as the document title.
Underneath, we have the <body> element. This is where the main body
of the document is defined. This is the bit you see in your browser window.
Finally, we need to close the <html> element. This marks the end of the
document.
Let’s explore an example in a bit more detail. Here, you can see a
simplified web page broken down to its most basic elements (Figure 2-2).
32
Chapter 2 Introduction to HTML
The <html> element contains all the HTML code and defines the start
of the HTML page. You can also specify the language by adding the lang
attribute:
The <body> element contains all the elements and is where the main
content is written to display on the web page.
You might also find the following elements:
<!-- … -->
33
Chapter 2 Introduction to HTML
These elements specify a comment for the developer’s benefit and are
ignored by the browser. Comments are useful to document your code and
explain its function.
The bit visible to the user goes in between the two tags.
34
Chapter 2 Introduction to HTML
The opening HTML tag often contains some attributes that define the
HTML element’s properties and are used to control formatting, size, page
link references, and so on, and it is placed inside the element's opening
tag. For example, see Figure 2-4.
35
Another random document with
no related content on Scribd:
Mr. Tope laughed in jolly appreciation of himself.
“Well, I suppose I’m crazy like the rest of ’em. We’re all crazy there.
The Casino is a great lunatic asylum. We wander about as if we
were free, but we’re not. Inevitably our feet carry us back. Don’t let it
get you, young man. Avoid Monte as you would the plague.... By the
way there’s the first call for lunch. I’m going to have a wash first. See
you later.”
2.
3.
Monte Carlo.
They were getting in now. The train seemed to plunge into a dazzle
of light; then the darkness of another tunnel; then a long green
station. On the lamps so meanly printed, he could see the magic
name that opens wide the portals of romance. Surely it should be
blazoned in fiery capitals on the heights of heaven! This then was
the spot of which people talk and dream, that masterpiece of nature
and art which never disenchants, which is adorable even in its
cruelty. Fatal, fascinating name,—Monte Carlo.
It was the climax of the beautiful journey. The train disgorged nearly
all its passengers as if this place like a magnet was drawing them
out. He saw Bob Bender, and Jarvie Tope. He watched old Professor
Durand looking curiously about him, and a white-haired porter taking
the baggage of Mrs. Belmire. He felt alone, abandoned.
As the train lingered, loth to leave this charmed spot, Hugh felt a
sudden desire to get off. He saw the fair-haired girl struggling with a
basket-valise. With a sudden impulse he gathered together his own
luggage and prepared to descend, but the train was already in
motion.
“Just as well. Now for Menton.”
Then behold! the train halted again and backed to the station.
“Fate!” said Hugh and jumped off. He passed through a long
baggage room into a courtyard where there was a line of luxurious
hotel omnibuses and porters in livery. The court was backed by a
wall of rock that rose to the heights of a glorious garden. Palms
speared the silvery arc-lights. Masses of geraniums stained the face
of the rock. On the winding steps that led to the garden a nude
statue of a woman was set in a niche amid ferns and water-lilies, and
a diamond spray of water.
On the long hill to the right was a line of fiacres. He saw the fair-
haired girl hand her bag to one of the drivers.
“Pension Paoli,” she said.
Hugh watched her drive away; then he, too, hailed a fiacre. The dark
driver bent to him with smiling politeness.
“Where to, monsieur?”
Hugh thought for a moment. As he stood there he had a strange thrill
of wonder and of joy. He seemed to breathe an enchanted air; the
silver lights amid the trees were those of fairyland; he felt as if he
were hesitating on the very threshold of romance.
“Pension Paoli,” he answered.
CHAPTER THREE
THE POISONED PARADISE
1.
2.
3.
4.
Hugh’s favourite walk was along the highroad that led to the Tête du
Chien. It crossed a dizzy bridge over a deep gorge in which the
washerwomen hung their linen to dry. At the mouth of this gorge,
framed in the arches of the railway bridge, was a tiny chapel, and
behind it, like a slab of lapis lazuli, the harbour. Climbing still higher
the road passed the Persian villa and reached the top of the hill.
Almost directly below were the red roofs of the Condamine.
Continuing still further the road swung into a great curve high above
Monaco, disclosing both the Rock and the sweet serenity of the sea.
Terrace upon terrace of olive trees rose to the base of the mountain.
Hugh was walking along this road one morning, admiring the beauty
that surrounded him, when suddenly he glanced down. In the dust at
his feet, fresh and glistening, was a crimson patch. “Curious,” he
thought; “those marks look as if a heavy body had fallen here.” He
examined the stone-wall and found a slight spatter of blood. A little
further on, he picked up something that made him look very
thoughtful, a bit of bony fibre, to which adhered a few dark hairs.
Strange! He looked downwards, and saw that he stood just above
the Cemetery of Monaco. He found the path and slowly descended.
He searched for some time for the suicide’s section of the cemetery
which he had been told was cunningly concealed. A great high wall
separated the lower from the upper graveyard, and built half the way
up the face of it, was another wall, the space between the two
forming a narrow shelf. There was no access to this shelf except
through a broken place in the balustrade of the stairway just large
enough to pass a coffin. As he looked down from the upper wall,
Hugh saw that the whole length of the shelf was closely packed with
nameless graves. In one place where the earth had been thrown
carelessly up a rusty shovel leaned against the wall. The air had the
smell of a charnel pit.
He climbed the hill again. The place where he had seen the blood
was now quite clean. There was no trace of any disturbance. Some
one had come in his absence and tidied things up. The sky had
suddenly grown grey, grey too and sinister the mountains. He had an
uneasy sense that somewhere in the olive trees unseen eyes were
watching him; that he was being spied on and shadowed.
5.
Another day when he took this solitary walk, twilight was gathering
and the roofs of the Condamine were softened to a coral mist. The
space between the rock of Monaco and the Tête du Chien was filled
with sunset after-glow as a cup is filled with wine. The olive trees
lately twinkling in the sunshine were now mysteriously still.
When Hugh came to the highest point overlooking the town, he
stopped to rest. The rock of Monaco rose like a monster from the
sea, and was as dim and silent as a tomb. He could distinguish the
courtyard of the Palace, greyly alight, and a black stencilling of
windows. A solitary lamp revealed a turret and an ancient archway,
all else was gloom. In its austere mediæval strength the rock
seemed the abode of mystery and silence.
And Monte Carlo! Looking towards it Hugh could see nothing but
light. The mountains were pricked with patterns of light, the great
hotels were packed with light. And all seemed to concentrate in one
dazzling centre, the source from which this luxury of light flowed,—
the Casino.
Then he noticed that on a bench near him was a stooping figure. To
his surprise he recognized it as that of Professor Durand. The old
man was clutching in his hands a number of the Revue of Monte
Carlo with its columns of permanencies.
“What a pity!” thought Hugh. “So fine, so venerable a head bent over
those wretched figures. This man who might be taken for a preacher,
a prophet,—a slave to this vulgar vice, puzzling over systems, trying
to outwit the Goddess Chance. Le calcul peut vaincre le jeu ... that is
the lying phrase that lures them. Fools!”
Then he turned for the Professor was addressing him. Hugh saw a
flashing eye, a noble brow.
“Young man, you will excuse me, but I claim the privilege of age. At
the Sorbonne I have lectured to thousands like you. I speak because
I noted in your passing glance something of disdain.”
Hugh made a gesture of protest.
“No, I do not blame you. You see me with these numbers. But you
misjudge me.... Listen....”
The old man seemed to grow taller. He stretched his hand to where
the Casino glittered like a crown of gems.
“I am eighty years old to-day. I have a feeling that I shall never see
another birthday. But there is one thing I hope to do before I die ... to
ruin that accursed place.”
Hugh stared at him.
“I speak for the good of humanity, I speak because of the evil it has
done in the past, the harm it can do in years to come. I speak in
behalf of its thousand of blasted homes, its broken hearts, its
shameful graves. Ah! you only see the beautiful surface. You do not
see below. But I do. And to my eyes yonder rock on which it stands,
is built of human skulls, the waves that lap it are tears and blood.
Look at the loveliness of earth and sky, the purple mountain rising
from the silver sea, the dreamlike peace, the soft and gentle air. No
painted picture was ever half so beautiful. How happy all might be
here! A paradise, a human paradise; but because of that place, a
poisoned paradise.”
Hugh stared harder. The old man’s voice was tense with passion.
“You think I am a fanatic, a madman. Wait and see. I am going to
destroy that place. For years I have worked on my great plan. It is
the crown of my life. In a few weeks I will begin to play. I shall win
and win. By mathematics I will frustrate chance. I will compel them to
close their doors, for my system is invincible. God has given me this
task to do, and I will complete it before I die. Into my hands He has
delivered them. I am His instrument of vengeance. Let them
beware!”
In a magnificent gesture he shook his clenched fists at the Casino.
When Hugh left him he was still standing like a prophet on the
heights, staring down on his poisoned paradise.
CHAPTER FOUR
THE GIRL WHO WAS ALWAYS ALONE
1.
2.