Basic Computer Coding HTML 3rd Edition - Kayoko Furochi
Basic Computer Coding HTML 3rd Edition - Kayoko Furochi
CODING: HTML
(3RD EDITION)
Kayoko Furochi
[Link]
BASIC COMPUTER CODING: HTML (3RD EDITION)
KAYOKO FUROCHI
[Link]
email: info@[Link]
Dan Piestun (PhD) is currently a startup entrepreneur in Israel working on the interface of Agriculture
and Biomedical Sciences and was formerly president-CEO of the National Institute of Agricultural
Research (INIA) in Uruguay. Dan is a widely published scientist who has received many honours
during his career including being a two-time recipient of the Amit Golda Meir Prize from the Hebrew
University of Jerusalem, his areas of expertise includes stem cell molecular biology, plant and animal
genetics and bioinformatics. Dan’s passion for applied science and technological solutions did not
stop him from pursuing a deep connection to the farmer, his family and nature. Among some of his
interest and practices counts enjoying working as a beekeeper and onboard fishing.
Hazem Shawky Fouda has a PhD. in Agriculture Sciences, obtained his PhD. From the Faculty of
Agriculture, Alexandria University in 2008, He is working in Cotton Arbitration & Testing General
Organization (CATGO).
Felecia Killings is the Founder and CEO of LiyahAmore Publishing, a publishing company committed
to providing technical and educational services and products to Christian Authors. She operates as the
Senior Editor and Writer, the Senior Writing Coach, the Content Marketing Specialist, Editor-in-Chief
to the company’s quarterly magazine, the Executive and Host of an international virtual network,
and the Executive Director of the company’s online school for Authors. She is a former high-school
English instructor and professional development professor. She possesses a Master of Arts degree in
Education and a Bachelor’s degree in English and African American studies.
Dr. Sandra El Hajj, Ph.D. in Health Sciences from Nova Southeastern University, Florida, USA is
a health professional specialized in Preventive and Global Health. With her 12 years of education
obtained from one of the most prominent universities in Beirut, in addition to two leading universities
in the State of Florida (USA), Dr. Sandra made sure to incorporate interdisciplinary and multicultural
approaches in her work. Her long years of studies helped her create her own miniature world of
knowledge linking together the healthcare field with Medical Research, Statistics, Food Technology,
Environmental & Occupational Health, Preventive Health and most noteworthy her precious last
degree of Global Health. Till today, she is the first and only doctor specialized in Global Health in the
Middle East area.
Fozia Parveen has a Dphil in Sustainable Water Engineering from the University of Oxford. Prior
to this she has received MS in Environmental Sciences from National University of Science and
Technology (NUST), Islamabad Pakistan and BS in Environmental Sciences from Fatima Jinnah
Women University (FJWU), Rawalpindi.
Igor Krunic 2003-2007 in the School of Economics. After graduating in 2007, he went on to study
at The College of Tourism, at the University of Belgrade where he got his bachelor degree in 2010.
He was active as a third-year student representative in the student [Link] he went on the
Faculty of science, at the University of Novi Sad where he successfully defended his master’s thesis
in 2013. The crown of his study was the work titled Opportunities for development of cultural tourism
in Cacak“. Later on, he became part of a multinational company where he got promoted to a deputy
director of logistic. Nowadays he is a consultant and writer of academic subjects in the field of tourism.
Dr. Jovan Pehcevski obtained his PhD in Computer Science from RMIT University in Melbourne,
Australia in 2007. His research interests include big data, business intelligence and predictive
analytics, data and information science, information retrieval, XML, web services and service-oriented
architectures, and relational and NoSQL database systems. He has published over 30 journal and
conference papers and he also serves as a journal and conference reviewer. He is currently working as
a Dean and Associate Professor at European University in Skopje, Macedonia.
Dr. Tanjina Nur finished her PhD in Civil and Environmental Engineering in 2014 from University
of Technology Sydney (UTS). Now she is working as Post-Doctoral Researcher in the Centre for
Technology in Water and Wastewater (CTWW) and published about eight International journal papers
with 80 citations. Her research interest is wastewater treatment technology using adsorption process.
Stephen obtained his PhD from the University of North Carolina at Charlotte in 2013 where his graduate
research focused on cancer immunology and the tumor microenvironment. He received postdoctoral
training in regenerative and translational medicine, specifically gastrointestinal tissue engineering, at
the Wake Forest Institute of Regenerative Medicine. Currently, Stephen is an instructor for anatomy
and physiology and biology at Forsyth Technical Community College.
Michelle holds a Masters of Business Administration from the University of Phoenix, with a
concentration in Human Resources Management. She is a professional author and has had numerous
articles published in the Henry County Times and has written and revised several employee handbooks
for various YMCA organizations throughout the United States.
TABLE OF
CONTENTS
Preface ..................................................................... xiii
Introduction .........................................................................................................1
1.1 Overview of Web Design .............................................................................2
1.1.1 The History of Website Design ..........................................................3
1.1.2 How to Learn Web Design .................................................................6
1.1.3 Web site .................................................................................................9
1.1.4 World Wide Web ................................................................................11
1.1.5 Web Standards....................................................................................12
1.2 Brief History of Internet .............................................................................16
1.2.1 Origin and Development ..................................................................17
1.2.2 Society and the Internet ....................................................................23
Summary ............................................................................................................40
Knowledge Check .............................................................................................41
Review Questions .............................................................................................43
References ..........................................................................................................44
Introduction .......................................................................................................45
2.1 Effective Web Design Principles ...............................................................46
2.2 The Web Site Design and Development Process ....................................51
2.2.1 How to Design a Website..................................................................56
2.3 The Five Golden Rules of Responsive Web Design ...............................58
2.4 How to Design a Website Template .........................................................60
2.5 Prototyping a Responsive Web Page........................................................62
2.5.1 Requirement Analysis .......................................................................62
2.5.2 Overall Design ....................................................................................63
2.5.3 Implementation ..................................................................................65
Summary ............................................................................................................67
Knowledge Check .............................................................................................68
Review Questions .............................................................................................70
References ..........................................................................................................71
Introduction .......................................................................................................73
3.1 Hypertext Markup Language ...................................................................74
3.1.1 Basic HTML Document .....................................................................75
3.1.2 HTML - Basic Tags .............................................................................77
3.1.3 HTML Page Structure........................................................................83
3.1.4 HTML <!DOCTYPE> Declaration....................................................84
3.2 HTML VERSION ........................................................................................86
3.2.1 HyperText Markup Language (1991) ..............................................86
3.2.2 HTML 2.0 ............................................................................................88
3.2.3 HTML 3.2 ............................................................................................89
3.2.4 HTML 4.01 ..........................................................................................92
3.2.5 XHTML ................................................................................................99
3.2.6 HTML5 ..............................................................................................106
Summary ..........................................................................................................108
Knowledge Check ...........................................................................................109
Review Questions ...........................................................................................111
References ........................................................................................................112
Introduction .....................................................................................................113
4.1 Elements of HTML....................................................................................114
4.1.1 Nested HTML Elements .................................................................114
4.1.2 Do Not Forget the End Tag .............................................................116
4.1.3 Empty HTML Elements ..................................................................116
4.1.4 Use Lowercase Tags .........................................................................116
4.2 Meta TAG ...................................................................................................117
vi
4.2.1 Adding Meta Tags to Your Documents ........................................117
4.2.2 Specifying Keywords ......................................................................117
4.2.3 Document Description ....................................................................118
4.2.4 Document Revision Date ................................................................119
4.2.5 Document Refreshing......................................................................119
4.2.6 Page Redirection ..............................................................................120
4.2.7 Setting Cookies .................................................................................120
4.2.8 Setting Author Name .......................................................................121
4.2.9 Specify Character Set .......................................................................122
4.3 DIV TAG.....................................................................................................123
4.3.1 Creating Web Layout using Div Tag .............................................126
4.4 Working with Text ....................................................................................130
4.4.1 Text Styles..........................................................................................131
4.4.2 Physical Text Styles ..........................................................................131
4.4.3 Logical Text Styles and Headings .................................................132
4.5 Working with Lists, Tables ......................................................................133
4.5.1 Table ...................................................................................................141
4.6 Working with Hyperlinks, Images .........................................................146
4.6.1 Images................................................................................................149
4.7 Working with Forms ................................................................................153
4.7.1 Form Attributes ................................................................................154
4.7.2 HTML Form Controls......................................................................154
4.7.3 Text Input Controls ..........................................................................154
4.7.4 Multiple-Line Text Input Controls ................................................157
4.7.5 Checkbox Control ............................................................................158
4.7.6 Radio Button Control ......................................................................159
4.7.7 Select Box Control ............................................................................160
4.7.8 File Upload Box ................................................................................162
4.7.9 Button Controls ................................................................................163
4.7.10 Hidden Form Controls ..................................................................164
Summary ..........................................................................................................165
Knowledge check ............................................................................................166
Review questionS ............................................................................................168
References ........................................................................................................169
Introduction .....................................................................................................171
5.1 Overview of HTML5 ................................................................................173
vii
5.1.1 Browser Support for HTML5 .........................................................173
5.1.2 New Features of HTML5 ................................................................173
5.1.3 HTML5 Backward Compatibility ..................................................174
5.2 Syntax of HTML5 ......................................................................................174
5.2.1 The DOCTYPE..................................................................................175
5.2.2 Character Encoding .........................................................................175
5.2.3 HTML5 Document ...........................................................................176
5.3 HTML5 Elements ......................................................................................176
5.3.1 List of Tag ..........................................................................................177
5.4 HTML5 Attributes.....................................................................................181
5.4.1 Standard Attributes .........................................................................181
5.4.2 Custom Attributes............................................................................182
5.5 Web Forms 2.0 ...........................................................................................182
5.5.1 The <input> element in HTML4 ....................................................183
5.5.2 The <input> element in HTML5 ....................................................184
5.5.3 The <output> element......................................................................185
5.5.4 The Placeholder Attribute ...............................................................186
5.5.5 The Autofocus Attribute..................................................................187
5.5.6 The Required Attribute ...................................................................187
5.6 HTML5 SVG ..............................................................................................188
5.6.1 Viewing SVG Files ...........................................................................188
5.6.2 Embedding SVG in HTML5 ...........................................................188
5.6.3 HTML5 SVG Circle ..........................................................................189
5.6.4 HTML5 SVG Rectangle ...................................................................190
5.6.5 HTML5 SVG Line ............................................................................191
5.6.6 HTML5 SVG Ellipse ........................................................................192
5.6.7 HTML5 SVG Polygon......................................................................193
5.6.8 HTML5 SVG Polyline ......................................................................194
5.6.9 HTML5 SVG Gradients ...................................................................195
5.6.10 HTML5 SVG Star ...........................................................................197
5.7 Web Storage of HTML5............................................................................198
5.7.1 Session Storage .................................................................................198
5.7.2 Local Storage ....................................................................................199
5.7.3 Delete Web Storage ..........................................................................200
Summary ..........................................................................................................204
Knowledge Check ...........................................................................................205
Review Questions ...........................................................................................206
References ........................................................................................................208
viii
Chapter 6 Cascading Style Sheets .......................................... 209
Introduction .....................................................................................................209
6.1 Concept of CSS ..........................................................................................210
6.1.1 Proper use of CSS .............................................................................210
6.1.2 Implementing CSS formatting .......................................................211
6.1.3 Cascading Style Rules .....................................................................211
6.1.4 Style Sheet Language.......................................................................211
6.1.5 CSS selectors .....................................................................................212
6.1.6 CSS - Syntax ......................................................................................213
6.2 CSS Properties ...........................................................................................217
6.2.1 CSS - Colors ......................................................................................217
6.2.2 CSS - Fonts ........................................................................................221
6.2.3 CSS - Tables .......................................................................................225
Summary ..........................................................................................................234
Knowledge Check ...........................................................................................235
Review Questions ...........................................................................................237
References ........................................................................................................238
Introduction .....................................................................................................239
7.1 Overview of Web Hosting .......................................................................240
7.1.1 Basic Functionality of Web Hosting ..............................................241
7.1.2 How Website Hosting Works? .......................................................245
7.1.3 How Domain Name Works ............................................................248
7.1.4 The Difference between Web Hosting, Website and Domain ...250
7.1.5 Domain Name Registration Process .............................................252
7.2 Creating Website Structures ....................................................................253
7.2.1 The Four Types of Website Structures ..........................................254
7.2.2 Why you should start with the Site Structure .............................255
7.2.3 How to Choose your Best Website Structure ...............................256
7.2.4 Difference between Web Hosting and Web Publishing .............258
Summary ..........................................................................................................262
Knowledge Check ...........................................................................................263
Review Questions ...........................................................................................265
References ........................................................................................................266
ix
Chapter 8 JavaScript and External Content ............................ 267
Introduction .....................................................................................................267
8.1 The Canvas.................................................................................................268
8.2 Briefly of JavaScript ..................................................................................269
8.2.1 Client-Side JavaScript ......................................................................270
8.2.2 Syntax ................................................................................................270
8.2.3 Including JavaScript on Your Web Page .......................................272
8.2.4 Your First JavaScript Web Page ......................................................272
8.3 JavaScript Events and jQuery ..................................................................274
8.3.1 Obtaining jQuery .............................................................................274
8.3.2 Getting Ready for jQuery................................................................275
8.3.3 Selecting Elements with jQuery .....................................................276
8.3.4 Calling Functions with JavaScript .................................................277
8.3.5 Responding to Events with jQuery and JavaScript .....................278
8.3.6 Validating a Web Form with jQuery and JavaScript ...................280
8.4 Using the HTML5 <canvas> Tag .............................................................283
Summary ..........................................................................................................293
Knowledge Check ..........................................................................................294
Review Questions ...........................................................................................296
References ........................................................................................................297
Introduction .....................................................................................................299
9.1 Use Images as Elements in the Foreground of a Web Page ................300
9.1.1 Image File Types ..............................................................................301
9.1.2 Using Existing Graphics .................................................................302
9.1.3 Specify the Height and Width of Images .....................................303
9.1.4 Provide Alternative Text and Titles for Images ...........................305
9.2 Link Images to Other Content on a Web Site........................................306
9.2.1 Link the Entire Image ......................................................................306
9.2.2 Link Sections of an Image ...............................................................307
9.3 Use Images as Elements in the Background of a Web Page ...............309
9.4 Multimedia Formats .................................................................................313
9.5 Understand How Plug-ins Are Used with Web Browsers ..................315
9.5.1 Identify the Installed Components................................................315
9.5.2 Recognize File Types, Extensions, and Appropriate
Plug-ins ......................................................................................315
9.6 Link to Different Types of Media from a Web Page ............................316
x
9.7 Embed Different Types of Media into a Web Page ..............................318
9.7.1 Using the Object Tag........................................................................318
9.7.2 Java Applets ......................................................................................322
Summary ..........................................................................................................323
Knowledge Check ...........................................................................................324
Review Questions ...........................................................................................325
References ........................................................................................................326
xi
PREFACE
HTML or Hypertext Markup Language is a programming language employed to
describe the structure of information on a webpage. In a combined way, HTML,
CSS, and JavaScript make up the vital building blocks of websites globally, with
CSS controlling the appearance of a webpage and JavaScript programming and
its functionality. This grooms a business standard in the market. A good design
takes user by the hand and directs them where they need to go and find the
information they need quickly and easily. HTML can be a little intimidating for
those not accustomed to looking at code. That’s why this book is designed as an
introduction to web design basics. This book will break down the basics of how
to get your HTML page created. This book will take you through what HTML is,
how to create an HTML page, HTML basics, and what program you can use to
edit the HTML.
Organization of the Book
This edition is comprised of nine chapters. In this book, you’ll learn how to design
and build beautiful websites by learning the basic principles of design like branding,
color theory, and typography which are all instrumental in the design process of a
website. You’ll also learn HTML and CSS, which are the common code languages
that all modern websites are built on.
Chapter 1 introduces web design principles that explores basic principles involved
in developing a web site, planning process, five golden rules of web designing,
designing navigation bar, page design, home page layout, and design concept.
Chapter 2 focuses on basics in web design that gives brief history of Internet, World
Wide Web why create a Website, Web Standards, audience requirement of Web, etc.
Chapter 3 presents an introduction to HTML. In this chapter, you will find HTML
Page Structure, Doctype, and Heading-Paragraphs, including HTML Version, Line
Breaks, and HTML Tags.
Chapter 4 gives an exploration on the elements of HTML. Meta Tag and Div Tag
are given in this chapter. You will know working with Lists, Tables, Hyperlinks,
Images, and Forms.
Chapter 5 is aimed to discuss the elements of HTML5. In this chapter, you will
know about Header Tag, Footer Tag, Section Tag, Nav Tag, Aside Tag, and Video
Tag.
Chapter 6 begins with the concept of CSS, and further Creating Style Sheet, CSS
Properties, and CSS Styling are also described. Working with block elements and
objects, and Lists and Tables is also explored.
Chapter 7 is web publishing or hosting explores creating and saving the Web Site.
Working on the web site and creating web site structure and titles for web pages
is also discussed.
Chapter 8 focuses on JavaScript and external content. JavaScript is a text-based
programming language used both on the client-side and server-side that allows
you to make web pages interactive. Where HTML and CSS are languages that give
structure and style to web pages, JavaScript gives web pages interactive elements
that engage a user.
Chapter 9 focuses on Image and Multimedia. In the dynamic world of web
development, integrating images and multimedia is fundamental to creating engaging
and interactive websites. HTML, the backbone of web content, provides essential
elements to seamlessly incorporate visual and multimedia elements into web pages.
xiv
CHAPTER 1
BASICS IN WEB
DESIGN
LEARNING OBJECTIVES
and preferences of the target audience, ensuring easy navigation, and optimizing
the site for various devices and screen sizes. A well-designed website goes beyond
aesthetics; it effectively communicates the brand identity, message, and purpose,
fostering a connection between the user and the content.
One of the fundamental aspects of web design is the creation of a layout that
organizes information in a clear and structured manner. This includes deciding on
the placement of text, images, and interactive elements to guide users through the
content effortlessly. Additionally, web designers focus on optimizing the loading
speed, ensuring that the website performs efficiently and retains user engagement.
As technology evolves, web design trends and techniques also evolve.
Responsive design, for example, has become a standard practice, ensuring websites
adapt seamlessly to various devices, from desktops to smartphones. Moreover,
accessibility considerations, such as providing alternative text for images and
ensuring compatibility with screen readers, have gained prominence to ensure
inclusivity for all users.
Everything about your website - including the content, the way it looks,
and the way it works - is determined by the website design. Web design is a
process of conceptualizing, planning, and building a collection of electronic files
that determine the layout, colors, text styles, structure, graphics, images, and use
2
Basics in Web Design
of interactive features that deliver pages to your site visitors. Professional Web
design helps to make your business appear credible online. When you are ready
to build a website, you have several options. If you are not familiar with HTML
programming language and Web design applications, there are a number of other
options for creating your Web design:
■ Hire a professional website design expert to create and build a unique
Web site.
■ Create your own website design using off-the-shelf software such as
FrontPage or Dreamweaver. (These software packages do require technical
expertise.)
■ Use online website design tools with pre-set and/or customizable Web
design templates to customize with your company colors, graphics and text.
The degree of customization included in your website design will determine
the speed and cost of getting your site up and running.
3
Basic Computer Coding: HTML
The internet is a relatively new invention but boy have things changed in its
short life! The internet has changed the way we live and it has been responsible
for the creation of thousands upon thousands of jobs that simply would not exist
without it. One of those categories of job is web design, something that we would
sorely miss now if it disappeared. What would we do without the animations? The
colorful backgrounds, the fancy writing and the music playing in the background?
2000 -2004
In the year 2000, the bubble burst and hundreds of thousands of web businesses
crashed. However, while this may have put the clamps on things for a while, it
was not for long. Web design standards began to pick up again. Now we started
4
Basics in Web Design
to see a better class of design. We got designs that were not based on tables, we
got transparency with .png images and CMS began to grow in popularity. Content
management System was a program that allowed designers to publish content on
the web. They could go back in and edit what they had published and modify it
as they saw fit.
2007 – 2004
Web 2.0 was born in 2004. This was the era of bold websites, sites that were aimed
at communities. There was bold typography and shiny gradients. Corners became
rounded, edges softened and web design, once again, took off at the speed of
light. Websites began to be more functional and needed more in the way of an
interface to work properly. Widgets were introduced all over the place to help
integrate one site with another. This was more often, where a social network site
was involved, lining outside feeds to the site, or lining from the site to a blog. This
era was also marked by an increase in accessibility of websites to common people.
Developments such as WordPress and Blogger, along with user-friendly guides on
how to make a website helped every day people make a website without having
to learn HTML or CSS.
5
Basic Computer Coding: HTML
Remember
Content
management
is an ongoing
process and you
should update
your website
frequently. You
Beginning
should gather
Note what web designs differs from. Web design is not book
a possible list
of topics and design, it is not poster design, it is not illustration, and the
make those into highest achievements of those disciplines are not what web
separate pages. design aims for. Although websites can be delivery systems
for games and videos, and although those delivery systems
can be lovely to look at, such sites are exemplars of game
design and video storytelling, not of web design.
Understand what web design involves. Web design is the
creation of digital environments that:
■ facilitate and encourage human activity;
■ reflect or adapt to individual voices and content; and
■ change gracefully over time while always retaining
their identity.
Determine what resource you want to use. The main resources
are websites, videos, and books. Some popular websites
are Codecademy and W3Schools. However, there are many
more, so feel free to experiment!
■ Sign up for an account if you have chosen a website.
You will be able to save your progress this way.
■ If you have chosen videos, bookmark all the videos
you will need.
■ Go to your local library or bookstore if you have
chosen the book route. If you want something
cheaper (or even free), download eBooks or PDF
files.
6
Basics in Web Design
■ If you are willing to pay, you might be able to get individualized sections
from a professional web designer.
Figure out how much time you will need. You will need to figure out how to fit
this into your day if you are a busy person.
Download a web design program if you have not already. While Notepad will
work, it is a good idea to have a program like Adobe Dreamweaver, Microsoft
Expression Web, or KompoZer. There are many, many others, so browse around
and get what you like.
Learning
Get started with HTML. HTML is an absolute requirement for any web designer.
Master the concept of tags, classes, IDs, inputs, etc.
■ The newest version of HTML is HTML5. HTML5 incorporates some new
technologies, so that is probably the best one to learn.
■ XHTML is also an option, but it is a little bit stricter in its rules.
Learn CSS. CSS stands for «Cascading Style Sheet». Without CSS, there would
not be the pretty designs you see on some websites. HTML is merely the skeleton,
but CSS is what makes a website colorful and pretty.
■ CSS is a bit stricter in its rules. For instance, if you forgot to put a
semicolon at the end of each line, you could be in for some headaches
trying to figure out what went wrong.
Learn JavaScript and jQuery. This is optional for ones that plan to make simple
website, but it is essential if you want interactive websites.
7
Basic Computer Coding: HTML
8
Basics in Web Design
9
Basic Computer Coding: HTML
that knowledge for future generations. Publish it on the web to share it, and put
a back-up copy of it onto a CD for safe keeping. Your family tree, your photos,
your stories, everything you add to your site can be saved for the future. It will
not fade or rot like paper and photo prints. It can be replicated in its entirety in
a few minutes and it can be sent around the world in a matter of moments. Start
now and in a generation or two your family will know their history like very few
of us do today.
Many of you, however, would like to either obtain or at least supplement their
income by creating web pages for others. There is not often too much money to
be made in producing web sites for individuals to show off their family portraits,
which means the targets will probably be businesses. Most large businesses either
develop their websites in-house or outsource the job to one of the many businesses
that have been providing web site development services for some time. This leaves
the smaller businesses. For every small business that has its own site, there must
be hundreds within a short distance that do not have one, but could definitely use
one. With the idea of providing some food for sales thought, we take a look here
at some of the reasons small business use websites. The first reason might seem
to be the most obvious; on looking closer we might revise our thought. Businesses
want to sell something. This results in first thought being that the business website
should sell something. This would suggest E-commerce. Such a site might well be
the answer for the business but is it really where they should start? The process
of selling something has several stages to it. You have to have a product. You let
people know about your product, persuading them of its virtues. Once they are
considering purchasing, you have to close the deal. Finally you fulfill. E-commerce
can be involved all of these steps, except the first.
10
Basics in Web Design
11
Basic Computer Coding: HTML
Remember
You must
secure
space on a server
where the files of
your website will
be accessible on When Tim Berners-Lee first created ENQUIRE (the
the Internet. This
server is referred precursor to the web), he had a vision of an information
to as a web host. super highway freely traveled by all. While still in its infancy,
the World Wide Web promised an unfettered access to
information, community and, yes, business opportunities.
However, as the web was slowly taking shape, that freedom
appeared to be threatened from within, and there was a
good chance that the internet we enjoy today might collapse
under its own potential.
12
Basics in Web Design
for the internet. These would become the rulebook which would guide the work
of programmers and software developers in the future, hopefully ensuring the
continued growth and accessibility of the internet. In 1998, an independent group
of web designers and developers formed the Web Standards Project (WaSP). Its
mission was to refine and promote the W3C’s list of best practices and end the
browser wars once and for all. WaSP was successful, and the vision of a freely
traveled information highway was largely realized. Today, WaSP continues to work
toward keeping the internet free, open, and accessible to all.
13
Basic Computer Coding: HTML
14
Basics in Web Design
HTML5 and XHTML). As a markup language, the HTML variants are used
to modify different types of content in an online document. The elements
that make up these languages specify how each bit of content should be
rendered in a web browser (i.e. headings, paragraphs, bullet lists, etc.).
While the basic markup elements define the actual content, the use of
additional attributes serve to provide more specific information about
that content.
short, the use of CSS allows web developers to more artfully control the
formatting and layout of a document. This allows web developers to easily
change backgrounds, alter fonts and text sizes, and reposition content on
a web page. While much of this is possible with basic HTML, the use of
CSS allows programmers and web developers to produce content that is
underpinned by a more streamlined and efficient code.
■ JavaScript is an object-oriented scripting language. It is primarily used to
add behavior to a web page. It can be used to validate data on a form,
provide drag-and-drop functions, enable button functions, and animate
page elements. JavaScript is instrumental in making web pages more
interactive, allowing them to more accurately respond to user events such
as mouse clicks, page navigation, and inputted searches.
These are the basic fundamentals of programming and web design as laid
out by the W3C and the Web Standards Project. More than simply a set of ‘best
practices’, adherence to their use ensures the continued development and expansion
of the World Wide Web.
16
Basics in Web Design
Early Networks
The first computer networks were dedicated special-purpose
systems such as SABRE (an airline reservation system) and
AUTODIN I (a defense command-and-control system), both
designed and implemented in the late 1950s and early 1960s.
By the early 1960s computer manufacturers had begun to use
semiconductor technology in commercial products, and both
conventional batch-processing and time-sharing systems were
in place in many large, technologically advanced companies.
Time-sharing systems allowed a computer’s resources to be
shared in rapid succession with multiple users, cycling through
Keyword
the queue of users so quickly that the computer appeared
Modem is
dedicated to each user’s tasks despite the existence of many
a network
others accessing the system “simultaneously.” This led to the hardware
notion of sharing computer resources (called host computers or device that
simply hosts) over an entire network. Host-to-host interactions modulates one
were envisioned, along with access to specialized resources or more carrier
(such as supercomputers and mass storage systems) and wave signals to
interactive access by remote users to the computational powers encode digital
of time-sharing systems located elsewhere. information for
transmission and
These ideas were first realized in ARPANET, which demodulates
established the first host-to-host network connection on Oct. 29, signals to decode
1969. It was created by the Advanced Research Projects Agency the transmitted
(ARPA) of the U.S. Department of Defense. ARPANET was one information.
of the first general-purpose computer networks. It connected
time-sharing computers at government-supported research
sites, principally universities in the United States, and it soon
became a critical piece of infrastructure for the computer
science research community in the United States. Tools and
applications—such as the simple mail transfer protocol (SMTP,
commonly referred to as e-mail), for sending short messages,
and the file transfer protocol (FTP), for longer transmissions—
quickly emerged. In order to achieve cost-effective interactive
17
Basic Computer Coding: HTML
Commercial packet networks were introduced in the 1970s, but these were
designed principally to provide efficient access to remote computers by dedicated
terminals. Briefly, they replaced long-distance modem connections by less-expensive
“virtual” circuits over packet networks. In the United States, Telenet and Tymnet
were two such packet networks. Neither supported host-to-host communications;
in the 1970s this was still the province of the research networks, and it would
.remain so for many years
DARPA (Defense Advanced Research Projects Agency; formerly ARPA)
supported initiatives for ground-based and satellite-based packet networks. The
ground-based packet radio system provided mobile access to computing resources,
while the packet satellite network connected the United States with several European
countries and enabled connections with widely dispersed and remote regions.
With the introduction of packet radio, connecting a mobile terminal to a computer
network became feasible. However, time-sharing systems were then still too large,
unwieldy, and costly to be mobile or even to exist outside a climate-controlled
computing environment.
A strong motivation thus existed to connect the packet radio network to
ARPANET in order to allow mobile users with simple terminals to access the time-
sharing systems for which they had authorization. Similarly, the packet satellite
network was used by DARPA to link the United States with satellite terminals
serving the United Kingdom, Norway, Germany, and Italy.
These terminals, however, had to be connected to other networks in European
countries in order to reach the end users. Thus arose the need to connect the packet
satellite net, as well as the packet radio net, with other networks.
18
Basics in Web Design
By the 1980s other U.S. governmental bodies were heavily involved with
networking, including the National Science Foundation (NSF), the Department of
Energy, and the National Aeronautics and Space Administration (NASA). While
DARPA had played a seminal role in creating a small-scale version of the Internet
among its researchers, NSF worked with DARPA to expand access to the entire
scientific and academic community and to make TCP/IP the standard in all federally
supported research networks. In 1985–86 NSF funded the first five supercomputing
centers—at Princeton University, the University of Pittsburgh, the University of
California, San Diego, the University of Illinois, and Cornell University. In the
1980s NSF also funded the development and operation of the NSFNET, a national
“backbone” network to connect these centers. By the late 1980s the network was
operating at millions of bits per second. NSF also funded various nonprofit local and
regional networks to connect other users to the NSFNET. A few commercial networks
19
Basic Computer Coding: HTML
also began in the late 1980s; these were soon joined by others, and the Commercial
Internet Exchange (CIX) was formed to allow transit traffic between commercial
networks that otherwise would not have been allowed on the NSFNET backbone.
In 1995, after extensive review of the situation, NSF decided that support of the
NSFNET infrastructure was no longer required, since many commercial providers
were now willing and able to meet the needs of the research community, and its
support was withdrawn.
Meanwhile, NSF had fostered a competitive collection of commercial Internet
backbones connected to one another through so-called network access points (NAPs).
From the Internet’s origin in the early 1970s, control of it steadily devolved
from government stewardship to private-sector participation and finally to private
custody with government oversight and forbearance. Today a loosely structured
group of several thousand interested individuals known as the Internet Engineering
Task Force participates in a grassroots development process for Internet standards.
Internet standards are maintained by the nonprofit Internet Society, an international
body with headquarters in Reston, Virginia. The Internet Corporation for Assigned
Names and Numbers (ICANN), another nonprofit, private organization, oversees
various aspects of policy regarding Internet domain names and numbers.
Commercial Expansion
The rise of commercial Internet services and applications helped to fuel a rapid
commercialization of the Internet. This phenomenon was the result of several other
factors as well. One important factor was the introduction of the personal computer
and the workstation in the early 1980s—a development that in turn was fueled by
unprecedented progress in integrated circuit technology and an attendant rapid
decline in computer prices.
Another factor, which took on increasing importance, was the emergence of
Ethernet and other “local area networks” to link personal computers. But other
forces were at work too. Following the restructuring of AT&T in 1984, NSF took
advantage of various new options for national-level digital backbone services for
the NSFNET. In 1988 the Corporation for National Research Initiatives received
approval to conduct an experiment linking a commercial e-mail service (MCI Mail)
to the Internet. This application was the first Internet connection to a commercial
provider that was not also part of the research community. Approval quickly
followed to allow other e-mail providers access, and the Internet began its first
explosion in traffic.
In 1993 federal legislation allowed NSF to open the NSFNET backbone to
commercial users. Prior to that time, use of the backbone was subject to an “acceptable
use” policy, established and administered by NSF, under which commercial use was
limited to those applications that served the research community. NSF recognized
that commercially supplied network services, now that they were available, would
ultimately be far less expensive than continued funding of special-purpose network
services.
20
Basics in Web Design
Also in 1993 the University of Illinois made widely available Mosaic, a new type
of computer program, known as a browser, that ran on most types of computers and,
through its “point-and-click” interface, simplified access, retrieval, and display of
files through the Internet. Mosaic incorporated a set of access protocols and display
standards originally developed at the European Organization for Nuclear Research
(CERN) by Tim Berners-Lee for a new Internet application called the World Wide
Web (WWW). In 1994 Netscape Communications Corporation (originally called
Mosaic Communications Corporation) was formed to further develop the Mosaic
browser and server software for commercial use. Shortly thereafter, the software
giant Microsoft Corporation became interested in supporting Internet applications
on personal computers (PCs) and developed its Internet Explorer Web browser
(based initially on Mosaic) and other programs. These new commercial capabilities
accelerated the growth of the Internet, which as early as 1988 had already been
growing at the rate of 100 % per year.
By the late 1990s there were approximately 10,000 Internet service providers (ISPs)
around the world, more than half located in the United States. However, most of
these ISPs provided only local service and relied on access to regional and national
ISPs for wider connectivity. Consolidation began at the end of the decade, with many
small to medium-size providers merging or being acquired by larger ISPs. Among
these larger providers were groups such as America Online, Inc. (AOL), which
started as a dial-up information service with no Internet connectivity but made a
transition in the late 1990s to become the leading provider of Internet services in
the world—with more than 25 million subscribers by 2000 and with branches in
Australia, Europe, South America, and Asia. Widely used Internet “portals” such
as AOL, Yahoo!, Excite, and others were able to command advertising fees owing
to the number of “eyeballs” that visited their sites. Indeed, during the late 1990s
advertising revenue became the main quest of many Internet sites, some of which
began to speculate by offering free or low-cost services of various kinds that were
visually augmented with advertisements. By 2001 this speculative bubble had burst.
21
Basic Computer Coding: HTML
Future Directions
While the precise structure of the future Internet is not yet clear, many directions
of growth seem apparent. One is the increased availability of wireless access.
Wireless services enable applications not previously possible in any economical
fashion. For example, global positioning systems (GPS) combined with wireless
Internet access would help mobile users to locate alternate routes, generate precise
accident reports and initiate recovery services, and improve traffic management and
congestion control. In addition to wireless laptop computers and personal digital
assistants (PDAs), wearable devices with voice input and special display glasses
are under development.
22
Basics in Web Design
23
Basic Computer Coding: HTML
Pakistan, and Vietnam had less than 10 %. South Korea was the world leader in
connecting its population to the Internet through high-speed broadband connections.
Such statistics can chart the Internet’s growth, but they offer few insights into
the changes wrought as users—individuals, groups, corporations, and governments—
have embedded the technology into everyday life. The Internet is now as much a
lived experience as a tool for performing particular tasks, offering the possibility
of creating an environment or virtual reality in which individuals might work,
socially interact with others, and perhaps even live out their lives.
Two agendas
The Internet has evolved from the integration of two very different technological
agendas—the Cold War networking of the U.S. military and the personal
computer (PC) revolution. The first agenda can be dated to 1973, when the Defense
Advanced Research Projects Agency (DARPA) sought to create a communications
network that would support the transfer of large data files between government and
government-sponsored academic-research laboratories. The result was the ARPANET,
a robust decentralized network that supported a vast array of computer hardware.
Initially, ARPANET was the preserve of academics and corporate researchers with
24
Basics in Web Design
The WELL
Why does this matter? The military played an essential role in shaping the Internet’s
architecture, but it was through the counterculture that many of the practices
of contemporary online life emerged. A telling example is the early electronic
bulletin board system (BBS), such as the WELL (Whole Earth ’Lectronic Link).
Established in 1985 by American publisher Stewart Brand, who viewed the
BBS as an extension of his Whole Earth Catalog, the WELL was one of the first
electronic communities organized around forums dedicated to particular subjects
such as parenting and Grateful Dead concerts. The latter were an especially popular
topic of online conversation, but it was in the parenting forum where a profound
sense of community and belonging initially appeared. For example, when one
participant’s child was diagnosed with leukemia, members of the forum went out
of their way either to find health resources or to comfort the distressed parents. In
this one instance, several features still prevalent in the online world can be seen.
First, geography was irrelevant. WELL members in California and New York could
bring their knowledge together within the confines of a forum—and could do so
collectively, often exceeding the experience available to any local physician or medical
center. This marshaling of shared resources persists to this day as many individuals
use the Internet to learn more about their ailments, find others who suffer from
the same disease, and learn about drugs, physicians, and alternative therapies.
25
Basic Computer Coding: HTML
26
Basics in Web Design
27
Basic Computer Coding: HTML
many Haitians lacking Internet access were able to contribute updates via text
messaging on mobile phones.
28
Basics in Web Design
29
Basic Computer Coding: HTML
Education
Commerce and industry are certainly arenas in which the Internet has had a
profound effect, but what of the foundational institutions of any society—namely,
those related to education and the production of knowledge? Here the Internet
has had a variety of effects, some of which are quite disturbing. There are more
computers in the classroom than ever before, but there is scant evidence that
they enhance the learning of basic skills in reading, writing, and arithmetic. And
while access to vast amounts of digital information is convenient, it has also become
apparent that most students now see libraries as antiquated institutions better
used for their computer terminals than for their book collections. As teachers at
all education levels can attest, students typically prefer to research their papers by
reading online rather than wandering through a library’s stacks.
In a related effect the Internet has brought plagiarism into the computer era in
two distinct senses. First, electronic texts have made it simple for students to “cut
and paste” published sources into their own papers. Second, although students
could always get someone to write their papers for them, it is now much easier to
find and purchase anonymous papers at Web sites and to even commission original
30
Basics in Web Design
term papers for a fixed fee. Ironically, what the Internet gives,
it also takes away. Teachers now have access to databases
of electronically submitted papers and can easily compare
their own students’ papers against a vast archive of sources.
Even a simple online search can sometimes find where one
particularly well-turned phrase originally appeared. Keyword
Database
File sharing is an
organized
College students have been at the leading edge of the growing collection of
awareness of the centrality of intellectual property in a data, stored
digital age. When American college student Shawn Fanning and accessed
invented Napster in 1999, he set in motion an ongoing legal electronically.
battle over digital rights. Napster was a file-sharing system
that allowed users to share electronic copies of music online.
The problem was obvious: recording companies were losing
revenues as one legal copy of a song was shared among
many people. Although the record companies succeeded in
shutting down Napster, they found themselves having to
contend with a new form of file sharing, P2P (“person-to-
person”). In P2P there is no central administrator to shut
down as there had been with Napster. Initially, the recording
industry sued the makers of P2P software and a few of the
most prolific users—often students located on university
campuses with access to high-speed connections for serving
music and, later, movie files—in an attempt to discourage
the millions of people who regularly used the software.
Still, even while some P2P software makers have been held
liable for losses that the copyright owners have incurred,
more-devious schemes for circumventing apprehension have
been invented.
The inability to prevent file sharing has led the recording
and movie industries to devise sophisticated copy protection
on their CDs and DVDs. In a particularly controversial
incident, Sony Corporation introduced CDs into the market
with copy protection that involved a special virus 2005 in
like code that hid on a user’s computer. This code, however,
also was open to being exploited by virus writers to gain
.control of users’ machines
Electronic publishing
The Internet has become an invaluable and discipline-
transforming environment for scientists and scholars. In
2004 Google began digitizing public-domain and out-of-
print materials from several cooperating libraries in North
31
Basic Computer Coding: HTML
America and Europe, such as the University of Michigan library, which made
some seven million volumes available. Although some researchers and publishers
challenged the project for fear of losing control of copyrighted material, similar
digitization projects were launched by Microsoft Corporation and the online book
vendor [Link], although the latter company proposed that each electronic
page would be retrieved for a small fee shared with the copyright holders.
The majority of academic journals are now online and searchable. This has created
a revolution in scholarly publishing, especially in the sciences and engineering.
For example, [Link] has transformed the rate at which scientists publish and
react to new theories and experimental data. Begun in 1991, [Link] is an online
archive in which physicists, mathematicians, computer scientists, and computational
biologists upload research papers long before they will appear in a print journal.
The articles are then open to the scrutiny of the entire scientific community, rather
than to one or two referees selected by a journal editor. In this way scientists around
the world can receive an abstract of a paper as soon as it has been uploaded into
the depository. If the abstract piques a reader’s interest, the entire paper can be
downloaded for study. Cornell University in Ithaca, New York, and the U.S. National
Science Foundation support [Link] as an international resource.
While [Link] deals with articles that might ultimately appear in print, it is
also part of a larger shift in the nature of scientific publishing. In the print world
a handful of companies control the publication of the most scientific journals, and
the price of institutional subscriptions is frequently exorbitant. This has led to a
growing movement to create online-only journals that are accessible for free to
the entire public—a public that often supports the original research with its taxes.
For example, the Public Library of Science publishes online journals of biology
and medicine that compete with traditional print journals. There is no difference
in how their articles are vetted for publication; the difference is that the material
is made available for free. Unlike other creators of content, academics are not
paid for what they publish in scholarly journals, nor are those who review the
articles. Journal publishers, on the other hand, have long received subsidies from
the scientific community, even while charging that community high prices for its
own work. Although some commercial journals have reputations that can advance
the careers of those who publish in them, the U.S. government has taken the side
of the “open source” publishers and demanded that government-financed research
be made available to taxpayers as soon as it has been published.
In addition to serving as a medium for the exchange of articles, the Internet
can facilitate the discussion of scientific work long before it appears in print.
Scientific blogs—online journals kept by individuals or groups of researchers—have
flourished as a form of online salon for the discussion of ongoing research. There
are pitfalls to such practices, though. Astronomers who in 2005 posted abstracts
detailing the discovery of a potential 10th planet found that other researchers had
used their abstracts to find the new astronomical body themselves. In order to
claim priority of discovery, the original group rushed to hold a news conference
rather than waiting to announce their work at an academic conference or in a
peer-reviewed journal.
32
Basics in Web Design
34
Basics in Web Design
35
Basic Computer Coding: HTML
use of the new privacy settings. Users tended to fall back on Facebook’s default
settings, which, because of the expansion of Facebook’s “opt-out” policy, were at
the loosest level of security, forcing users to “opt-in” to make information private.
Responding to criticism, Facebook revised its privacy policy again in May 2010,
with a simplified system that consolidated privacy settings onto a single page.
Another privacy issue is cyberbullying—using the Internet to threaten or
humiliate another person with words, photos, or videos. The problem received
particular attention in 2010 when a male Rutgers University student committed
suicide after two acquaintances reportedly streamed a video over the Internet of
the student having a sexual encounter with a man. Also in 2010, Donna Witsell,
the mother of a 13-year-old Florida girl who had committed suicide in 2009 after
a cyberbullying incident, formed a group called Hope’s Warriors to help curb
abuse and to warn others of the threat. Most U.S. states have enacted laws against
bullying, although very few of them include cyberbullying.
36
Basics in Web Design
ROLE MODEL
SIR TIM BERNERS-LEE: BRITISH
SCIENTIST
Sir Tim Berners-Lee is a British computer scientist who invented
what is undoubtedly one of the most revolutionary inventions
of the 20th century—the World Wide Web (WWW). A qualified
software engineer who was working at CERN when he came
up with the idea of a global network system, Sir Tim is also
credited for creating the world’s first web browser and editor. He founded the World
Wide Web Foundation and directs the World Wide Web Consortium (W3C). Both of
his parents worked on the Ferranti Mark I, the first commercial computer, and thus it
is not surprising that he too chose the field of computers. But what is surprising is the
phenomenal impact his idea of a global network has had on the world of information
and technology. An alumnus of the University of Oxford, he realized the need for a
global communication network while working at CERN as the researchers from all over
the world needed to share their data with each other. By the late 1980s he had drawn
up a proposal for creating a global hypertext document system using the internet. A
few more years of pioneering work in the field led to the birth of the World Wide
Web making Berners-Lee one of the most significant inventors of the modern era.
Career
■ He was appointed as an engineer at the telecommunications company,
Plessey in Poole after completing his studies. He remained there for two
years, working on distributed transaction systems, message relays, and
bar code technology.
■ He left Plessey in 1978 and joined D. G. Nash Ltd. In this job he wrote
typesetting software for intelligent printers and a multitasking operating
system.
37
Basic Computer Coding: HTML
Major Works
■ His invention, the World Wide Web, is counted among the most significant
inventions of the 20th century. The web revolutionized the world of
information and technology and has opened up several new avenues.
38
Basics in Web Design
39
Basic Computer Coding: HTML
SUMMARY
■ Web design has numerous components that work together to create the
finished experience of a website, including graphic design, user experience
design, interface design, search engine optimization (SEO) and content
creation.
■ Web design encompasses many different skills and disciplines in the
production and maintenance of websites. The different areas of web
design include web graphic design; interface design; authoring, including
standardized code and proprietary software; user experience design; and
search engine optimization.
■ Web site, Collection of files and related resources accessible through the
World Wide Web and organized under a particular domain name.
■ A hypertext document with its corresponding text and hyperlinks is written
in Hypertext Markup Language (HTML) and is assigned an online address
called a Uniform Resource Locator (URL).
■ Web Standards is defined as a formal set of standards and technical
specifications used to define aspects of the World Wide Web. These are
best-practice standards used by organizations to build web sites and web
applications.
■ HTML5 is the latest iteration of the basic HTML markup language. It
introduces some new rules and features, while discarding some of the
elements from before versions.
■ CSS (Cascading Style Sheets) provide the mechanism by which changes
in the appearance or position of online content can be assigned to a
document’s HTML or XHTML elements.
■ Internet, a system architecture that has revolutionized communications
and methods of commerce by allowing various computer networks around
the world to interconnect.
■ The Internet was the result of some visionary thinking by people in the
early 1960s who saw great potential value in allowing computers to share
information on research and development in scientific and military fields.
40
Basics in Web Design
KNOWLEDGE CHECK
1. What is a CMS in web design?
a. Content Management System
b. Creative Management System
c. Content Mixing System
d. Creatives Managerial System
2. To make your website mobile friendly, you can make your website
a. Responsive
b. Reactive
c. Fast Loading
d. Light
3. What does CSS stand for
a. Current Style Sheets
b. Current Sheets Style
c. Cascading Style Sheets
d. Cascading Sheets Style
4. Which of the following statements is false
a. You can make a website without using HTML
b. You can make a website without using PHP
c. You can make a website without using CSS
d. You can make a website without using JavaScript
5. What is WordPress
a. It is a software used to press text
b. It is a text formatting software
c. It is a CMS (Content Management System)
d. It is mail service
6. SQL stands for
a. Structured Query Language
b. Statistical Query Language
c. Superior Questions Lot
d. Standard Query Lot
7. Which of the following is true about JavaScript
a. It is a server side scripting language
b. It is client side scripting language
c. It is a Software
d. It is a database
41
Basic Computer Coding: HTML
42
Basics in Web Design
15. What does the acronym API stand for in the context of web development?
a. Advanced Programming Interface
b. Application Programming Interface
c. Advanced Protocol Integration
d. Application Protocol Interface
16. What is the purpose of the JavaScript [Link]() function?
a. To retrieve a CSS style
b. To access an HTML element by its ID
c. To define a new HTML element
d. To create a new JavaScript variable
REVIEW QUESTIONS
1. What do you understand by web design?
2. How do you learn web design?
3. What do you mean by web site? Also define why create a website?
4. Write a short note on World Wide Web.
5. Discuss about web standards.
6. Explain the origin and development of internet.
7. What was the original purpose of ARPANET, the precursor to the modern
internet?
8. What is the significance of the TCP/IP protocol in the development of the
internet?
43
Basic Computer Coding: HTML
REFERENCES
1. Barrell, Dylan. Agile Accessibility Explained: A practical guide to sustainable
accessible software development, Amazon Digital Services, 2019.
2. Blanck, Peter. eQuality: The Struggle for Web Accessibility by Persons with
Cognitive Disabilities, Cambridge Disability Law and Policy Series, 2015.
3. Burgstahle, Sheryl. Universal Design in Higher Education: From Principles
to Practice, Harvard Education Press, 2008.
4. Chisholm, and May. Universal Design for Web Applications: Web Applications
That Reach Everyone, O’Reilly Media, 2008.
5. Feingold , [Link] Negotiation: A Winning Alternative to Lawsuits
, American Bar Association, 2016.
6. Gilbert, Regine M. Inclusive Design for a Digital World: Designing with
Accessibility in Mind (Design Thinking), Apress, 2020.
7. Hamraie, Aimi. Building Access: Universal Design and the Politics of Disability,
University Of Minnesota Press, 2017.
8. Hassell, Jonathan. Including your missing 20% by embedding web and mobile
accessibility, BSI British Standards Institution, 2014.
9. Horton, Sarah and Quesenbery, Whitney. Universal Design for Web
Accessibility, Rosenfeld Media, 2014.
10. Lazar, Jonathan; Goldstein, Daniel; and Taylor, Anne . Ensuring Digital
Accessibility through Process and Policy, Morgan Kaufmann, 2015.
11. McCall, Karen. Accessible and Usable PDF Documents: Techniques for
Document Authors, Fourth Edition , [Link], 2017.
12. McCall, Karen. Styles in Word: A Primer for Accessible Document Design ,
[Link], 2017.
13. Meloncon, Lisa. Rhetorical AccessAbility: At the Intersection of Technical
Communication and Disability Studies , Baywood Publishing Company Inc.,
2013.
14. Connor, Joshue. Pro HTML5 Accessibility, Apress, 2012.
15. Paciello, Michael G. Web Accessibility for People With Disabilities, CMP
Books, 2000.
16. Pickering, Heydon. Apps For All: Coding Accessible Web Applications,
Smashing Magazine GmbH, 2014.
17. Pickering, Heydon. Inclusive Design Components: The Book, Smashing Magazine, 2019.
44
CHAPTER 2
WEB DESIGN
PRINCIPLES
LEARNING OBJECTIVES
on either side of a central point, providing a sense of stability. On the other hand,
asymmetrical balance involves arranging elements of varying size and weight to
achieve equilibrium, often resulting in a more dynamic and modern look.
Contrast is another critical principle that involves highlighting the differences
between elements. This can be achieved through variations in color, size, or
typography, drawing attention to specific areas of the website and creating visual
interest. Contrast not only enhances the visual hierarchy but also contributes to
the overall readability and accessibility of the content.
Emphasis is the principle that guides designers in determining the focal points
of a webpage. By strategically emphasizing certain elements, such as headlines,
images, or calls-to-action, designers can guide the user’s attention and convey the
most important information effectively.
The principle of repetition involves the consistent use of visual elements
throughout the design, providing a sense of unity and cohesion. Repetition creates
a predictable and familiar rhythm, making the website more intuitive for users
to navigate. Consistent use of fonts, colors, and styling elements contributes to a
cohesive and professional appearance.
Proximity is the principle that deals with the placement of elements in relation
to each other. Items that are related or function together should be grouped closely
to establish visual connections. Effective use of proximity helps users understand
the relationships between different pieces of content and enhances overall clarity.
46
Web Design Principles
47
Basic Computer Coding: HTML
example, Fonts like Verdana, Times New Roman, Arial, etc. are simple
fonts that almost everyone can easily read online. Similarly, the font size
that works the best is 16 px but you can be a little flexible with it.
■ Colors – As far as the user experience is concerned, your color scheme
and contrast must be well thought of and should be able to create visual
harmony and balance. It is always better to choose contrasting colors for
the background and written content so that it can be easily read. Choose
a darker text color and a lighter background shade so that the result is
easy to the eyes. Extra bright colors must be used sparingly.
■ Images – Do you know that the human mind perceives and processes
images a lot faster than text? Well, it is thus a good idea to choose and
place the right images on your web pages to communicate with the
audiences in a better way. Make sure they are high-quality images and
are suitable for your purpose.
48
Web Design Principles
50
Web Design Principles
51
Basic Computer Coding: HTML
52
Web Design Principles
53
Basic Computer Coding: HTML
54
Web Design Principles
to be sure that all of the code written for your web site
validates. Valid code means that your site meets the current
web development standards – this is helpful when checking
for issues such as cross-browser compatibility as mentioned
above.
Once you give your web designer final approval, it is time
Did You
to deliver the site. An FTP (File Transfer Protocol) program Know?
is used to upload the web site files to your server. Some web The
designers offer domain name registration and web hosting World Wide Web
(WWW) was
services as well, or have recommendations as to where you created in 1990
can host your site. Once these accounts have been setup, and by the British
your web site uploaded to the server, the site should be put CERN physicist
through one last run-through. This is just precautionary, to Tim Berners-Lee.
confirm that all files have been uploaded correctly, and that
the site continues to be fully functional.
Other final details include plugin installation (for
WordPress or other CMS driven web sites and SEO (Search
Engine Optimization). SEO is the optimization of your web
site with elements such as title, description and keyword
tags which help your web site achieve higher rankings in the
search engines. The previously mentioned code validation is
something that plays a vital role in SEO, as well. There are
many WordPress plugins available that further enhance the
default WordPress functionality – many of which directly
relate to improving your SEO, as well.
■ Your website’s pages may be easier to visualize if you draw rough pictures
of each of them rather than just determining what content should appear.
3. Use intuitive design. While there›s something to be said for fresh ideas,
your website›s basic design should follow established guidelines such as
the following:
■ Navigation options (e.g., tabs for different webpages) should go at the
top of the page.
■ If you use a menu icon (☰), it should be in the top-left corner of the page.
■ If you use a search bar, it should be near the upper-right side of the page.
■ Helpful links (e.g., links to the “About” page or the “Contact Us” page)
should go at the very bottom of each page.
4. Be consistent. Whatever text font, color palette, image theme, and design
options you choose, make sure that you use the same decision throughout
your website. It can be incredibly jarring to see one font or color scheme
used for the «About» page when a completely different one was used for
the home page.
■ For example, if you exclusively use cool-tone colors for your site’s home
page, don’t implement bright, loud colors on the next page.
■ Keep in mind that using loud or clashing colors, especially when the
colors display in a dynamic (e.g., moving) fashion, can evoke epilepsy in
a small number of web users. If you decide to use such colors on your
site, make sure you add an epilepsy warning before any relevant pages.
57
Basic Computer Coding: HTML
58
Web Design Principles
59
Basic Computer Coding: HTML
Steps
1. Decide what your website topic is. There are millions of different kinds of
websites that you can choose to your liking.
2. Find the right color scheme. Try using colors that will pop out, like blue, purple
or orange. You can also adjust the color to the topic of your website.
60
Web Design Principles
3. Decide what kind of navigation bar to use. Make sure it has useful resources,
such as home, comments, and more.
4. Mock up how your website will be laid out in a graphic editing program. Just
like the topics, there are wide choices on how you would like the layout of each
page to be.
5. Create the page in HTML. You can also create it by going onto Google websites.
Be sure to pick a creative name too!
61
Basic Computer Coding: HTML
7. Duplicate the HTML page for the other pages and add
content. This article is just an in-depth for layouts.
63
Basic Computer Coding: HTML
64
Web Design Principles
2.5.3 Implementation
Once the layout and designed are finalized in the sketch which gives the basic
idea of how the web page renders in different viewports, following the mobile first
principle the first web page was designed for mobile using Dreamweaver CS5. Web
development software, used for creating static and dynamic web applications and
web pages. The created product was installed on a desktop local server and tested
with latest browsers. The implementation procedures are briefly described below.
After the installation of Dreamweaver web platform, the new HTML5 project
was created.
The Clientside is the name of the folder that represents the public_html folder
where a website’s index page is normally stored. It contains the entire required
folder for storing CSS, JavaScript and HTML5 files, which is good practice because
it makes it easy to navigate between files and locate the files when needed. The
actual implementation of the requirement was started after creating this folder
structure. Necessary files for each type of document were placed in their respective
folders. The prototype was designed for adaptive and responsive web layout. For
this reason flexible grid, flexible media, and media queries were implemented.
For the flexible grid, the width of the container was calculated from the context
formula.
#wrapper aside {
margin:1%;
float:left;
width:40%;
box-shadow:0px 0px 3px 1px #888;
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
padding:2%;
min-height:10px;
}
#wrapper section{
margin:1%;
float:right;
width:56%;
box-shadow:0px 0px 3px 1px #888;
65
Basic Computer Coding: HTML
-webkit-border-radius: 10px;
-moz-border-radius: 10px;
border-radius: 10px;
padding:2%;
min-height:100px;
}
The web page has main two containers excluding the
header and footer. These two containers width was defined
in a percentage value so that the containers were flexible
when the width of browser narrowed down. The width of
both containers is 96% of the viewports width. The 4% of
width was used for the margin of the container.
Similarly, the page has two embedded videos in the aside
container. For the demonstration purpose the video container
was used for flexible media. For the flexible media, the video
container defines as maximum width 100%. Finally, to achieve
real adaptive and responsive design the CSS media queries
were implemented inside the [Link] file. The file
Keyword has several breakpoint conditions to achieve different layouts
Media for appropriate viewports. This is a simple prototype, so two
queries is a breakpoint conditions were used. The breakpoint condition can
feature of CSS 3 vary according to the list of the supported viewport. If none
allowing content of these conditions are matched then a default CSS would
rendering to be applied for the web page. Those conditions that are not
adapt to different defined in this breakpoint are default.
conditions
such as screen @media only screen and (min-width :320px) and (max-
resolution. width:600px){ // CSS style }
@media only screen and (min-width: 600px) and (max-
width: 1024px){ // CSS style }
For example as shown in listing 4, if the media type is
screen and the minimum width is 320 pixels to maximum
width is 600 pixels, which is the range of a mobile and small
tablet’s viewport, the first condition will be true and all the
CSS properties defined inside these conditions will be applied.
66
Web Design Principles
SUMMARY
■ Web design is not only about how the website looks and feels but is also
a lot about how it works and responds. When web designers work on a
website, they incorporate not just those elements that add a visual appeal
to it but also try to make it highly responsive, functional, quick and useful.
■ Communication between both you and your designer is crucial to ensure
that the final web site will match your needs and taste. It is important
that you work closely with your designer, exchanging ideas, until you
arrive at the final design for your web site.
■ Elements such as the CMS (content management system) like WordPress,
interactive contact forms, or ecommerce shopping carts are implemented
and made functional during this phase, as well.
■ A good web designer is one who is well versed in current standards for
web site design and development. The basic technologies currently used
are HTML and CSS (Cascading Style Sheets).
■ Web development software, used for creating static and dynamic web
applications and web pages. The created product was installed on a desktop
local server and tested with latest browsers.
■ The web page has main two containers excluding the header and footer.
These two containers width was defined in a percentage value so that the
containers were flexible when the width of browser narrowed down. The
width of both containers is 96% of the viewports width. The 4% of width
was used for the margin of the container.
67
Basic Computer Coding: HTML
KNOWLEDGE CHECK
1. The first page of a website is called?
a. Design page
b. Home page
c. First page
d. Main page
2. Which of the following statements is true
a. The web designer shouldn’t just be concerned about the looks but also
about user interface
b. Usability is very important in web design
c. a and b
d. None of the above
3. Which of the following is not a web hosting company
a. Hostgator
b. Blue Host
c. WPX Hosting
d. Facebook
4. A web designer works on the appearance, layout, and, in some cases, content
of a website.
a. True
b. False
5. Web design takes into consideration a concept called ‘Visible language’.
a. True
b. False
6. Which statement best describes how a web user reads a website?
a. They don’t they only ever look at pictures
b. Scan the site looking for content
c. Carefully read every word that is written
d. None of these
7. URL is an acronym for
a. Universal research locator
b. Universal resource locator
c. Uniform research locator
d. Uniform resource locator
8. [Link] was developed by
a. Cambridge university
68
Web Design Principles
b. California university
c. Carnegie-Mellon university
d. None of the above
9. TCP is an acronym for
a. Transmission control protocol
b. Transit control protocol
c. Transmission calling protocol
d. None of the above
10. Which of the following statements is true
a. The web designer shouldn’t just be concerned about the looks but also
about user interface
b. Usability is very important in web design
c. a and b
d. None of the above
11. Which principle emphasizes creating a consistent and predictable rhythm
in the design?
a. Contrast
b. Proximity
c. Repetition
d. Alignment
12. What does the term “Hierarchy” refer to in web design?
a. The order of HTML tags in a document
b. The visual arrangement of elements to imply importance
c. The structure of CSS rules in a stylesheet
d. The placement of images in a design
13. What is the primary purpose of the “Contrast” principle in design?
a. Creating a harmonious color palette
b. Making elements stand out from one another
c. Ensuring elements are close to each other
d. Achieving a balanced layout
14. Which principle is concerned with the arrangement of elements along a
straight line or an imaginary axis?
a. Proximity
b. Alignment
c. Repetition
d. Contrast
69
Basic Computer Coding: HTML
REVIEW QUESTIONS
1. What is principle of web design?
2. What is process of Website design?
3. How to design a website?
4. Discuss the prototyping a responsive web page.
5. Describe the five golden rules of responsive web design.
6. How to design a website template?
70
Web Design Principles
REFERENCES
1. Krause, Jim. Color Index: Over 1100 Color Combinations, CMYK and RGB
Formulas, for Print and Web Media, How Design Books, 2002.
2. Pickering, Heydon. Inclusive Design Patterns, Smashing Magazine, 2016.
3. Seale, Jane. E-learning and Disability in Higher Education, Routledge, 2014.
4. Slatin, John M. and Rush, Sharron. Maximum Accessibility: Making Your Web
Site More Usable for Everyone, Addison Wesley Professional, 2002.
5. Sydik, Jeremy. Design Accessible Web Sites, Pragmatic Bookshelf, 2007.
6. Thatcher, Jim et al. Constructing Accessible Web Sites, Glasshaus, 2002.
7. Thatcher, Jim et al. Web Accessibility: Web Standards and Regulatory
Compliance, friends of ED, 2006.
8. Watson, Leonie et al. Practical Approaches For Designing Accessible Websites,
Smashing Magazine GmbH, 2015. (ISBN (EPUB: 978-3-945749-23-4).
9. Nielsen, Jakob (10 November 2003), The Ten Most Violated Homepage Design
Guidelines, Nielsen Norman Group, archived from the original on 5 October
2013
10. Spool, Jared (29 September 2005), Is Home Page Design Relevant Anymore?,
User Interface Engineering, archived from the original on 16 September 2013
11. Porter, Joshua (24 April 2006), Prioritizing Design Time: A Long Tail Approach,
User Interface Engineering, archived from the original on 14 May 2013
12. Spool, Jared (6 August 2007), Usability Tools Podcast: Home Page Design,
archived from the original on 29 April 2013
13. Knight, Kayla (20 August 2009), Essential Tips for Designing an Effective
Homepage, Six Revisions, archived from the original on 21 August 2013
14. Chapman, Cameron (15 September 2010), 10 Usability Tips Based on Research
Studies, Six Revisions, archived from the original on 2 September 2013
15. Bates, Chris (9 October 2012), Best practices in carousel design for effective
web marketing, Smart Insights, archived from the original on 3 April 2013
16. Messner, Katie (22 April 2013), Image Carousels: Getting Control of the Merry-
Go-Round, [Link], archived from the original on 10 October 2013
17. Jones, Harrison (19 June 2013), Homepage Sliders: Bad For SEO, Bad For
Usability, archived from the original on 22 November 2013
71
CHAPTER 3
INTRODUCTION
TO HTML
LEARNING OBJECTIVES
74
Introduction to H T M L
<head>
<title>This is document title</title>
</head>
<body>
<h1>This is a heading</h1>
<p>Document content goes here.....</p>
</body>
</html>
HTML Tags
As told earlier, HTML is a markup language and makes use of various tags
to format the content. These tags are enclosed within angle braces <Tag Name>.
Except few tags, most of the tags have their corresponding closing tags. For
example, <html> has its closing tag </html> and <body> tag has its closing tag </
body> tag etc.
Above example of HTML document uses the following tags −
1 <!DOCTYPE...>
2 <html>
This tag encloses the complete HTML document and mainly comprises of document header which is
represented by <head>...</head> and document body which is represented by <body>...</body> tags.
3 <head>
This tag represents the document’s header which can keep other HTML tags like <title>, <link> etc.
4 <title>
The <title> tag is used inside the <head> tag to mention the document title.
5 <body>
This tag represents the document’s body which keeps other HTML tags like <h1>, <div>, <p> etc.
6 <h1>
76
Introduction to H T M L
<head>
Document header related tags
</head>
<body>
Remember
Document body related tags To learn
HTML,
</body> you will need to
study various
tags and
understand how
</html> they behave,
while formatting
Let’s see what is document declaration tag. a textual
document.
The <!DOCTYPE> Declaration Learning HTML
The <!DOCTYPE> declaration tag is used by the web is simple as users
have to learn the
browser to understand the version of the HTML used in usage of different
the document. tags in order to
Current version of HTML is 5 and it makes use of the format the text
or images to
following declaration − make a beautiful
<!DOCTYPE html> webpage.
There are many other declaration types which can be
used in HTML document depending on what version of
HTML is being used. We will see more details on this while
discussing <!DOCTYPE...> tag along with other HTML tags.
77
Basic Computer Coding: HTML
Heading Tags
Any document starts with a heading. You can use different sizes for your headings.
HTML also has six levels of headings, which use the elements <h1>, <h2>, <h3>,
<h4>, <h5>, and <h6>. While displaying any heading, browser adds one line before
and one line after that heading.
Example:
<!DOCTYPE html>
<html>
<head>
<title>Heading Example</title>
</head>
<body>
<h1>This is heading 1</h1>
<h2>This is heading 2</h2>
<h3>This is heading 3</h3>
<h4>This is heading 4</h4>
<h5>This is heading 5</h5>
<h6>This is heading 6</h6>
</body>
</html>
This will produce the following result −
This is heading 1
This is heading 2
This is heading 3
This is heading 4
This is heading 5
This is heading 6
Paragraph Tag
The <p> tag offers a way to structure your text into different paragraphs. Each
paragraph of text should go in between an opening <p> and a closing </p> tag as
shown below in the example −
Example:
<!DOCTYPE html>
78
Introduction to H T M L
<html>
<head>
<title>Paragraph Example</title>
</head>
<body>
<p>Here is a first paragraph of text.</p>
<p>Here is a second paragraph of text.</p>
<p>Here is a third paragraph of text.</p>
</body>
</html>
This will produce the following result −
Here is a first paragraph of text.
<head>
<title>Line Break Example</title>
</head>
<body>
79
Basic Computer Coding: HTML
<p>Hello<br />
You delivered your assignment ontime.<br />
Thanks<br />
Mahnaz</p>
</body>
</html>
This will produce the following result −
Hello
You delivered your assignment on time.
Thanks
Mahnaz
Centering Content
You can use <center> tag to put any content in the center of the page or any table
cell.
Example:
<!DOCTYPE html>
<html>
<head>
<title>Centring Content Example</title>
</head>
<body>
<p>This text is not in the center.</p>
<center>
<p>This text is in the center.</p>
</center>
</body>
</html>
This will produce following result −
This text is not in the center.
This text is in the center.
80
Introduction to H T M L
Horizontal Lines
Horizontal lines are used to visually break-up sections of a document. The <hr>
tag creates a line from the current position in the document to the right margin
and breaks the line accordingly.
For example, you may want to give a line between two paragraphs as in the
given example below −
Example:
<!DOCTYPE html>
<html>
<head>
<title>Horizontal Line Example</title>
</head>
<body>
<p>This is paragraph one and should be on top</p>
<hr />
<p>This is paragraph two and should be at bottom</p>
</body>
</html>
This will produce the following result −
This is paragraph one and should be on top
This is paragraph two and should be at bottom
Again <hr /> tag is an example of the empty element, where you do not need
opening and closing tags, as there is nothing to go in between them.
The <hr /> element has a space between the characters hr and the forward slash.
If you omit this space, older browsers will have trouble rendering the horizontal
line, while if you miss the forward slash character and just use <hr> it is not valid
in XHTML
Preserve Formatting
Sometimes, you want your text to follow the exact format of how it is written in
the HTML document. In these cases, you can use the preformatted tag <pre>.
Any text between the opening <pre> tag and the closing </pre> tag will preserve
the formatting of the source document.
81
Basic Computer Coding: HTML
Example:
<!DOCTYPE html>
<html>
<head>
<title>Preserve Formatting Example</title>
</head>
<body>
<pre>
function testFunction( strText ){
alert (strText)
}
</pre>
</body>
</html>
This will produce the following result −
function testFunction( strText ){
alert (strText)
}
Try using the same code without keeping it inside <pre>...</pre> tags
Nonbreaking Spaces
Suppose you want to use the phrase “12 Angry Men.” Here, you would not want
a browser to split the “12, Angry” and “Men” across two lines −
An example of this technique appears in the movie “12 Angry Men.”
In cases, where you do not want the client browser to break text, you should
use a nonbreaking space entity instead of a normal space. For example,
when coding the «12 Angry Men» in a paragraph, you should use something
similar to the following code −
Example:
<!DOCTYPE html>
<html>
<head>
<title>Nonbreaking Spaces Example</title>
82
Introduction to H T M L
</head>
<body>
<p>An example of this technique appears in the movie
“12 Angry Men.”</p>
</body>
</html>
This will produce the following result −
An example of this technique appears in the movie “12 Angry Men.”
Keyword
Document type
declaration is
an instruction
that associates
a particular
SGML or XML
document (for
example, a 3.1.4 HTML <!DOCTYPE> Declaration
webpage) with
a document The <!DOCTYPE> declaration must be the very first thing in
type definition
your HTML document, before the <html> tag.
(for example,
the formal The <!DOCTYPE> declaration is not an HTML tag; it
definition of a is an instruction to the web browser about what version of
particular version HTML the page is written in.
of HTML1.0 -
In HTML 4.01, the <!DOCTYPE> declaration refers to a
HTML 4.0).
DTD, because HTML 4.01 was based on SGML. The DTD
specifies the rules for the markup language, so that the
browsers render the content correctly.
HTML5 is not based on SGML, and therefore does not
require a reference to a DTD.
<!DOCTYPE html>
<html>
<head>
<title>Title of the document</title>
</head>
<body>
The content of the document......
</body>
</html>
84
Introduction to H T M L
<!DOCTYPE html>
85
Basic Computer Coding: HTML
XHTML 1.1
This DTD is equal to XHTML 1.0 Strict, but allows you to
add modules (for example to provide Ruby support for
East-Asian languages).
<!DOCTYPE html PUBLIC «-//W3C//DTD XHTML 1.1//
EN» «[Link]
format used to create hypertext documents that are portable from one platform to
another. HTML documents are SGML documents with generic semantics that are
appropriate for representing information from a wide range of domains.
As HTML is an application of SGML, this specification assumes a working
knowledge of [SGML].
Scope: HTML has been in use by the World-Wide Web (WWW) global
information initiative since 1990. Previously, informal documentation on HTML
has been available from a number of sources on the Internet. This specification
brings together, clarifies, and formalizes a set of features that roughly corresponds
to the capabilities of HTML in common use prior to June 1994. A number of new
features to HTML are being proposed and experimented in the Internet community.
This document thus defines a HTML 2.0 (to distinguish it from the previous
informal specifications). Future (generally upwardly compatible) versions of HTML
with new features will be released with higher version numbers.
HTML is an application of ISO Standard 8879:1986 Information Processing Text
and Office Systems; Standard Generalized Markup Language (SGML). The HTML
Document Type Definition (DTD) is a formal definition of the HTML syntax in
terms of SGML.
This specification also defines HTML as an Internet Media Type[IMEDIA] and
MIME Content Type[MIME] called `text/html’. As such, it defines the semantics
of the HTML syntax and how that syntax should be interpreted by user agents.
Conformance: This specification governs the syntax of HTML documents and
aspects of the behavior of HTML user agents.
Documents: A document is a conforming HTML document if:
■ It is a conforming SGML document, and it conforms to the HTML DTD.
■ It conforms to the application conventions in this specification. For example,
the value of the HREF attribute of the A element must conform to the
URI syntax.
■ Its document character set includes [ISO-8859-1] and agrees with [ISO-
10646]; that is, each code position listed in section The HTML Coded
Character Set is included, and each code position in the document character
set is mapped to the same character as [ISO-10646] designates for that
code position. (2)
Feature Test Entities: The HTML DTD defines a standard HTML document
type and several variations, by way of feature test entities. Feature test entities are
declarations in the HTML DTD that control the inclusion or exclusion of portions
of the DTD.
[Link]. Certain features of the language are necessary for
compatibility with widespread usage, but they may compromise the structural
integrity of a document. This feature test entity selects a more prescriptive document
type definition that eliminates those features. It is set to `IGNORE’ by default. For
example, in order to preserve the structure of a document, an editing user agent
may translate HTML documents to the recommended subset, or it may require that
87
Basic Computer Coding: HTML
88
exactly what HTML should be able to do. It was even more
important to have this information available in one place,
so that users could learn exactly how the language worked.
The first official standards for HTML 2.0 were published in
November of 1995. HTML 2.0 was created through the Internet
Engineering Task Force (IETF), though Tim Berners-Lee still Introduction to H T M L
took an active role in its creation.
89
Basic Computer Coding: HTML
Charlie Kindel from Microsoft, Eric Sink from Spyglass, [and] Wayne Gramlich from
Sun Microsystems.” Tim Berners-Lee and Dan Connolly served as representatives
of the W3 Consortium. Together, the seven discussed and debated the standards,
eventually coming to a consensus.
91
Basic Computer Coding: HTML
92
Introduction to H T M L
to create increasingly complex websites and are able to achieve this efficiently.
It only happens every few years, and the changes are made by the » World
Wide Web Consortium (W3C), who are HTML’s governing body, as it were. They
convene and design the specifications that we all work with when creating websites
(CSS was designed by the W3C too). They look for weaknesses in HTML that
are holding the web back, and sort them out, which makes creating compelling
websites easier for everybody.
The standard we were all working with before this was HTML 3.2. That was
used for a while before the W3C decided to step it up another notch a few years
ago. They released HTML 4. Sometime later, when some minor errors in the
specification were uncovered, they fixed these and called the final specification
HTML 4.01.
Versions
If you have used any software you will have undoubtedly noticed how every few
months it advances its number. Until they improved it and it became Firefox 2.1.
Adding a decimal to the version number signifies a minor change to the original.
When major changes are made to a software project, they will move up a whole
number to version 3. This is the same way most dynamic things work. As you can
see, the original HTML 3.0 spec was revised to version 3.2 before the big change
to 4, and a minor change to 4.01.
There was some confusion when HTML 4 started being discussed, as at the
time version 4 browsers like Internet Explorer 4 were making their appearance
and people thought there was some connection. In reality, the two separate things
had just reached those versions simultaneously, not because of each other. As you
know, browser technology has advanced to version 7 stages and beyond by now,
and HTML is still at level 4. So there’s no real connection; though, that said, it
was in the version 4 browsers that HTML 4 started being incorporated properly.
Glad that’s cleared up.
A few months after HTML 4.0 was released, its documentation was updated
to correct some minor problems, and its version number was bumped up slightly.
So the final version of this standard is HTML 4.01.
DOCTYPEs Ahoy
Nowadays the Document Type Declaration (DTD) at the top of your document is
very important if you want the browsers to render your page correctly. Without
it, browsers might interpret your code more loosely, and you may have display
errors. The HTML 4.01 DTDs are below. Take your pick.
Use the strict DTD if you’re using pure, structural code with no hacks:
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01//EN” “[Link]
[Link]/TR/html4/[Link]”>
The transitional DOCTYPE, below, is the most commonly used, and still permits
93
Basic Computer Coding: HTML
you to use certain old elements that we will eventually stop using altogether. It
is probably the best choice until you’ve gotten to know HTML really well. Once
you’re ready, you can start using the stricter DOCTYPE above.
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Transitional//EN” “http://
[Link]/TR/html4/[Link]”>
Finally, for frameset pages, use the frameset DTD:
<!DOCTYPE HTML PUBLIC “-//W3C//DTD HTML 4.01 Frameset//EN” “http://
[Link]/TR/html4/[Link]”>
Simply add this line of code to the very top of your HTML pages (before the
opening <html> tag), and you’re away. You will also need to specify the character
encoding of your page. The best encoding to use is called Unicode, and allows
you to type almost any character you want (like punctuation, letters with accents
etc.) directly into your content. Add this element in between your page’s <head>
and </head>:
<meta http-equiv=”Content-Type” content=”text/html; charset=UTF-8”>
Once you have added your DOCTYPE and encoding, run your page through
the » HTML validator to see if you’re obeying the rules.
<abbr>
This is used to show an ABBReviated version of a word, and to offer the full
version. When a reader leaves their mouse on the word, the full version pops up.
The code would be <abbr title=”abbreviation”>abbr.</abbr>
<acronym>
Similar to the one above, this is used for special abbreviations called acronyms
(initialled abbreviations that can be spoken as a word themselves). It works the
same way. <acronym title=”North Atlantic Treaty Organisation”>NATO</acronym>
<bdo>
Most text is read from left to right, but some languages are the opposite, like Hebrew
for example. This new tag allows the browser to display your page correctly if
you use one of these languages, and allows you to pull off cool effects like this:
cool effects. That’s typed in normally in the source code, but the tag changes its
direction. RTL means ‘Right To Left’. Code: <bdo dir=”rtl”>crazy text</bdo>
94
Introduction to H T M L
<button>
This is a simple way of adding form buttons to your pages.
What’s more, you can now format the text and put images
and other elements on the button. <button><b>click</b> me</
button> click me for nothing!
Keyword
<colgroup> Internet
Explorer
A table tag that allows you to affect the attributes of an is a series
entire column with one line of code. More info in Tables of graphical
Accessibility. web browsers
developed by
Microsoft and
<del> included in
Wrapping this around some text creates a strike-through effect the Microsoft
Windows line
to signify DELeted text, so you can show readers what once
of operating
existed without cutting it out altogether. <del>waffle</del>
systems, starting
in 1995.
<fieldset>
This allows you to group buttons and things together, giving
you a framed container to hold them in. It works together
with the <legend> tag below.
<frame>
Strangely, this has only been made part of the official
specifications now, despite it having been in use for years.
It has been given new style attributes but overall it’s the
same as the frame tag before.
<frameset>
This tag is in the same boat as its friend above. Nothing’s
really new.
<iframe>
Once a proprietary Internet Explorer tag, this was such a
smart idea that it has been assimilated into HTML proper.
>ins<
This stands for INSerted text. It works in conjunction with
the del tag, and the inserted text appears with an underline.
<del>waffle</del><ins>quality literature</ins>
95
Basic Computer Coding: HTML
<label>
This allows you to give form elements a label. Clicking the label functions like
clicking the element (a radio button, for example) itself. This improves Forms
Accessibility.
<label for=”choice1”>Choice 1</label>
<input type=”radio” id=”choice1”>
<legend>
When using a fieldset element, this element must come first before any other
content inside the fieldset. It gives the title of the group.
<fieldset><legend>Contact Info</legend>
Email:<input type=”text”>
Address:<input type=”text”></fieldset>
<noframes>
Another part of the frames umbrella that is being formally added to HTML 4. You
can learn more about it at the basic frames page.
<noscript>
The same as above, this is for people who can’t do JavaScript.
<object>
This is set to become the do-it-all tag for inserting multimedia into your page, and
is supposed to take over from img, ismap, applet, script and any others.
<object data=”[Link]” type=”image/gif”></object>
<optgroup>
With this tag you can group together many option elements which are part of a
select field, and give the groups titles.
<param>
This tag is used to set PARAMeters for ActiveX, Applets and objects. It existed
before HTML 4.01, but now is official code.
<span>
96
Introduction to H T M L
This tag was brought in specifically to work with stylesheets in applying classes
and ids. It does nothing on its own, but it is great for applying your styles to text.
<tbody>
A new table tag that allows you to give attributes to a block of cells with this one
tag.
<tfoot>
Allows you to add a footer to the tbody part of your tables.
<thead>
This allows you to add a header to the tbody part of a table. It comes before
tbody, while tfoot comes after in the code. Both of these elements are also found
in HTML4 Tables.
<q>
If you’ve ever used the blockquote tag, you’ll know it’s a big tag. How many letters
are in that, ten?! This is much more like it, and is suitable for shorter quotations.
Plus, it adds in the quotation marks for you. It will not add in the line breaks you
get with blockquote.
class
This is how you give your page elements and text their classes from your stylesheet.
Read all about it in advanced CSS.
dir
This is the attribute that is used mostly with the new <bdo> tag above. Your possible
values are rtl (right-to-left) or the default ltr (left-to-right).
id
ids are just like classes, but can be used with JavaScript and DHTML. More info.
97
Basic Computer Coding: HTML
lang
This attribute sets off a block of text as text typed in a foreign LANGuage, so that
search engines and browsers know, and don’t just take it as badly spelled English.
It will not translate anything for you, it’s just some behind-the-scenes help for
things other than readers.
You can denote the text using the span tag, like
<span lang=”fr”>Bonjour!</span>.
If you’re going to use it, have a look at the the common language codes.
title
This is one of my favorite things that came with HTML 4.01. It allows you to add
in tooltip text, like the alt attribute; but now you can add it to absolutely anything.
You can give table cells titles, add in extra information to your links, and even
hide jokes in your code that will only appear when a reader is on a specific word
or sentence in your text.
Deprecated Elements
A deprecated element is one that is on the way out, but one which has been
given a few more months to live before its life fully ends. There are much better
elements than these available now, so your usage of them should be downscaled
as much as possible.
<applet>
Used to add Java applets. Use the new <object> element instead.
<basefont>
Used to affect text on the whole page. Use style sheets instead.
<center>
Used to center elements. Use <div align=”center”> or stylesheets.
<dir>
Used to make lists. Use uls instead.
<font>
Ah, the classic font element. Still good for small things, but stylesheetshave
taken over. This is one element you should really try to avoid using.
<isindex>
Just use the input tag.
<menu>
Another type of list that is redundant thanks to the ul element.
<s>
Creates strike-through effects. Use the stylesheets again, or the new delelement.
98
Introduction to H T M L
<strike>
Same as above, use style.
<u>
The underlining element, use stylesheets or ins instead.
Dead Elements
These are the elements that were so useless that they’re out on their asses for good.
Never use these, you can’t guarantee the browsers will continue to support them.
All three of these elements have been replaced by one new element — so you can
see how they were useless.
<listing>, <plaintext>, and <xmp>. Use pre instead. This creates PRE formatted
text (text which follows its layout in your code).
And that’s the lot. By this stage, you are encouraged to use all of these elements.
Most people have either upgraded their browsers or bought computers with the
newest software on it, so the majority of the web audience are on the same level.
That said, there are some elements here that still aren’t supported in even the
newest browsers, so test your pages out before you go using any of these elements.
3.2.5 XHTML
The extensible hypertext markup language (XHTML) is a quick way to refer to
several language recommendations that are widely used on Internet-enabled devices
for viewing web pages. Although named after its predecessor, the hypertext markup
language (HTML), it’s is actually based on the extensible markup language (XML),
which is a very selective part of the standard generalized markup language (SGML).
In essence, they’re all offspring of SGML. While HTML is a direct application of
SGML, XHTML is what’s referred to as a namespace, or a set of definitions for
an XML document that helps to relieve ambiguity when more than one XML
vocabulary is being used in any given situation.
The language came about because of a few limitations to HTML and the
varied way HTML was being implemented. Around the time HTML made it to
version four, it began to wane in proper usage by many HTML interpreters, the
computer programs that parse HTML documents into a formatted, viewable web
page. As mobile devices and other web-viewing platforms were also emerging, a
better solution was needed. XML is a much more strict implementation of SGML
over HTML, and different XML namespaces can be used in a single instance. So
around the year 2000, the World Wide Web Consortium (W3C) drafted and made
XHTML one of its recommendations to solve some of these emerging issues.
For all intents and purposes, XHTML mimics HTML in most ways, but since
the former uses an XML namespace, it can be parsed by any XML interpreter, while
HTML is limited to only HTML interpreters. XHTML is really HTML recreated
under the more restrictive XML subset of SGML. In this way, the more recent
language was immediately able to be interpreted by existing web browsers while
99
Basic Computer Coding: HTML
also making itself available for other platforms. Living up to the extensible aspect
of XHTML’s moniker is also important to note. It not only offers the ability to be
read by more programs and platforms, but it is also further extensible by allowing
the use of other XML namespaces within its documents. With XHTML’s ability to
include other XML namespaces in a document, it can be extended in a number
of ways to present more than just page formatting. The mathematical markup
language (MathML), for example, can be included in these documents to display
mathematical formulas and notation. Images can also be embedded using the
scalable vector graphics (SVG) namespace within a document of this type. As such,
XHTML can also be a included with another XML document. Since XHTML is really
just HTML refined under XML’s rules, it offers three document type definitions
(DTD) that duplicate those of HTML version four. A DTD is a detailed description
of the elements of a markup language, including when, where, and how it can be
used, as well as any associated attributes. In later versions of XHTML, however,
XML schemas, another, more robust way of describing an XML document, were
established that further augmented XHTML. In turn, various stripped-down versions
of XHTML were developed that can then be built upon for specific uses, many of
which revolve around mobile computing platforms.
100
Introduction to H T M L
101
Basic Computer Coding: HTML
markup languages and CSS, to still be able to generate and edit content. However,
one problem with web pages and websites being built with correct XHTML has
been WYSIWYG editors that do not generate proper markup. XStandard points
out the problem and makes XHTML WYSIWYG Editor™ to address this, assuring
that only markup that meets best practice criteria is used.
One important feature you may find in an XHTML editor is the ability to
choose the version of XHTML you are working on. Adobe Dreamweaver CS4, for
example, offers a choice of XHTML 1.0 Transitional, XHTML 1.0 Strict, XHTML
1.1, or XHTML 1.0 Mobile. HTML 4.01 Transitional and HTML 4.01 Strict are also
offered.
In any case, there are some other features that may be present in an XHTML
editor. One valuable feature that is not universally offered is XHTML validation.
Alternatively, dynamic correction may be offered along with an error log file.
An HTML to XHTML conversion feature may also be included. Other desirable
features include syntax highlighting, word wrap, and UTF-8 Unicode (8-bit UCS/
Unicode Transformation Format) — UCS stands for Universal Character Set — to
enable work on multilingual files.
Syntax
XHTML syntax is very similar to HTML syntax and almost all the valid HTML
elements are valid in XHTML as well. But when you write an XHTML document,
you need to pay a bit extra attention to make your HTML document compliant
to XHTML.
Here are the important points to remember while writing a new XHTML
document or converting existing HTML document into XHTML document −
■ Write a DOCTYPE declaration at the start of the XHTML document.
■ Write all XHTML tags and attributes in lower case only.
■ Close all XHTML tags properly.
■ Nest all the tags properly.
■ Quote all the attribute values.
■ Forbid Attribute minimization.
■ Replace the name attribute with the id attribute.
■ Deprecate the language attribute of the script tag.
Here is the detail explanation of the above XHTML rules −
DOCTYPE Declaration
All XHTML documents must have a DOCTYPE declaration at the start. There are
three types of DOCTYPE declarations. Here is an example of using DOCTYPE −
<!DOCTYPE html PUBLIC “-//W3C//DTD XHTML 1.0 Transitional//EN”
“[Link]
102
Introduction to H T M L
Case Sensitivity
XHTML is case sensitive markup language. All the XHTML tags and attributes
need to be written in lower case only.
<!-- This is invalid in XHTML -->
<A Href=”/xhtml/xhtml_tutorial.html”>XHTML Tutorial</A>
Attribute Quotes
All the values of XHTML attributes must be quoted. Otherwise, your XHTML
document is assumed as an invalid document. Here is the example showing syntax −
<!-- This is invalid in XHTML -->
<img src=”/images/[Link]” width=250 height=50 />
Attribute Minimization
XHTML does not allow attribute minimization. It means you need to explicitly
state the attribute and its value. The following example shows the difference −
<!-- This is invalid in XHTML -->
103
Basic Computer Coding: HTML
<option selected>
<!-- Correct XHTML way of writing this is as follows -->
<option selected=”selected”>
Here is a list of the minimized attributes in HTML and the way you need to
write them in XHTML −
The id Attribute
The id attribute replaces the name attribute. Instead of using name = “name”,
XHTML prefers to use id = “id”. The following example shows how −
<!-- This is invalid in XHTML -->
<img src=”/images/[Link]” name=”xhtml_logo” />
104
Introduction to H T M L
</script>
Nested Tags
You must nest all the XHTML tags properly. Otherwise your document is assumed
as an incorrect XHTML document. The following example shows the syntax −
<!-- This is invalid in XHTML -->
<b><i> This text is bold and italic</b></i>
<!-- Correct XHTML way of writing this is as follows -->
<b><i> This text is bold and italic</i></b>
Element Prohibitions
The following elements are not allowed to have any other element inside them. This
prohibition applies to all depths of nesting. Means, it includes all the descending
elements.
Element Prohibition
<a> Must not contain other <a> elements.
<pre> Must not contain the <img>, <object>, <big>, <small>, <sub>,
or <sup> elements.
<button> Must not contain the <input>, <select>, <textarea>, <label>,
<button>, <form>, <fieldset>, <iframe> or <isindex>
elements.
<label> Must not contain other <label> elements.
<form> Must not contain other <form> elements.
105
Basic Computer Coding: HTML
<body>
...your content goes here...
</body>
</html>
3.2.6 HTML5
Hypertext Markup Language revision 5 (HTML5) is markup language for the
structure and presentation of World Wide Web contents. HTML5 supports the
traditional HTML and XHTML-style syntax and other new features in its markup,
New APIs, XHTML and error handling.
There are three organizations that are currently in charge of the specification
of HTML5:
Web Hypertext Application Technology Working Group (WHATWG) created
the HTML5 specification and is in charge of the HTML5 development that provides
open collaboration of browser vendors and other involved parties.
World Wide Web Consortium (W3C) is in charge with delivering the HTML5
specification.
Internet Engineering Task Force (IETF) is in charge of the development of
HTML5 WebSocket API.
HTML5 is an effort is to bring order to web development chaos by organizing
common practices, embracing implementations from various browsers. It is massive,
with over 100 specifications as part of the HTML5 specs. Understanding this, you
can simplify by thinking of HTML5 this way. HTML5 is simply just an umbrella
term for the next generation of web apps an how functionality will be expanded
with better markup (HTML), better style (CSS), and better interactivity (JavaScript).
The specification of HTML5 that has been published currently is not yet
final. HTML5 is expected due for Candidate Recommendation (CR) by 2012, and
is expected for Proposed Recommendation (PR) by 2022. However, this doesn’t
mean that HTML5 is not ready for use. The proposed recommendation does mean
however that there will be two interoperable implementations. As of 2011, browser
vendors are actively adding support for new features of HTML5.
New features of HTML5 include:
■ New parsing rules that are not based on SGML but are oriented towards
flexible parsing and compatibility.
■ Support of use of inline Scalar Vector Graphics (SVG) and Mathematical
Markup Language (MathML) in text/html.
■ New available elements include article, aside, audio, bdi, canvas, command,
datalist, details, embed, figcaption, figure, footer, header, hgroup, keygen,
mark, meter, nav, output, progress, rp, rt, ruby, section, source, summary,
time, video and wbr.
106
Introduction to H T M L
■ New available types of form controls include dates and times, email, url,
search, number, range, tel and color.
■ New available attributes of charset on meta and async on script.
■ Global attributes that can be applied for every element that include id,
tabindex, hidden, data-* or customer data attributes.
107
Basic Computer Coding: HTML
SUMMARY
■ HyperText Markup Language (HTML) is a type of computer language that
is used to create pages that can be posted on the Internet or sent via email.
■ HTML is a Markup Language which means you use HTML to simply
«mark-up» a text document with tags that tell a Web browser how to
structure it to display.
■ The tag tells the browser that this is an HTML document. The tag represents
the root of an HTML document. The tag is the container for all other
HTML elements (except for the tag).
■ Horizontal lines are used to visually break-up sections of a document.
The <hr> tag creates a line from the current position in the document to
the right margin and breaks the line accordingly.
■ The <!DOCTYPE> declaration is not an HTML tag; it is an instruction
to the web browser about what version of HTML the page is written in.
■ HTML defines the structure and layout of a Web document by using a
variety of tags and attributes. The correct structure for an HTML document
starts with <HTML><HEAD>(enter here what document is about)<BODY>
and ends with </BODY></HTML>.
■ HTML 3.2 was the first version of HTML to be released as a W3C
Recommendation, and implemented most, but not all, of the features
that were proposed in 3.0. Most notably, the mathematical equations were
removed from 3.2.
■ HTML 4.01 was a large shake-up to the HTML standards that arrived in
April 1998. The HTML language you have learnt is constantly evolving
to meet the needs of a growing Internet.
■ The extensible hypertext markup language (XHTML) is a quick way to refer
to several language recommendations that are widely used on Internet-
enabled devices for viewing web pages.
■ The eXtensible HyperText Markup Language (XHTML) has replaced the
similar HyperText Markup Language (HTML) as the markup language
of choice for creating webpages, but old webpages are relatively easy to
convert from HTML to XHTML.
■ Hypertext Markup Language revision 5 (HTML5) is markup language
for the structure and presentation of World Wide Web contents. HTML5
supports the traditional HTML and XHTML-style syntax and other new
features in its markup, New APIs, XHTML and error handling.
108
Introduction to H T M L
KNOWLEDGE CHECK
1. Recommendation of using attributes in HTML is to use it in
a. Uppercase
b. Lower case
c. Sentence case
d. Proper case
2. Language of document can be specified with tag
a. lang
b. Ref
c. language
d. Href
3. Style attribute of an element defines
a. Size
b. Color
c. Font type
d. All of the Above
4. In HTML, language of document is declared in tag
a. <!DOCTYPE html>
b. <html>
c. <body>
d. <ref>
5. The
a. Image is displayed
b. Image is not displayed
c. Image is shared
d. Image is not shared
6. HTML stands for -
a. HighText Machine Language
b. HyperText and links Markup Language
c. HyperText Markup Language
d. None of these
7. The correct sequence of HTML tags for starting a webpage is -
a. Head, Title, HTML, body
b. HTML, Body, Title, Head
c. HTML, Head, Title, Body
d. HTML, Head, Title, Body
109
Basic Computer Coding: HTML
110
Introduction to H T M L
REVIEW QUESTIONS
1. What is the basics of HTML document?
2. Discuss about the various tags of HTML.
3. Explain the HTML page structure.
4. Define the HTML <!DOCTYPE> Declaration.
5. Write the features of HTML 2.0.
6. What are the different between HTML 3.2 and HTML 4.01?
7. Differentiate between HTML and HTML5. What new features does HTML5
introduce?
8. Explain the purpose of HTML tags and provide an example of an opening
and closing tag.
9. What is the role of the “doctype” declaration in an HTML document?
111
Basic Computer Coding: HTML
REFERENCES
1. Castro, Elizabeth and Hyslop . HTML5, and CSS, Eight Edition: (Visual
QuickStart Guide), Peachpit Press, 2013.
2. Devlin, Ian. HTML5 Multimedia: Develop and Design, Peachpit Press, 2011.
3. Felke-Morris, Web Development & Design Foundations with HTML5, 10th
Edition, Addison-Wesley, 2020.
4. Felke-Morris. Basics of Web Design: HTML5 & CSS3, 5th Edition, Pearson
Education, 2019.
5. Keith, Jeremy and Andrew, Rachel. HTML5 For Web Designers , A Book
Apart, 2016.
6. Lawson, Bruce and Sharp, Remy. Introducing HTML5, New Riders Press, 2010.
7. Meiert, Jens Oliver. The Little Book of HTML/CSS Coding Guidelines, O’Reilly,
2015.
8. Meiert, Jens Oliver. Upgrade Your HTML (the Booklet), Amazon Digital
Services LLC, 2019.
9. Pfeiffer, Silvia, and Green, Tom. Beginning HTML5 Media: Make the most
of the new video and audio standards for the Web, APress, 2015.
10. Pfeiffer, Silvia. The Definitive Guide to HTML5 Video, APress, 2010.
112
CHAPTER 4
ELEMENTS OF
HTML
LEARNING OBJECTIVES
p> above). The closing tag is identical to the opening tag with the addition
of a forward slash (/) after the first angle bracket.
■ The content is placed between the element’s opening and closing tags
(This is paragraph text. above).
HTML elements with no content are called empty elements. Empty elements do
.(not have an end tag, such as the <br> element (which indicates a line break
Example
<! DOCTYPE html>
114
Elements of H T M L
<html>
<body>
<h1>My First Heading</h1>
<p>My first paragraph. </p>
</body>
</html>
Example Explained
The <html> element defines the whole document.
It has a start tag <html> and an end tag </html>.
The element content is another HTML element (the <body> element).
<html>
<body>
<h1>My First Heading</h1>
<p>My first paragraph. </p>
</body>
</html>
The <body> element defines the document body.
It has a start tag <body> and an end tag </body>.
The element content is two other HTML elements (<h1> and <p>).
<body>
<h1>My First Heading</h1>
<p>My first paragraph. </p>
</body>
115
Basic Computer Coding: HTML
Example
<html>
<body>
<p>This is a paragraph
<p>This is a paragraph
</body>
</html>
The example above works in all browsers, because the closing tag is considered
optional.
Never rely on this. It might produce unexpected results and/or errors if you
forget the end tag.
116
Elements of H T M L
Specifies a scheme to interpret the property’s value (as declared in the content
attribute).
4 http-equiv
Used for http response message headers. For example, http-equiv can be used to
refresh the page or to set a cookie. Values include content-type, expires, refresh
and set-cookie.
117
Basic Computer Coding: HTML
Example
Following is an example, where we are adding HTML, Meta Tags, and Metadata
as important keywords about the document.
<!DOCTYPE html>
<html>
<head>
<title>Meta Tags Example</title>
<meta name = “keywords” content = “HTML, Meta Tags, Metadata” />
</head>
<body>
<p>Hello HTML5!</p>
</body>
</html>
This will produce the following result −
Hello HTML5
Example
Live Demo
<!DOCTYPE html>
<html>
<head>
<title>Meta Tags Example</title>
<meta name = “keywords” content = “HTML, Meta Tags, Metadata” />
<meta name = “description” content = “Learning about Meta Tags.” />
</head>
<body>
<p>Hello HTML5!</p>
118
Elements of H T M L
</body>
</html>
Example
<! DOCTYPE html>
<html>
<head>
<title>Meta Tags Example</title>
<meta name = “keywords” content = “HTML, Meta Tags, Metadata” />
<meta name = “description” content = “Learning about Meta Tags.” />
<meta name = “revised” content = “Tutorialspoint, 3/7/2014” />
</head>
<body>
<p>Hello HTML5! </p>
</body>
</html>
Example
If you want your page keep refreshing after every 5 seconds, then use the following
syntax.
<! DOCTYPE html>
<html>
<head>
<title>Meta Tags Example</title>
<meta name = “keywords” content = “HTML, Meta Tags, Metadata” />
<meta name = “description” content = “Learning about Meta Tags.” />
119
Basic Computer Coding: HTML
Example
Following is an example of redirecting current page to another page after 5 seconds.
If you want to redirect page immediately then do not specify content attribute.
<! DOCTYPE html>
<html>
<head>
<title>Meta Tags Example</title>
<meta name = “keywords” content = “HTML, Meta Tags, Metadata” />
<meta name = “description” content = “Learning about Meta Tags.” />
<meta name = “revised” content = “Tutorialspoint, 3/7/2014” />
<meta http-equiv = “refresh” content = “5; url = [Link]
com” />
</head>
<body>
<p>Hello HTML5!</p>
</body>
</html>
120
Elements of H T M L
Example
Following is an example of redirecting current page to another page after 5
seconds. If you want to redirect page immediately then do not specify content
attribute.
<! DOCTYPE html>
<html>
<head>
<title>Meta Tags Example</title>
<meta name = “keywords” content = “HTML, Meta Tags, Metadata” />
<meta name = “description” content = “Learning about Meta Tags.” />
<meta name = “revised” content = “Tutorials point, 3/7/2014” />
<meta http-equiv = “cookie” content = “userid = xyz;
expires = Wednesday, 08-Aug-15 23:59:59 GMT;” />
</head>
<body>
<p>Hello HTML5!</p>
</body>
</html>
If you do not include the expiration date and time, the cookie is considered a
session cookie and will be deleted when the user exits the browser.
Example
<! DOCTYPE html>
<html>
<head>
<title>Meta Tags Example</title>
<meta name = “keywords” content = “HTML, Meta Tags, Metadata” />
<meta name = “description” content = “Learning about Meta Tags.” />
<meta name = “author” content = “Mahnaz Mohtashim” />
</head>
121
Basic Computer Coding: HTML
<body>
<p>Hello HTML5!</p>
</body>
</html>
Example
By default, Web servers and Web browsers use ISO-8859-1 (Latin1) encoding
to process Web pages. Following is an example to set UTF-8 encoding −
<!DOCTYPE html>
<html>
<head>
<title>Meta Tags Example</title>
<meta name = “keywords” content = “HTML, Meta Tags, Metadata” />
<meta name = “description” content = “Learning about Meta Tags.” />
<meta name = “author” content = “Mahnaz Mohtashim” />
<meta http-equiv = “Content-Type” content = “text/html; charset = UTF-8” />
</head>
<body>
<p>Hello HTML5!</p>
</body>
</html>
To serve the static page with traditional Chinese characters, the webpage must
contain a <meta> tag to set Big5 encoding –
<!DOCTYPE html>
<html>
<head>
<title>Meta Tags Example</title>
<meta name = “keywords” content = “HTML, Meta Tags, Metadata” />
<meta name = “description” content = “Learning about Meta Tags.” />
<meta name = “author” content = “Mahnaz Mohtashim” />
<meta http-equiv = “Content-Type” content = “text/html; charset = Big5” />
122
Elements of H T M L
</head>
<body>
<p>Hello HTML5!</p>
</body>
</html>
<html>
<head>
<title>gfg</title>
<style type=text/css>
p{
background-color:gray;
margin: 10px;
}
div
{
color: white;
background-color: 009900;
margin: 2px;
font-size: 25px;
}
</style>
123
Basic Computer Coding: HTML
</head>
<body>
<div > div tag </div>
<div > div tag </div>
<div > div tag </div>
<div > div tag </div>
</body>
</html>
Output:
div tag
div tag
div tag
div tag
As we know div tag is used for grouping HTML elements together and is to
apply CSS and web layout on them Lets see below example without using div
tag. we need to applying CSS for each tag (in the example using H1 H2 and two
paragraphs p tags)
<html>
<head>
<title>gfg</title>
<style type=text/css>
p{
color: white;
124
Elements of H T M L
background-color: 009900;
width: 400px;
}
h1
{
color: white;
background-color: 009900;
width: 400px;
}
h2
{
color: white;
background-color: 009900;
width: 400px; Keyword
CSS is a
}
style sheet
</style> language used
</head> for describing
the presentation
<body> of a document
<h1>GeeksforGeeks</h1> written in a
markup language
<p>How many times were you frustrated while
like HTML.
looking out
for a good collection of programming/algorithm/
interview
questions? What did you expect and what did
you get?
This portal has been created to provide well written,
well thought and well-explained solutions for
selected questions.
</p>
<h2>GeeksforGeeks</h2>
<p>GCET is an entrance test for the extensive
classroom programme
by GeeksforGeeks to build and enhance Data
Structures and Algorithm
concepts, mentored by Sandeep Jain (Founder &
CEO, GeeksforGeeks).
He has 7 years of teaching experience and 6 years
of industry experience.
125
Basic Computer Coding: HTML
</p>
</body>
</html>
126
Elements of H T M L
div{
padding : 1%;
color: white;
background-color: 009900;
width: 30%;
border: solid black;
}
</style>
</head>
<body>
<div class=”leftdiv”>
<h1>GeeksforGeeks</h1>
<p>How many times were you frustrated while looking out
for a good collection of programming/algorithm/interview
questions? What did you expect and what did you get?
This portal has been created to provide well written,
well thought and well-explained solutions for selected questions.
</p>
<h2>GeeksforGeeks</h2>
<p>GCET is an entrance test for the extensive classroom programme
by GeeksforGeeks to build and enhance Data Structures and Algorithm
concepts, mentored by Sandeep Jain (Founder & CEO, GeeksforGeeks).
He has 7 years of teaching experience and 6 years of industry experience.
</p>
</div>
<div class=”middlediv”>
<h1>GeeksforGeeks</h1>
<p>How many times were you frustrated while looking out
for a good collection of programming/algorithm/interview
questions? What did you expect and what did you get?
This portal has been created to provide well written,
well thought and well-explained solutions for selected questions.
</p>
<h2>GeeksforGeeks</h2>
<p>GCET is an entrance test for the extensive classroom programme
by GeeksforGeeks to build and enhance Data Structures and Algorithm
127
Basic Computer Coding: HTML
Using class
We can use Class on that particular div either in internal CSS or external CSS
In case of internal CSS: we need to define Class in the <head> section of HTML
within <style> element.
In case of External CSS: we need to create a separate .css file and include it
in HTML code in <head> section using <link> element.
The class name should be different from other class name in other div otherwise
the CSS used in one div can affect another division.
<html>
<head>
<link rel=”stylesheet” href=”[Link]”>
<title>
gfg
</title>
128
Elements of H T M L
</head>
<body>
<center>
<div class=”color”>
<!--open tag of Div!-->
<caption>
<h1>GEEKSFORGEEKS</h1>
</caption>
<h1>Inline CSS is not USED in THIS method.
</h1>
</div>
<!--closing tag of Div!-->
</center>
</body>
</html>
Inline CSS
we can directly use CSS in div also this method does not require of CLASS. Div
in HTML coding is used as a container tag also because it is the one that can
contain all other tags.
<html>
<head>
<title>
gfg
</title>
</head>
<body>
<center>
129
Basic Computer Coding: HTML
130
Elements of H T M L
131
Basic Computer Coding: HTML
beginning and end; you must say where the bold type, for example, begins and
where it ends.
<B>Boldface type looks like this on your machine</B> <BR>
<I>Italics appear like this.</I> <BR>
<TT>Typewriter text uses a fixed-width font.</TT> <BR>
<B> <I>The styles may be combined as well.</I> </B> <BR>
Here is what the above code looks like:
Boldface type looks like this on your machine
Italics appear like this.
Typewriter text uses a fixed-width font
.The styles may be combined as well
132
Elements of H T M L
Testing 1 2 3
printf(“The value of n is %d\n”,n)
(Abort, Retry, Fail)?
username
Is this thing on?
username, host
You cannot be serious!
Example
<!DOCTYPE html>
<html>
<head>
<title>HTML Unordered List</title>
133
Basic Computer Coding: HTML
</head>
<body>
<ul>
<li>Beetroot</li>
<li>Ginger</li>
<li>Potato</li>
<li>Radish</li>
</ul>
</body>
</html>
This will produce the following result −
Example
Following is an example where we used <ul type = “square”>
<!DOCTYPE html>
<html>
<head>
<title>HTML Unordered List</title>
</head>
<body>
<ul type = “square”>
<li>Beetroot</li>
<li>Ginger</li>
<li>Potato</li>
<li>Radish</li>
</ul>
</body>
</html>
134
Elements of H T M L
Example
Following is an example where we used <ul type = “disc”> −
<!DOCTYPE html>
<html>
<head>
<title>HTML Unordered List</title>
</head>
<body>
<ul type = “disc”>
<li>Beetroot</li>
<li>Ginger</li>
<li>Potato</li>
<li>Radish</li>
</ul>
</body>
</html>
This will produce the following result −
Example
Following is an example where we used <ul type = “circle”> −
<!DOCTYPE html>
<html>
<head>
<title>HTML Unordered List</title>
</head>
<body>
<ul type = “circle”>
<li>Beetroot</li>
<li>Ginger</li>
<li>Potato</li>
<li>Radish</li>
135
Basic Computer Coding: HTML
</ul>
</body>
</html>
This will produce the following result −
Example
<!DOCTYPE html>
<html>
<head>
<title>HTML Ordered List</title>
</head>
<body>
<ol>
Keyword <li>Beetroot</li>
<li>Ginger</li>
An
ordered list is <li>Potato</li>
also called a <li>Radish</li>
number list. The
ordering is given </ol>
by a numbering </body>
scheme, using
Arabic numbers,
letters, Roman </html>
numerals. This will produce the following result −
Example
Following is an example where we used <ol type = “1”>
<!DOCTYPE html>
<html>
<head>
<title>HTML Ordered List</title>
</head>
<body>
Did You
<ol type = “1”>
Know?
<li>Beetroot</li> In 1980,
<li>Ginger</li> physicist Tim
Berners-Lee, a
<li>Potato</li> contractor at
<li>Radish</li> CERN, proposed
and prototyped
</ol> ENQUIRE, a
</body> system for CERN
researchers to
use and share
</html> documents. In
1989, Berners-Lee
This will produce the following result − wrote a memo
proposing an
Internet-based
Example hypertext system.
Following is an example where we used <ol type = “I”> [6]
<!DOCTYPE html>
<html>
<head>
<title>HTML Ordered List</title>
</head>
<body>
<ol type = “I”>
<li>Beetroot</li>
<li>Ginger</li>
137
Basic Computer Coding: HTML
<li>Potato</li>
<li>Radish</li>
</ol>
</body>
</html>
This will produce the following result −
Example
Following is an example where we used <ol type = “i”>
<!DOCTYPE html>
<html>
<head>
<title>HTML Ordered List</title>
</head>
<body>
<ol type = “i”>
<li>Beetroot</li>
<li>Ginger</li>
<li>Potato</li>
<li>Radish</li>
</ol>
</body>
</html>
This will produce the following result −
Example
Following is an example where we used <ol type = “A” >
<!DOCTYPE html>
<html>
<head>
<title>HTML Ordered List</title>
</head>
<body>
<ol type = “A”>
<li>Beetroot</li>
138
Elements of H T M L
<li>Ginger</li>
<li>Potato</li>
<li>Radish</li>
</ol>
</body>
</html>
This will produce the following result −
Example
Following is an example where we used <ol type = “a”>
<!DOCTYPE html>
<html>
<head>
<title>HTML Ordered List</title>
</head>
<body>
<ol type = “a”>
<li>Beetroot</li>
<li>Ginger</li>
<li>Potato</li>
<li>Radish</li>
</ol>
</body>
</html>
This will produce the following result −
139
Basic Computer Coding: HTML
Example
Following is an example where we used <ol type = “i” start = “4” >
<!DOCTYPE html>
<html>
<head>
<title>HTML Ordered List</title>
</head>
<body>
<ol type = “i” start = “4”>
<li>Beetroot</li>
<li>Ginger</li>
<li>Potato</li>
<li>Radish</li>
</ol>
</body>
</html>
This will produce the following result −
Example
<!DOCTYPE html>
<html>
<head>
<title>HTML Definition List</title>
</head>
<body>
<dl>
140
Elements of H T M L
<dt><b>HTML</b></dt>
<dd>This stands for Hyper Text Markup Language</
dd>
<dt><b>HTTP</b></dt>
<dd>This stands for Hyper Text Transfer Protocol</
dd>
</dl>
</body>
</html>
This will produce the following result −
HTML
This stands for Hyper Text Markup Language
HTTP
This stands for Hyper Text Transfer Protocol
4.5.1 Table
An HTML table is defined with the <table> tag.
Each table row is defined with the <tr> tag. A table header
Keyword
is defined with the <th> tag. By default, table headings are bold Header
refers to
and centered. A table data/cell is defined with the <td> tag.
supplemental
data placed at
Example the beginning of
a block of data
<table style=”width:100%”> being stored or
<tr> transmitted.
<th>Firstname</th>
<th>Lastname</th>
<th>Age</th>
</tr>
<tr>
<td>Jill</td>
<td>Smith</td>
<td>50</td>
</tr>
<tr>
<td>Eve</td>
<td>Jackson</td>
<td>94</td>
141
Basic Computer Coding: HTML
</tr>
</table>
Example
table, th, td {
border: 1px solid black;
}
Example
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
Example
th, td {
padding: 15px;
}
142
Elements of H T M L
Example
th {
text-align: left;
}
To set the border spacing for a table, use the CSS border-spacing property:
Example
table {
border-spacing: 5px;
}
Example
<table style=”width:100%”>
<tr>
<th>Name</th>
<th colspan=”2”>Telephone</th>
</tr>
<tr>
<td>Bill Gates</td>
<td>55577854</td>
<td>55577855</td>
</tr>
</table>
143
Basic Computer Coding: HTML
Example
<table style=”width:100%”>
<tr>
<th>Name:</th>
<td>Bill Gates</td>
</tr>
<tr>
<th rowspan=”2”>Telephone:</th>
<td>55577854</td>
</tr>
<tr>
<td>55577855</td>
</tr>
</table>
Example
<table style=”width:100%”>
<caption>Monthly savings</caption>
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
Keyword
Attribute <tr>
is a <td>January</td>
specification <td>$100</td>
that defines a
property of an </tr>
object, element, <tr>
or file
<td>February</td>
<td>$50</td>
</tr>
</table>
144
Elements of H T M L
Example
<table id=”t01”>
<tr>
<th>Firstname</th>
<th>Lastname</th>
<th>Age</th>
</tr>
<tr>
<td>Eve</td>
<td>Jackson</td>
<td>94</td>
</tr>
</table>
Now you can define a special style for this table:
table#t01 {
width: 100%;
background-color: #f1f1c1;
}
145
Basic Computer Coding: HTML
Local Links
The example above used an absolute URL (a full web address).
A local link (link to the same web site) is specified with
a relative URL (without [Link]
Example
<a href=”html_images.asp”>HTML Images</a>
Example
<style>
a:link {
color: green;
146
Elements of H T M L
background-color: transparent;
text-decoration: none;
}
a:visited {
color: pink;
background-color: transparent;
text-decoration: none;
}
a:hover {
color: red;
background-color: transparent;
text-decoration: underline;
}
a:active {
color: yellow;
background-color: transparent;
text-decoration: underline;
}
</style>
Example
<a href=”[Link] target=”_blank”>Visit W3Schools!</a>
Tip: If your webpage is locked in a frame, you can use target=”_top” to break
out of the frame:
147
Basic Computer Coding: HTML
Example
<a href=”[Link] target=”_top”>HTML5 tutorial!</a>
Example
<a href=”[Link]”>
<img src=”[Link]” alt=”HTML tutorial” style=”width:42px;height:42px;b
order:0;”>
</a>
Note: border:0; is added to prevent IE9 (and earlier) from displaying a border
around the image (when the image is a link).
Link Titles
The title attribute specifies extra information about an element. The information
is most often shown as a tooltip text when the mouse moves over the element.
Example
<a href=”[Link] title=”Go to W3Schools HTML
section”>Visit our HTML Tutorial</a>
Example
First, create a bookmark with the id attribute:
<h2 id=”C4”>Chapter 4</h2>
Then, add a link to the bookmark (“Jump to Chapter 4”), from within the
same page:
<a href=”#C4”>Jump to Chapter 4</a>
Or, add a link to the bookmark (“Jump to Chapter 4”), from another page:
148
Elements of H T M L
Example
<a href=”html_demo.html#C4”>Jump to Chapter 4</a>
External Paths
External pages can be referenced with a full URL or with a path relative to the
current web page.
This example uses a full URL to link to a web page:
Example
<a href=”[Link] tutorial</a>
This example links to a page located in the html folder on the current web site:
Example
<a href=”/html/[Link]”>HTML tutorial</a>
This example links to a page located in the same folder as the current page:
Example
<a href=”[Link]”>HTML tutorial</a>
4.6.1 Images
Images can improve the design and the appearance of a web page.
Example
<img src=”pic_trulli.jpg” alt=”Italian Trulli”>
Example
<img src=”img_girl.jpg” alt=”Girl in a jacket”>
Example
<img src=”img_chania.jpg” alt=”Flowers in Chania”>
HTML Images Syntax
In HTML, images are defined with the <img> tag.
The <img> tag is empty, it contains attributes only, and does not have a closing
tag.
The src attribute specifies the URL (web address) of the image:
<img src=”url”>
149
Basic Computer Coding: HTML
Example
<img src=”img_chania.jpg” alt=”Flowers in Chania”>
If a browser cannot find an image, it will display the value of the alt attribute:
Example
<img src=”[Link]” alt=”Flowers in Chania”>
Note: The alt attribute is required. A web page will not validate correctly
without it.
Example
<img src=”img_girl.jpg” alt=”Girl in a jacket” style=”width:500px;height:600px;”>
Alternatively, you can use the width and height attributes:
Example
<img src=”img_girl.jpg” alt=”Girl in a jacket” width=”500” height=”600”>
The width and height attributes always defines the width and height of the
image in pixels.
Example
<! DOCTYPE html>
<html>
<head>
150
Elements of H T M L
<style>
img {
width: 100%;
}
</style>
</head>
<body>
</body>
</html>
Example
<img src=”/images/[Link]” alt=”HTML5 Icon” style=”width: 128px;height:128px;”>
Example
<img src=”[Link] alt=”W3Schools.
com”>
You can read more about file paths in the chapter HTML File Paths.
Animated Images
HTML allows animated GIFs:
Example
<img src=”[Link]” alt=”Computer Man” style=”width:48px;height:48px;”>
151
Basic Computer Coding: HTML
Image as a Link
To use an image as a link, put the <img> tag inside the <a> tag:
Example
<a href=”[Link]”>
<img src=”[Link]” alt=”HTML tutorial” style=”width:42px;height:42px;b
order:0;”>
</a>
Note: border: 0; is added to prevent IE9 (and earlier) from displaying a border
around the image (when the image is a link).
Image Floating
Use the CSS float property to let the image float to the right or to the left of a text:
Example
<p><img src=”[Link]” alt=”Smiley face” style=”float:right;width:42px;height:42
px;”>
The image will float to the right of the text.</p>
<p><img src=”[Link]” alt=”Smiley face” style=”float:left;width:42px;height
:42px;”>
The image will float to the left of the text.</p>
Image Maps
The <map> tag defines an image-map. An image-map is an image with clickable
areas.
In the image below, click on the computer, the phone, or the cup of coffee:
Example
<img src=”[Link]” alt=”Workplace” usemap=”#workmap”>
<map name=”workmap”>
<area shape=”rect” coords=”34, 44,270,350” alt=”Computer” href=”computer.
htm”>
<area shape=”rect” coords=”290,172,333,250” alt=”Phone” href=”[Link]”>
<area shape=”circle” coords=”337,300,44” alt=”Coffee” href=”[Link]”>
</map>
The name attribute of the <map> tag is associated with the <img>’s usemap
attribute and creates a relationship between the image and the map.
152
Elements of H T M L
The <map> element contains a number of <area> tags, that define the clickable
areas in the image-map.
Background Image
To add a background image on an HTML element, use the CSS property background-
image:
Example
To add a background image on a web page, specify the background-image property
on the BODY element:
<body style=”background-image:url(‘[Link]’)”>
<h2>Background Image</h2>
</body>
Example
To add a background image on a paragraph, specify the background-image
property on the P element:
<body>
<p style=”background-image:url(‘[Link]’)”>
...
</p>
</body>
153
Basic Computer Coding: HTML
4 enctype
You can use the enctype attribute to specify how the browser encodes the
− data before it sends it to the server. Possible values are
Application/x-www-form-urlencoded − This is the standard method most
.forms use in simple scenarios
mutlipart/form-data − This is used when you want to upload binary data in
.the form of files like image, word file etc
Note − You can refer to Perl & CGI for a detail on how form data upload works.
154
Elements of H T M L
only one line of user input, such as search boxes or names. They are
created using HTML <input> tag.
■ Password input controls − This is also a single-line text input but it masks
the character as soon as a user enters it. They are also created using HTMl
<input> tag.
■ Multi-line text input controls − This is used when the user is required
to give details that may be longer than a single sentence. Multi-line input
controls are created using HTML <textarea> tag.
■ 4.7.4 Single-line text input controls
This control is used for items that require only one line of user input, such as
search boxes or names. They are created using HTML <input> tag.
Example
Here is a basic example of a single-line text input used to take first name and last
name −
<!DOCTYPE html>
<html>
<head>
<title>Text Input Control</title>
</head>
<body>
<form >
First name: <input type = “text” name = “first_name” />
<br>
Last name: <input type = “text” name = “last_name” />
</form>
</body>
</html>
This will produce the following result −
First name:
Last name:
Attributes
Following is the list of attributes for <input> tag for creating text field.
155
Basic Computer Coding: HTML
Indicates the type of input control and for text input control it will be set to text.
2 name
Used to give a name to the control which is sent to the server to be recognized
and get the value.
3 value
Allows to specify the maximum number of characters a user can enter into the
text box.
Example
Here is a basic example of a single-line password input used to take user
password −
<!DOCTYPE html>
<html>
<head>
<title>Password Input Control</title>
</head>
<body>
<form >
User ID : <input type = “text” name = “user_id” />
<br>
Password: <input type = “password” name = “password” />
</form>
</body>
</html>
This will produce the following result –
156
Elements of H T M L
User ID :
Password:
Attributes
Following is the list of attributes for <input> tag for creating password field.
Indicates the type of input control and for password input control
it will be set to password.
2 name
Example
Here is a basic example of a multi-line text input used to take item description −
<!DOCTYPE html>
<html>
<head>
<title>Multiple-Line Input Control</title>
</head>
<body>
<form>
157
Basic Computer Coding: HTML
Attributes
Following is the list of attributes for <textarea> tag.
Example
Here is an example HTML code for a form with two checkboxes −
<!DOCTYPE html>
<html>
<head>
158
Elements of H T M L
<title>Checkbox Control</title>
</head>
<body>
<form>
<input type = “checkbox” name = “maths” value = “on”> Maths
<input type = “checkbox” name = “physics” value = “on”> Physics
</form>
</body>
</html>
This will produce the following result −
Attributes
Following is the list of attributes for <checkbox> tag.
Example
Here is example HTML code for a form with two radio buttons −
159
Basic Computer Coding: HTML
<!DOCTYPE html>
<html>
<head>
<title>Radio Box Control</title>
</head>
<body>
<form>
<input type = “radio” name = “subject” value = “maths”> Maths
<input type = “radio” name = “subject” value = “physics”> Physics
</form>
</body>
</html>
This will produce the following result −
Attributes
Following is the list of attributes for radio button.
Indicates the type of input control and for checkbox input control it
will be set to radio.
2 name
160
Elements of H T M L
Example
Here is example HTML code for a form with one drop down box
<!DOCTYPE html>
<html>
<head>
<title>Select Box Control</title>
</head>
<body>
<form>
<select name = “dropdown”>
<option value = “Maths” selected>Maths</option>
<option value = “Physics”>Physics</option>
</select>
</form>
</body>
</html>
This will produce the following result −
Attributes
Following is the list of important attributes of <select> tag −
161
Basic Computer Coding: HTML
The value that will be used if an option in the select box box is
selected.
2 selected
Example
Here is example HTML code for a form with one file upload box −
<!DOCTYPE html>
<html>
<head>
<title>File Upload Box</title>
</head>
<body>
<form>
<input type = “file” name = “fileupload” accept = “image/*” />
</form>
</body>
</html>
This will produce the following result –
Attributes
Following is the list of important attributes of file upload box −
162
Elements of H T M L
Example
Here is example HTML code for a form with three types of buttons −
<!DOCTYPE html>
<html>
<head>
<title>File Upload Box</title>
</head>
<body>
<form>
<input type = “submit” name = “submit” value = “Submit” />
<input type = “reset” name = “reset” value = “Reset” />
<input type = “button” name = “ok” value = “OK” />
163
Basic Computer Coding: HTML
Example
Here is example HTML code to show the usage of hidden control −
<!DOCTYPE html>
<html>
<head>
<title>File Upload Box</title>
</head>
<body>
<form>
<p>This is page 10</p>
<input type = “hidden” name = “pagename” value = “10” />
<input type = “submit” name = “submit” value = “Submit” />
<input type = “reset” name = “reset” value = “Reset” />
</form>
</body>
</html>
This will produce the following result −
This is page 10
164
Elements of H T M L
SUMMARY
■ An HTML element is a component of an HTML document that tells a web
browser how to structure and interpret a part of the HTML document.
HTML elements can contain formatting instructions, semantic meaning,
and content.
■ HTML5 does not require empty elements to be closed. But if you want
stricter validation, or if you need to make your document readable by
XML parsers, you must close all HTML elements properly.
■ The META elements can be used to include name/value pairs describing
properties of the HTML document, such as author, expiry date, a list of
keywords, document author etc.
■ The tag is used to provide such additional information. This tag is an
empty element and so does not have a closing tag but it carries information
within its attributes.
■ Cookies are data, stored in small text files on your computer and it is
exchanged between web browser and web server to keep track of various
information based on your web application need.
■ The div tag is known as Division tag. The Div tag is used in HTML to
make divisions of content in the web page like (text, images, header, footer,
navigation bar etc). Div tag has both open() tag and it is mandatory to
close the tag.
■ Div tag is a container tag inside div tag we can put more than one HTML
element and can group together and can apply CSS for them.
■ HTML also includes logical styles. These are more general descriptions
that may be interpreted by each browser differently. They make your
document easier to follow and edit. They will also allow your page to
conform to local custom; if a journal citation (for example) is typically
bold in one country and italicized in another, the use of the logical style
will cause it to appear correctly in each place.
■ HTML and XHTML supports a list style which is called definition lists
where entries are listed like in a dictionary or encyclopedia. The definition
list is the ideal way to present a glossary, list of terms, or other name/
value list.
■ An HTML table is defined with the <table> tag. Each table row is defined
with the <tr> tag. A table header is defined with the <th> tag. By default,
table headings are bold and centered. A table data/cell is defined with
the <td> tag.
■ Checkboxes are used when more than one option is required to be selected. They
are also created using HTML <input> tag but type attribute is set to checkbox.
■ Radio buttons are used when out of many options, just one option is
required to be selected. They are also created using HTML <input> tag
but type attribute is set to radio.
165
Basic Computer Coding: HTML
KNOWLEDGE CHECK
1. Which one of the following is the most significant heading tag?
a. <h1>
b. <h3>
c. <h5>
d. <h6>
2. Choose the correct option.
a. Elements in HTML describes the way of presenting the content in the
browser.
b. All elements must have atleast one attribute associated with it.
c. Both a and b.
d. None of the above
3. In HTML, <ul> means
a. Underline
b. Unique list.
c. Unordered list.
d. None of the above
4. Which one of the following options is correct?
a. Both block element and inline element start in the new line.
b. Both block element and inline element start in the same line
c. Only inline element starts in new line.
d. Only block element starts in new line.
5. Which of the following is an inline element?
a. <p>
b. <h1>
c. <div>
d. <s>
6. The BODY Tag Is Usually Used After
a. EM Tag
b. TITLE Tag
c. HEAD Tag
d. HTML Tag
167
Basic Computer Coding: HTML
d. <text>
15. What HTML tag is used to create an unordered list?
a. <ol>
b. <ul>
c. <li>
d. <list>
REVIEW QUESTIONS
1. Explain the Nested HTML Elements.
2. Discuss the Empty HTML elements.
3. Define the adding Meta Tags to your documents.
4. Explain the document revision date.
5. Describe the creating web layout using Div Tag.
6. Explain the HTML form controls.
7. Explain the use of the <form> element in HTML. What attributes are
commonly associated with it?
8. What does the <em> element represent in HTML, and how does it differ
from the <strong> element?
9. Define the purpose of the <div> element. How is it commonly used in
HTML for structuring content?
10. What is the significance of the <input> element in HTML forms, and how
can different input types be specified?
168
Elements of H T M L
REFERENCES
1. Berglund A., 2006. Extensible Stylesheet Language (XSL) Version 1.1. World
Wide Web Consortium (W3C).
2. Bray, T. et al, 2008. Extensible Markup Language (XML) 1.0 (Fifth Edition).
World Wide Web Consortium (W3C).
3. Costello, J. et al, 2002. XML: A New Web Site Architecture. SUNY Center
for Technology in Government. Albany, NY, [Link]
publications/reports/xml
4. Extensible Markup Language (XML) 1.0 (fifth edition) T. Bray, J. Paoli, C.M.
Sperberg-McQueen, Eve Maler, François Yergeau, editors, 26 November 2008.
5. Extensible Markup Language (XML) 1.0 (fifth edition) T. Bray, J. Paoli, C.M.
Sperberg-McQueen, Eve Maler, François Yergeau, editors, 26 November 2008.
6. Gabor Grothendieck and Thomas Petzoldt. R help desk: Date and time classes
in R. R News, 4(1):29-32, 2004.
7. In Wolfgang Härdle and Bernd Rönz, editors, Compstat 2002 -- Proceedings
in Computational Statistics, pages 575-580. Physica Verlag, Heidelberg, 2002.
8. Pilgrim, Mark. HTML5: Up and Running, O’Reilly, 2010.
9. Powers, Shelley. HTML5 Media Integrating audio and video with the Web,
O’Reilly, 2011.
10. Rhea, John. A Beginner’s Guide to Learning HTML (and Smacking Zombies
Upside the Web Development), Undead Institute, 2018.
11. Smith, M., 2013. HTML: The Markup Language (an HTML language reference).
World Wide Web Consortium
12. Stevens, Luke. The Truth About HTML5 (For Web Designers), 2012.
13. Weyl, Estelle, et al. HTML5 & CSS3 For The Real World, Sitepoint, 2016.
169
CHAPTER 5
HTML5
LEARNING OBJECTIVES
173
Basic Computer Coding: HTML
174
HTML5
HTML 5 does not have the same syntax rules as XHTML where we needed
lower case tag names, quoting our attributes, an attribute had to have a value and
to close all empty elements.
HTML5 comes with a lot of flexibility and it supports the following features −
■ Uppercase tag names.
■ Quotes are optional for attributes.
■ Attribute values are optional.
■ Closing empty elements are optional.
176
HTML5
convention is to stick with lowercase. Most of the elements contain some content
like <p>...</p> contains a paragraph. Some elements, however, are forbidden from
containing any content at all and these are known as void elements. For example,
br, hr, link, meta, etc.
Tag Description
<!--...--> Specifies a comment
<!DOCTYPE> Specifies the document type
<a> Specifies an anchor
<abbr> Specifies an abbreviation
<acronym> Deprecated: Specifies an acronym
<address> Specifies an address element
<applet> Deprecated: Specifies an applet
<area> Specifies an area inside an image map
<article> New Tag: Specifies an independent piece
of content of a document, such as a blog
entry or newspaper article
<aside> New Tag: Specifies a piece of content that
is only slightly related to the rest of the
page.
<audio> New Tag: Specifies an audio file.
<base> Specifies a base URL for all the links in a
page
<basefont> Deprecated: Specifies a base font
<bdo> Specifies the direction of text display
<bgsound> Specifies the background music
<blink> Specifies a text which blinks
<blockquote> Specifies a long quotation
<body> Specifies the body element
<br> Inserts a single line break
<button> Specifies a push button
<canvas> New Tag: This is used for rendering
dynamic bitmap graphics on the fly, such
as graphs or games.
<caption> Specifies a table caption
<center> Deprecated: Specifies centered text
177
Basic Computer Coding: HTML
178
HTML5
179
Basic Computer Coding: HTML
180
HTML5
181
Basic Computer Coding: HTML
182
HTML5
Following is the simple example of using labels, radio buttons, and submit
buttons −
...
<form action = “[Link] method = “post”>
183
Basic Computer Coding: HTML
<p>
<label for = “firstname”>first name: </label>
<input type = “text” id = “firstname”><br />
A date and time (year, month, day, hour, minute, second, fractions of a second)
encoded according to ISO 8601 with the time zone set to UTC.
2 datetime-local
A date and time (year, month, day, hour, minute, second, fractions of a second)
encoded according to ISO 8601, with no time zone information.
3 date
184
HTML5
5 week
A date consisting of a year and a week number encoded according to ISO 8601.
6 time
It accepts only numerical value. The step attribute specifies the precision,
defaulting to 1.
8 range
The range type is used for input fields that should contain a value from a range
of numbers.
9 email
It accepts only email value. This type is used for input fields that should
contain an e-mail address. If you try to submit a simple text, it forces to enter
only email address in email@[Link] format.
10 url
It accepts only URL value. This type is used for input fields that should contain
a URL address. If you try to submit a simple text, it forces to enter only URL
address either in [Link] format or in [Link]
format.
<html>
<head>
<script type = “text/javascript”>
function showResult() {
x = [Link][“myform”][“newinput”].value;
[Link][“myform”][“result”].value = x;
}
185
Basic Computer Coding: HTML
</script>
</head>
<body>
</body>
</html>
It will produce the following result −
<html>
<body>
</body>
</html>
186
HTML5
<html>
<body>
</body>
</html>
<html>
<body>
187
Basic Computer Coding: HTML
</body>
</html>
It will produce the following result −
188
HTML5
</svg>
Firefox 3.7 has also introduced a configuration option (“about:config”) where
you can enable HTML5 using the following steps −
■ Type about:config in your Firefox address bar.
■ Click the “I’ll be careful, I promise!” button on the warning message that
appears (and make sure you adhere to it!).
■ Type [Link] into the filter bar at the top of the page.
■ Currently it would be disabled, so click it to toggle the value to true.
Now your Firefox HTML5 parser should be enabled and you should be able
to experiment with the following examples.
<html>
<head>
<style>
#svgelem {
position: relative;
left: 50%;
-webkit-transform: translateX(-20%);
-ms-transform: translateX(-20%);
transform: translateX(-20%);
}
</style>
<title>SVG</title>
<meta charset = “utf-8” />
</head>
<body>
<h2 align = “center”>HTML5 SVG Circle</h2>
189
Basic Computer Coding: HTML
</svg>
</body>
</html>
This would produce the following result in HTML5 enabled latest version of
Firefox.
<style>
#svgelem {
position: relative;
left: 50%;
-webkit-transform: translateX(-50%);
-ms-transform: translateX(-50%);
transform: translateX(-50%);
}
</style>
<title>SVG</title>
<meta charset = “utf-8” />
</head>
<body>
<h2 align = “center”>HTML5 SVG Rectangle</h2>
<html>
<head>
<style>
#svgelem {
position: relative;
left: 50%;
-webkit-transform: translateX(-50%);
-ms-transform: translateX(-50%);
transform: translateX(-50%);
}
</style>
<title>SVG</title>
<meta charset = “utf-8” />
</head>
<body>
<h2 align = “center”>HTML5 SVG Line</h2>
191
Basic Computer Coding: HTML
<html>
<head>
<style>
#svgelem {
position: relative;
left: 50%;
-webkit-transform: translateX(-40%);
-ms-transform: translateX(-40%);
transform: translateX(-40%);
}
</style>
<title>SVG</title>
<meta charset = “utf-8” />
</head>
192
HTML5
<body>
<h2 align = “center”>HTML5 SVG Ellipse</h2>
</body>
</html>
This would produce the following result in HTML5 enabled latest version of
Firefox.
<html>
<head>
<style>
#svgelem {
position: relative;
left: 50%;
-webkit-transform: translateX(-50%);
-ms-transform: translateX(-50%);
transform: translateX(-50%);
}
</style>
<title>SVG</title>
193
Basic Computer Coding: HTML
<body>
<h2 align = “center”>HTML5 SVG Polygon</h2>
<html>
<head>
<style>
#svgelem {
position: relative;
left: 50%;
-webkit-transform: translateX(-20%);
-ms-transform: translateX(-20%);
transform: translateX(-20%);
}
</style>
194
HTML5
<title>SVG</title>
<meta charset = “utf-8” />
</head>
<body>
<h2 align = “center”>HTML5 SVG Polyline</h2>
<svg id = “svgelem” height = “200” xmlns = “http://
[Link]/2000/svg”>
<polyline points = “0,0 0,20 20,20 20,40 40,40
40,60” fill = “red” />
</svg>
</body>
</html>
This would produce the following result in HTML5
enabled latest version of Firefox.
<style>
#svgelem {
position: relative;
left: 50%;
195
Basic Computer Coding: HTML
-webkit-transform: translateX(-40%);
-ms-transform: translateX(-40%);
transform: translateX(-40%);
}
</style>
<title>SVG</title>
<meta charset = “utf-8” />
</head>
<body>
<h2 align = “center”>HTML5 SVG Gradient Ellipse</h2>
</body>
</html>
This would produce the following result in HTML5 enabled latest version of
Firefox.
<style>
#svgelem {
position: relative;
left: 50%;
-webkit-transform: translateX(-40%);
-ms-transform: translateX(-40%);
transform: translateX(-40%);
}
</style>
<title>SVG</title>
<meta charset = “utf-8” />
</head>
<body>
<h2 align = “center”>HTML5 SVG Star</h2>
197
Basic Computer Coding: HTML
If a user buying plane tickets in two different windows, using the same
site. If the site used cookies to keep track of which ticket the user was
buying, then as the user clicked from page to page in both windows, the
ticket currently being purchased would “leak” from one window to the
other, potentially causing the user to buy two tickets for the same flight
without really noticing.
198
HTML5
if( [Link] ) {
[Link] = Number([Link]) +1;
} else {
[Link] = 1;
}
[Link](“Total Hits :” + [Link] );
</script>
</body>
</html>
This will produce the following result −
Total Hits :1
Close the window and open it again and check the result.
Example
HTML5 introduces the localStorage attribute which would be used to access a page’s
local storage area without no time limit and this local storage will be available
whenever you would use that page.
Following is the code which would set a local storage variable and access
that variable every time this page is accessed, even next time, when you open the
window −
<!DOCTYPE HTML>
199
Basic Computer Coding: HTML
<html>
<body>
<script type = “text/javascript”>
if( [Link] ) {
[Link] = Number([Link]) +1;
} else {
[Link] = 1;
}
[Link](“Total Hits :” + [Link] );
</script>
</body>
</html>
This will produce the following result −
Total Hits :1
Close the window and open it again and check the result.
[Link]();
</script>
</body>
</html>
This will produce following result −
Total Hits :1
Close the window and open it again and check the result.
201
Basic Computer Coding: HTML
CASE STUDY
HTML5: WEB APP DEVELOPMENT
The Client
The client is an industry leading market research firm.
They build cloud-based software that facilitate two-way communication that
ranges from market research to civic engagement for their clients’ specific platforms.
Their solutions have accessible UIs and feature modules for survey authoring,
community management, discussion forums, and reporting services.
The Challenge
The client required their survey application to be accessible on mobile devices. They
were looking for a web-based solution that would work across multiple devices
and have a rich mobile user interface.
Key Challenges
■ The client required a rich web GUI that is comparable to a native application
in terms of control sophistication and user experience.
■ The application had to be extensible so that modifications to elements of
the survey and new ways to integrate with the back end would be easy
to accommodate.
■ The application was to be used on a variety of devices; consequently, the
respective native browser’s behavior and constraints had to be considered.
The Process
■ Agile development process consisting of multiple sprints.
■ Testing locally on multiple devices.
■ Deliveries made in overlapping meetings with clients.
■ Cloud-based staging environment for a shared test system.
different type of data fetching services. This allows the clients to add new data
generation services when they are created.
We then conducted device and user agent detections by using open source 3rd
party WURFL services. Device-specific code customizations were made to handle
the device’s limitations.
Finally, the application was vetted to see if it performed at an acceptable
performance level. We made sure to verify an acceptable level for all question
types, including those that required heavy UI side processing.
The end result is a web-based survey tool that works across virtually all modern
mobile devices. The UI has a consistent look and feel and provides a positive user
experience.
203
Basic Computer Coding: HTML
SUMMARY
■ HTML5 is the next major revision of the HTML standard superseding HTML
4.01, XHTML 1.0, and XHTML 1.1. HTML5 is a standard for structuring
and presenting content on the World Wide Web.
■ HTML5 is designed, as much as possible, to be backward compatible
with existing web browsers. Its new features have been built on existing
features and allow you to provide fallback content for older browsers.
■ The HTML 5 language has a “custom” HTML syntax that is compatible
with HTML 4 and XHTML1 documents published on the Web, but is not
compatible with the more esoteric SGML features of HTML 4.
■ DOCTYPEs in older versions of HTML were longer because the HTML
language was SGML based and therefore required a reference to a DTD.
■ Web Forms 2.0 is an extension to the forms features found in HTML4. Form
elements and attributes in HTML5 provide a greater degree of semantic
mark-up than HTML4 and free us from a great deal of tedious scripting
and styling that was required in HTML4.
■ HTML5 introduced a new attribute called placeholder. This attribute on
<input> and <textarea> elements provide a hint to the user of what can
be entered in the field.
■ SVG stands for Scalable Vector Graphics and it is a language for describing
2D-graphics and graphical applications in XML and the XML is then
rendered by an SVG viewer. SVG is mostly useful for vector type diagrams
like Pie charts, Two dimensional graphs in an X,Y coordinate system etc.
■ Cookies are included with every HTTP request, thereby slowing down
your web application by transmitting the same data.
■ The Session Storage is designed for scenarios where the user is carrying
out a single transaction, but could be carrying out multiple transactions
in different windows at the same time.
■ The Local Storage is designed for storage that spans multiple windows, and
lasts beyond the current session. In particular, Web applications may wish
to store megabytes of user data, such as entire userauthored documents
or a user’s mailbox, on the client side for performance reasons.
204
HTML5
KNOWLEDGE CHECK
1. Which of the following browser supports HTML5 in its latest version?
a. Apple Safari
b. Google Chrome
c. Both of the above.
d. None of the above.
2. Which of the following tag can be used to mark up a conversation in HTML5?
a. footer
b. nav
c. dialog
d. figure
3. Which of the following input control represents a date consisting of a year
and a week number encoded according to ISO 8601 in Web Form 2.0?
a. week
b. time
c. number
d. range
4. Can you use MathML tags directly in HTML5 without any plugin?
a. True
b. False
5. When a session storage data gets deleted in HTML5?
a. The Session Storage Data would be deleted by the browsers immediately
after the session gets terminated.
b. If you want to clear all settings, you need to call [Link]()
method.
c. Both of the above.
d. None of the above.
6. Which browsers does the HTML5 supports?
a. Firefox
b. Safari
c. Internet Explorer
d. All the mentioned above
7. ………….is the replacement for cookies in HTML5.
a. Java scripts
b. Web beacons
c. Local Storage
d. All of the above
205
Basic Computer Coding: HTML
REVIEW QUESTIONS
1. What is HTML5? Name some of the new features of HTML5. Which
browsers support HTML5?
2. What is web forms 2.0?
3. What are the purpose of ‘output’ tag and ‘placeholder’ attribute in HTML5?
206
HTML5
207
Basic Computer Coding: HTML
REFERENCES
1. Baker, Mitchell (2014-05-14). “DRM and the Challenge of Serving Users”.
Mozilla. Retrieved 2014-05-20.
2. Cimpanu, Catalin (29 May 2019). “Browser vendors Win War with W3C over
HTML and DOM standards”. ZDNet. Archived from the original on 29 May
2019. Retrieved 29 May 2019.
3. Danny O’Brien (2013-10-02). “Lowering Your Standards: DRM and the Future
of the W3C”. Electronic Frontier Foundation. Retrieved 2013-10-03.
4. Doctorow, Cory (2014-05-14). “Firefox’s adoption of closedsource DRM breaks
my heart”. The Guardian. Retrieved 2014- 05-20.
5. Faulkner, Steve; Eicholz, Arron; Leithead, Travis; Danilo, Alex; Moon,
Sangwhan; Doyle Navara, Erika; O’Connor, Theresa; Berjon, Robin, eds. (14
December 2017) [2016]. “HTML 5.2 W3C Recommendation”. Revised version.
World Wide Web Consortium (W3C). Retrieved 26 July 2018.
6. Gal, Andreas (2014-05-14). “Reconciling Mozilla’s Mission and W3C EME”.
Mozilla. Retrieved 2014-05-20.
7. Hickson, Ian, ed. (25 July 2018). “HTML Living Standard”. Multipage Version.
WHATWG. Retrieved 26 July 2018.
8. HTML5 is a W3C recommendation. W3C Blog. World Wide Web Consortium
(W3C). 28 October 2014. Retrieved 28 October 2014.
9. Manu Sporny (2013-01-26). “DRM in HTML5”. The Beautiful, Tormented
Machine. Manu Sporny. Archived from the original on 2014-04-25. Retrieved
2014-05-16.
10. Scott Gilbertson (2013-02-12). “DRM for the Web? Say It Ain’t So”. Webmonkey.
Condé Nast. Archived from the original on 2013-04-06. Retrieved 2013-03-21.
11. W3C Confirms May 2011 for HTML5 Last Call, Targets 2014 for HTML5
Standard. World Wide Web Consortium. 14 February 2011. Retrieved 18
February 2011.
12. W3C Workshop on Web Applications and Compound Documents (Day 1).
[Link]. W3C. 1 June 2004. Retrieved 30 December 2011.
208
CHAPTER 6
CASCADING
STYLE SHEETS
LEARNING OBJECTIVES
210
Cascading Style Sheets
A rule can be set up that tells the browser to format every <P> tag so
that its first line is indented. Or you could construct your own paragraph
rule, and just apply the style to certain paragraphs, not all paragraphs.
211
Basic Computer Coding: HTML
within which various attributes, such as font-size and background-color are assigned
values. The World Wide Web Consortium (W3C) standards organization defines the
CSS attributes, although various browsers may offer supplemental support by defining
their own custom fields. This is often done for proposed attributes that are expected
to be included in future CSS releases.
CSS example
The following HTML page is using both an internal style and an inline style for
defining cascading style sheet information:
Figure 1. Using inline styles vs. internal styles with cascading styles
Notice that, when the webpage renders, any text that is not contained within
a style just renders as plain black text on a white background.
Figure 2. Rendering a CSS formatted HTML webpage that uses both inline styles and
internal styles
Any text contained within a paragraph tag without an inline style pulls
formatting information from the internal stylesheet, which means it is rendered
as blue, 14-pixel, italicized text on a silver background. However, when the inline
style is used, the internal style overrides and matches properties, while leaving
212
Cascading Style Sheets
nonconflicting attributes alone, causing the text to render as white, 20-pixel, italicized
text on a silver background.
213
Basic Computer Coding: HTML
color: #000000;
}
This rule renders the content of every element in our document in black.
The ID Selectors
You can define style rules based on the id attribute of the elements. All the
elements having that id will be formatted according to the defined rule.
#black {
color: #000000;
}
This rule renders the content in black for every element with id attribute set
214
Cascading Style Sheets
to black in our document. You can make it a bit more particular. For example −
h1#black {
color: #000000;
}
This rule renders the content in black for only <h1> elements with id attribute
set to black.
The true power of id selectors is when they are used as the foundation for
descendant selectors, For example −
#black h2 {
color: #000000;
}
In this example all level 2 headings will be displayed in black color when those
headings will lie with in tags having id attribute set to black.
215
Basic Computer Coding: HTML
216
Cascading Style Sheets
217
Basic Computer Coding: HTML
#FF0000
#00FF00
#0000FF
#FFFF00
#00FFFF
#FF00FF
#C0C0C0
#FFFFFF
218
Cascading Style Sheets
rgb(192,192,192)
rgb(255,255,255)
219
Basic Computer Coding: HTML
220
Cascading Style Sheets
<body>
<p style = “font-family:georgia,garamond,serif;”>
This text is rendered in either georgia, garamond,
or the
default serif font depending on which font you
have at your system.
</p>
</body>
</html>
This will produce following result −
This text is rendered in either georgia, garamond, or
the default serif font depending on which font you have at
your system.
221
Basic Computer Coding: HTML
<html>
<head>
</head>
<body>
<p style = “font-variant:small-caps;”>
This text will be rendered as small caps
</p>
</body>
</html>
This will produce following result −
THIS TEXT WILL BE RENDERED AS SMALL CAPS
222
Cascading Style Sheets
<html>
<head>
</head>
<body>
<p style = “font-weight:bold;”>
This font is bold.
</p>
<body>
<p style = “font-size:20px;”>
This font size is 20 pixels
</p>
224
Cascading Style Sheets
</head>
<body>
<p style = “font-stretch:ultra-expanded;”>
If this doesn’t appear to work, it is likely that
your computer
doesn’t have a <br>condensed or expanded version
of the font being used.
</p>
</body>
</html>
This will produce following result −
If this doesn’t appear to work, it is likely that your
computer doesn’t have a condensed or expanded version of
the font being used.
Shorthand Property
You can use the font property to set all the font properties
at once. For example −
<html>
<head>
</head>
Keyword
<body>
<p style = “font:italic small-caps bold 15px georgia;”> Rendering is
the automatic
Applying all the properties on the text at once.
process of
</p> generating a
</body> photorealistic
or non-
</html> photorealistic
This will produce following result − image from
a 2D or 3D
APPLYING ALL THE PROPERTIES ON THE TEXT AT model by means
ONCE. of computer
programs.
6.2.3 CSS - Tables
This stage will teach you how to set different properties of
an HTML table using CSS. You can set following properties
of a table −
225
Basic Computer Coding: HTML
td.a {
border-style:dotted;
border-width:3px;
border-color:#000000;
padding: 10px;
}
td.b {
border-style:solid;
border-width:3px;
border-color:#333333;
padding:10px;
}
</style>
</head>
226
Cascading Style Sheets
<body>
<table class = “one”>
<caption>Collapse Border Example</caption>
<tr><td class = “a”> Cell A Collapse Example</td></tr>
<tr><td class = “b”> Cell B Collapse Example</td></tr>
</table>
<br />
227
Basic Computer Coding: HTML
</style>
Now let’s modify the example and see the effect −
<html>
<head>
<style type = “text/css”>
[Link] {
border-collapse:separate;
width:400px;
border-spacing:10px;
}
[Link] {
border-collapse:separate;
width:400px;
border-spacing:10px 50px;
}
</style>
</head>
<body>
<table class = “one” border = “1”>
<caption>Separate Border Example with border-spacing</caption>
<tr><td> Cell A Collapse Example</td></tr>
<tr><td> Cell B Collapse Example</td></tr>
</table>
<br />
</body>
</html>
It will produce the following result −
228
Cascading Style Sheets
<body>
229
Basic Computer Coding: HTML
</caption>
<tr><td > Cell A</td></tr>
<tr><td > Cell B</td></tr>
</table>
<br />
</body>
</html>
It will produce the following result −
230
Cascading Style Sheets
<body>
<tr>
<th>Row Title</th>
<td class = “empty”>value</td>
<td class = “empty”>value</td>
231
Basic Computer Coding: HTML
</tr>
<tr>
<th>Row Title</th>
<td class = “empty”>value</td>
<td class = “empty”></td>
</tr>
</table>
Did You
Know? </body>
CSS was
first proposed </html>
by Håkon Wium It will produce the following result −
Lie on October
10, 1994. At the
time, Lie was
working with
Tim Berners-Lee
at CERN. Several
other style sheet
languages for
the web were The table-layout Property
proposed around
the same time, The table-layout property is supposed to help you control
and discussions how a browser should render or lay out a table.
on public mailing
lists and inside This property can have one of the three values: fixed,
World Wide auto or inherit.
Web Consortium
resulted in the The following example shows the difference between these
first W3C CSS properties.
Recommendation <html>
(CSS1) being
released in 1996. <head>
<style type = “text/css”>
[Link] {
table-layout: auto
}
[Link] {
table-layout: fixed
}
</style>
</head>
<body>
232
Cascading Style Sheets
</body>
</html>
It will produce the following result −
233
Basic Computer Coding: HTML
SUMMARY
■ Cascading style sheets (CSS) are used to format the layout of Web pages.
They can be used to define text styles, table sizes, and other aspects of
Web pages that previously could only be defined in a page’s HTML.
■ A Cascading Style sheet rule tells the browser what the HTML looks like,
and what it should do. A rule can dictate what just one HTML tag should
look like, or you can construct your own rule to be applied as and where
you want it.
■ CSS syntax is relatively simple. The name of the element to style, referred to
as the CSS selector, is followed by braces, within which various attributes,
such as font-size and backgroundcolor are assigned values.
■ CSS handles the look and feel part of a web page. Using CSS, you can control
the color of the text, the style of fonts, the spacing between paragraphs,
how columns are sized and laid out, what background images or colors
are used, layout designs, and variations in display for different devices
and screen sizes as well as a variety of other effects.
■ CSS uses color values to specify a color. Typically, these are used to set
a color either for the foreground of an element (i.e., its text) or else for
the background of the element. They can also be used to affect the color
of borders and other decorative effects.
■ A hexadecimal is a 6 digit representation of a color. The first two digits
(RR) represent a red value, the next two are a green value(GG), and the
last are the blue value(BB).
■ The border-collapse specifies whether the browser should control the
appearance of the adjacent borders that touch each other or whether each
cell should maintain its style.
■ The border-spacing property specifies the distance that separates adjacent
cells’. borders. It can take either one or two values; these should be units
of length.
234
Cascading Style Sheets
KNOWLEDGE CHECK
1. Which of the following selector selects all elements of E that have the
attribute attr that end with the given value?
a. E[attr^=value]
b. E[attr$=value]
c. E[attr*=value]
d. none of the mentioned
2. Which of the following selector selects the elements that are checked?
a. E~F
b. ::after
c. :checked
d. none of the mentioned
3. Which of the following selector selects the elements that are the default
among a set of similar elements?
a. :default
b. :%
c. :disabled
d. none of the mentioned
4. Which of the following selector selects an element that has no children?
a. :empty
b. :nochild
c. :inheritance
d. :no-child
5. Which of the following selector selects the elements that are currently
enabled?
a. :element
b. :empty
c. :enabled
d. none of the mentioned
6. CSS stands for -
a. Cascade style sheets
b. Color and style sheets
c. Cascading style sheets
d. None of the above
7. Which of the following is the correct syntax for referring the external style
sheet?
a. <style src = [Link]>
235
Basic Computer Coding: HTML
236
Cascading Style Sheets
REVIEW QUESTIONS
1. What is the cascading style rules?
2. Discuss on the style sheet language.
3. Give a suitable CSS example.
4. Write the syntax of CSS.
5. Explain the following CSS properties:
a. CSS - Colors
b. CSS - Tables
6. Explain the concept of the box model in CSS. What are the main components
of the box model?
7. Describe the difference between classes and IDs in CSS. When would you
use one over the other?
8. What is the significance of the “Cascading” in Cascading Style Sheets?
How does it influence the styling of HTML elements?
9. Explain the role of pseudo-classes in CSS. Provide an example of a scenario
where a pseudo-class might be useful.
10. What is the purpose of the float property in CSS? How does it affect the
layout of elements on a webpage?
237
Basic Computer Coding: HTML
REFERENCES
1. Andrew, Rachel. The New CSS Layout , A Book Apart, 2017.
2. Bartlett, Kynn. Sams Teach Yourself Cascading Style Sheets in 24 Hours,
Second Edition, Sams, 2006.
3. Briggs, Owen et al. Cascading Style Sheets: Separating Content from
Presentation, Second Edition, APress, 2004.
4. Brown, Tiffany. CSS Master, Sitepoint, 2021.
5. Budd, Andy, et al. CSS Mastery: Advanced Web Standards Solutions, Friends
of ED, 2006.
6. Casciano, Chris. The CSS Pocket Guide, Peachpit Press, 2010.
7. Cederholm, Dan. CSS3 For Web Designers, A Book Apart, 2015.
8. Clarke, Andy. Hardboiled Web Design, Five Simple Steps, 2010.
9. Clarke, Andy. Transcending CSS: The Fine Art of Web Design, New Riders,
2006.
10. Collison, Simon. Professional CSS for Web Development: From Novice to
Professional, APress, 2006.
11. Croft, Jeff, , et al. ProCSS Techniques, APress, 2006.
12. Debolt, Virginia. Integrated HTML and CSS, Sybex Inc, 2005.
13. Debolt, Virginia. Mastering Integrated HTML and CSS, Sybex Inc, 2007.
14. Freeman, Elisabeth and Freeman, Eric. Head First HTML with CSS & XHTML,
O’Reilly & Associates, 2005.
15. Gasston, Peter. Book of CSS3, No Starch Press, 2011.
16. Gillenwater, Zoe, Mickley. Flexible Web Design: Creating Liquid and Elastic
Layouts with CSS, New Riders Press, 2008.
17. Gillenwater, Zoe, Mickley. Stunning CSS3: A Project-based Guide to the Latest
in CSS, New Riders Press, 2010.
18. Grannell, Craig. The Essential Guide to CSS and HTML Web Design, friends
of ED, 2007.
19. Grannell, Craig. Web Designer’s Reference, friends of ED, 2004.
20. Griffiths, Patrick. XHTML & CSS: A Web Standards Approach, New Riders,
2005.
21. Holzschlag, Molly and Clarke, Andy. Transcending CSS : The Fine Art of
Web Design, New Riders Press, 2006.
22. Holzschlag, Molly. Spring Into HTML and CSS, Addison-Wesley Professional,
2005.
238
CHAPTER 7
WEB HOSTING
LEARNING OBJECTIVES
240
Web Hosting
Keyword
An Introduction to Web Hosting
Internet
is the
global system of
interconnected
computer
networks that
use the Internet
protocol suite
(TCP/IP) to
link devices
worldwide.
If sites have downtime, or they decide to add cost further down the line.
There are a number of different types of web hosts and depending on the
size of your business and your business priorities, you can choose the
.most relevant type of web host
241
Basic Computer Coding: HTML
the Internet has a unique numerical Internet Protocol (IP) address. If the servers act
as metaphorical apartment buildings with unique addresses, then each apartment
unit within these buildings provides rented space for individual websites. Much
like real apartment buildings, each unit also has an address based on “the building”
in which it is located, which is the IP address for a particular website.
Web Hosting
Depending on your level of expertise, web hosting, which is the task of making
websites and web pages available to many users, can be either very simple of
daunting. In this section we are going to explore the different types of hosting.
242
Web Hosting
Shared Hosting
Shared hosting is one of the more common methods for
website hosting. It is also the cheapest, and least reliable.
This is when several website owners are sharing a single
server including all resources such as CPU, memory and drive
space. This is the most cost efficient as all of the different
website owners share in the operational expenses of the
single server. However, you can suffer from “bad neighbor
syndrome”: if another website is sharing the same webhost
as your site, and if it is very busy, then it will hog the CPU
and RAM and network bandwidth of the web host, resulting
in poor performance for all the other websites on the host.
The result of this will be that all sites will load very slowly.
Keyword
DDoS
Attack means
“Distributed
Denial-of-
Service (DDoS)
Attack” and it
There are also security risks with this kind of hosting. is a cybercrime
If one of the other websites gets hacked, or infected with in which the
malware, then it is very likely that the other websites on attacker floods
a server with
the same webhost will also be infected since the all run on
internet traffic
the same computer. And if there is a DDOS attack on one
to prevent users
of the sites, then, again, they are all affected because they from accessing
share the same resource. This type of hosting should only connected online
be used for small sites that are not expecting much traffic. services and sites.
Dedicated Hosting
For those that rely on maximum performance and an
ultimately secured platform, dedicated hosting provides that
functionality. In this environment, a single person leases
an entire server eliminating resource use by other website
owners. This means that 100 % of the system is operating
for your purposes alone. This also gives you full control of
the machine, so that it can be configured any way you like,
with whatever software, or modules and as little or as much
security as you want. Dedicated servers are also one of the
most expensive hosting options.
243
Basic Computer Coding: HTML
VPS Hosting
A Virtual Private Servers, or VPS, is a virtual machine running
on top of a real machine. Several VPS servers may run on
a single real server machine. A VPS runs its own separate
Keyword copy of the operating system on its own separate space
on the host server, and so can be treated as if it is really
Operating a separate computer. This means it has the advantages of
system is
a dedicated server in terms of having full control over the
system software
that manages machine, but not the cost. The drawback is that performance
computer will not be as good as a dedicated server, but it is far better
hardware than shared hosting. The main difference between VPS and
and software shared hosting is that each VPS runs an entirely separate
resources operating system instance inside its own virtual machine,
and provides whereas on a shared host, only one single operating system
common services runs which is shared by all the websites.
for computer
programs.
Cloud Hosting
Instead of relying on a single server to host a website, the
Cloud alternative utilizes a network of machines to provide
the content. A single account could be spread out across many
different servers which could include those in other cities or
even countries. This provides reliability, scaling of size and
.faster recovery times in the event of a disaster
244
Web Hosting
Using as much as they need without having to build and maintain their own
computing infrastructure in-house. The resources required for maintaining your
website are spread across more than one web server, reducing the chance of any
downtime due to server malfunction. Cloud-based hosting is scalable, meaning
your site can grow over time, using as much resource as it requires and you only
pay for what you need.
Managed hosting
Most hosting packages you are likely to find online will be managed. Hosting
companies provide technical services such as hardware and software setup and
configuration, maintenance, hardware replacement, technical support, patching,
updating and monitoring. Unlike standard dedicated hosting, the hosting provider
looks after the day-to-day management of the hardware, operating systems and
standardized applications. A popular sub-category is WordPress managed hosting.
For many businesses, the beauty of Wordpress is in its simplicity. Its benefits are
clear, it is easy to setup and it is straightforward to manage. Choosing a hosting
provider for a Wordpress site can be more of a task, however, especially for those
without expert knowledge or experience of the market. Many web-hosting companies
now specialize solely in offering managed services for WordPress.
Colocation
Instead of keeping servers in-house or at a private data center, you may choose to
”‘co-locate” your equipment by renting space in a colocation center. The center will
provide the power, bandwidth, IP address and cooling systems that your server
requires. Space is rented out in “racks’ and ‘cabinets”. Colocation gives access to
higher levels of bandwidth than a normal office server room at a much lower cost.
You are left to your own devices (literally) and will be expected to take care of
everything including the hardware, software and services.
245
Basic Computer Coding: HTML
Remember
Formerly,
many
colocation
providers
would accept
any system
configuration You all must have heard that to make a website visible
for hosting, even on World Wide Web it is necessary to host it. Thus hosting
ones housed in
desktop-style helps an organization or business to make their website
minitower cases, reachable via the World Wide Web. It basically provides the
but most hosts space, technology, and services that would be needed for
now require your website to be reachable. There are three main types of
rack mount web hosting viz. Shared hosting, VPS hosting, and Dedicated
enclosures and
standard system hosting. All three have different characteristics and have their
configurations. own advantages and disadvantages.
Domain names
Domain names are considered as the second name for
IP address. It is difficult to remember these number and
domain names are simpler to remember and understand. It
is important to get a domain name for the website and acts
as an address. For e.g. [Link]. You are sure it is
easy for you also to remember [Link] rather than
[Link]. One needs to purchase a domain name and
it ranges from being cheap to expensive depending on your
need. You can book your domain name from 1 to 10 years
or so. Before its expiry, make sure, you restore it again or
else your domain name will be publicly available.
DNS
DNS stands for Domain Name Server or Domain Name
System. This step is known to be the hardest of all. It basically
keeps a record of the information and is in charge of it i.e.
Your IP address and domain name. Many times the hosting
247
Basic Computer Coding: HTML
Hosting
Now that you have your IP address, the domain name in
place it is time to host it and make it reachable. In simple
words, hosting is when you pay a company to put your
website files on their web server. Your website’s files consist
of HTML files, images, videos, photos, etc. To put it all in
place, when your domain name is put on the web browser,
the DNS is connect it to the right computer/server and then
that particular computer has your website hosted on it.
Keyword
Domain
name is
7.1.3 How Domain Name Works
an identification
string that
A domain is the name of your website. Before you can create
defines a realm a website, you will need a domain. A domain name is not
of administrative something physical that you can touch or see; it is merely a
autonomy, string of characters that give your website an identity (yes,
authority or a name, like human and businesses). Now, here are some
control within quick examples: [Link] is a domain name; so are Alexa.
the Internet. com, [Link], [Link], as well as [Link].
To have your own domain, you will need to register your
domain with a domain registrar.
248
Web Hosting
domain (shortform: TLD). Examples of other TLD include .uk, .ws, .[Link], .[Link],
.tv, .edu, .co, .[Link], and .mobi. While most of these TLDs are open for public’s
registration, there are strict regulations on certain domain registration. For example
the registration of country code top level domains (like .[Link] for United Kingdom)
are restricted for the citizens of the corresponding country; and the activities with
such domains website are ruled by local regulations and cyber laws.
Certain extensions of these TLDs are used to describe the ‘characteristics’ of
the website – like .biz for businesses, .edu for education (schools, universities,
colleagues, etc.), .org for public organization, and country code top level domain
names are for locations.
249
Basic Computer Coding: HTML
Domain vs sub-domain
Take [Link] for example – [Link] is the domain,
[Link] in this case, is the sub domain.
A domain must be unique (for example there can only be
one single [Link]) and must be registered with a domain
registrar (i.e. NameCheap); while for sub domains, users can
freely add it on top of the existing domain as long as their
web host provide the service.
Some would say sub-domains are the ‘third level’ domains
in the sense that they are simply “sub folders” under the
domain root directory, normally used to organize your website
content in different languages or different categories.
Keyword However, this is not the case to many including the search
Primary engines – it is known fact that the search engines (namely,
domain is the Google) treat sub domain as a different domain independent
main address for from the primary domain.
your site. If you
only have one Terms of domain name
domain name
registered, then To quickly recap on what we have just learned: –
that will be your
primary domain.
Website Domain Name Subdomain TLD ccTLD
[Link] Yahoo – .com –
[Link] Yahoo mail .com –
[Link] Yahoo finance .com –
[Link] Yahoo – – .[Link]
250
Web Hosting
Remember
Dreamweaver
would ask before
updating all the
pages. And, any
changed pages
Web Hosting and Email Services would then have
to be uploaded to
The three basic parts that make up any current day the server.
website are:
■ Domain Names
■ Web-Hosting Servers
■ Site Files
Domain Names
Computers communicate by using numbers, called IP addresses,
to contact each other, much like you use a phone number to
dial a specific person’s phone. Domain names on the internet
are much like entries in a phone book. The phone book tells
people looking for a business what the entries are just as a
domain tells people (i.e. their computers) that a domain is
hosted on the server. Without a domain you would not be able
to use a domain name such as [Link], making your site
appear unprofessional and impractical if your visitors are able
to load it at all.
Web-Hosting Servers
The web-hosting or server is much like the space that you rent
out to have your business in. It is merely the space itself. It
does not include furnishings like shelves for your products,
just as the web-hosting account does not include a site for
you to sell your products. Luckily, in the web-hosting world,
it is very easy to furnish the space provided by your host,
because you can install many framework applications through
the QuickInstall icon within your cPanel. Without the hosting
services, you will not have a place for your files to reside, so
your domain would then become like a disconnected phone
number in the phone directory, and your site files would
have nowhere to stay.
251
Basic Computer Coding: HTML
Site Files
The site files are what your visitors and potential customers
actually see when going to site such as your products and
services. The site files are the same as any other file you
normally use, like a .jpg photograph, or .mp3 music file.
Keyword
Though, website files are also .php files or .html files, which
PHP is a
are PHP scripts or html pages respectively. The web-hosting
widely-
used open
server knows how to read these files, which explain how
source general- the webpage looks or instruct the server to do a series of
purpose scripting computations. These computations are things like figuring out
language that what blog article it is supposed to send back to the viewer,
is especially or what forum post it is supposed to send back.
suited for web
development and
can be embedded
7.1.5 Domain Name Registration Process
into HTML.
In order to reserve a domain name in a gTLD, a domain
name registrant must register it with an ICANN-accredited
registrar. The registrar will check if the domain name is
available and create a WHOIS record with the domain name
registrant’s information. It is also possible to register domain
names through a registrar’s resellers. The diagram below
illustrates the main functions of the parties that are usually
involved in the process.
A domain name registrant is the person or organization
who has registered the domain name. In order to do so, the
domain name registrant will usually apply online to a domain
registrar or one of their resellers. The domain name registrant
is bound by the terms and conditions of the registrar with
which it registers its domain name, for instance adhering
to a certain code of conduct or indemnifying the registrar
and registry against any legal or civil action taken as a
result of use of the domain name. Domain name registrants
have certain responsibilities that are incorporated into these
terms and conditions like payment of registration fees and
submission and timely update of accurate data.
In addition to registering the domain name, domain name
registrants also need to have their domain names listed on
name servers in order for that domain name to be reachable
on the Internet. A domain name registrant is responsible
for procuring or hosting his or her own name server if the
registrar does not offer this service or he or she has opted
out of the registrar’s service. In some cases, a person or
organization who does not wish to have their information
listed in WHOIS may contract with a proxy service provider
to register domain names on their behalf. In this case, the
252
Web Hosting
service provider is the domain name registrant, not the end customer.
Registrars are organizations accredited by ICANN and certified by the registries
to sell domain names. They are bound by the Registrar Accreditation Agreement
(RAA) with ICANN, and by their agreements with the registries. The RAA sets out
responsibilities for the registrar including maintenance of WHOIS data, submission
of data to registries, facilitating public WHOIS queries, ensuring domain name
registrants details are escrowed, and complying with RAA conditions relating to
the conclusion of the domain name registration period.
Some domain name registrants may opt to register through a reseller. These
organizations are affiliated or under contract with registrars, and usually offer other
services such as web hosting, email mailboxes etc. Resellers are bound by their
agreements with the registrar(s) whose services they sell; they are not accredited
by ICANN. However, the registrar for whom they are re-selling will still be the
sponsor for the domain name registration and accountable for the domain names
sold by the reseller.
While registrars are contracted to conduct the day-to-day business of selling
domain name registrations, registries are responsible for maintaining the registry for
each TLD. The responsibilities of the registries include accepting registration requests
(whether from registrars or directly from domain name registrants), maintaining
a database of the necessary domain name registration data and providing name
servers to publish the zone file data (i.e. information about the location of a domain
name) throughout the Internet. The Internet Corporation for Assigned Names and
Numbers (ICANN) is the non-profit organization that oversees the assignment
of both IP addresses and domain names. It has responsibility for managing root
server and TLD name system management and has contractual agreements with
both registries and registrars that provide the foundation for the WHOIS system.
253
Basic Computer Coding: HTML
Hierarchical Model
Keyword
Website
is a
collection of
related web
pages, including
multimedia These are possibly the most common types of website
content, typically structures. They start with a broad set of information (parent
identified with pages) that filters down into more detailed information (child
a common pages). Sometimes these structures are called trees, and they
domain name, are very similar to organizational charts in corporations.
and published on
at least one web
server. Sequential Model
These types of structures are exactly like they sound – they
lead site visitors through a sequence. Whereas a hierarchical
structure might lead site visitors down or across to another
parent page, sequential structures only lead visitor either
backward or forward from one step to another.
254
Web Hosting
Matrix Model
Although this structure may be nontraditional, in the early years of the internet,
it was quite popular. A matrix type structure lets site visitors choose where they
would like to go next. Instead of building a sequence, or limiting navigation with
parent/child relationships, this structure provides many links under topic groups
with those who land on the page choosing where they go next.
Database Model
This dynamic approach to website structuring integrates a database with search.
To build a site like this, you will need to think from the bottom up – carefully
tagging your content’s metadata based on information architecture principles. When
done correctly, this structure produces a site where visitors can create experiences
based on what they are looking for.
255
Basic Computer Coding: HTML
256
Web Hosting
Hierarchical
For most website users the hierarchical model works just
fine. For this structure, information is ranked and presented Keyword
in logical order. One reason most people appreciate this type Hub is
of organization is because it is currently the most popular the central
model online, making it easy to navigate simply because it part of a wheel
is familiar. Hierarchical structures are also easy to adjust to that connects the
fit many scenarios. You can go for a simple hub and spoke axle to the wheel
style or build more complex hierarchies with subheadings itself.
based on the intended uses and user. Simple hierarchies also
work great on mobile sites, where the options are limited to a
single page and a few links. The trick to choosing a structure
that will stand the test of time is creating one that is not
too shallow or deep. Too many (or too few) subheadings is
a bad thing.
Sequential
Sequential sites are often associated with educational sites,
and this is no surprise since this structure is based on the
style used by print publications. If you are presenting content
that teaches, naturally occurs in a logical order (such as
alphabetical), or is intended to be given chronologically, a
sequential structure is probably best. It should also go without
saying, that the intended audience is those looking to learn
a significant amount of information that is presented over
multiple pages.
257
Basic Computer Coding: HTML
258
Web Hosting
259
Basic Computer Coding: HTML
ROLE MODEL
VINTON CERF: AMERICAN COMPUTER
SCIENTIST
Vinton Cerf, in full Vinton Gray Cerf, (born June 23,
1943, New Haven, Connecticut, U.S.), American computer
scientist who is considered one of the founders, along
with Robert Kahn, of the Internet. In 2004 both Cerf and Kahn
won the A.M. Turing Award, the highest honor in computer
science, for their “pioneering work on internetworking,
including the design and implementation of the Internet’s
basic communications protocols, TCP/IP, and for inspired
leadership in networking.”
In 1965 Cerf received a bachelor ’s degree
in mathematics from Stanford University in California.
He then worked for IBM as a systems engineer before attending the University of
California at Los Angeles (UCLA), where he earned a master’s degree and then a
doctorate in computer science in 1970 and 1972, respectively. He then returned to
Stanford, where he joined the faculty in computer science and electrical engineering.
While at UCLA, Cerf worked under fellow student Stephen Crocker in the laboratory
of Leonard Kleinrock on the project to write the communication protocol (Network
Control Program [or Protocol]; NCP) for the ARPANET (Advanced Research Projects
Agency Network; see DARPA), the first computer network based on packet switching,
a heretofore untested technology. (In contrast to ordinary telephone communications,
in which a specific circuit must be dedicated to the transmission, packet switching
splits a message into “packets” that travel independently over many different
circuits.) UCLA was among the four original ARPANET nodes. Cerf also worked
on the software that measured and tested the performance of the ARPANET. While
working on the protocol, Cerf met Kahn, an electrical engineer who was then a
senior scientist at Bolt Beranek & Newman. Cerf’s professional relationship with
.Kahn was among the most important of his career
In 1972 Kahn moved to DARPA as a program manager in the Information
Processing Techniques Office (IPTO), where he began to envision a network of
packet-switching networks—essentially, what would become the Internet. In 1973
Kahn approached Cerf, then a professor at Stanford, to assist him in designing this
new network. Cerf and Kahn soon worked out a preliminary version of what they
called the ARPA Internet, the details of which they published as a joint paper in
1974. Cerf joined Kahn at IPTO in 1976 to manage the office’s networking projects.
Together, with many contributing colleagues sponsored by DARPA, they produced
TCP/IP (Transmission Control Protocol/Internet Protocol), an electronic transmission
protocol that separated packet error checking (TCP) from issues related to domains
and destinations (IP).
260
Web Hosting
261
Basic Computer Coding: HTML
SUMMARY
■ Web hosting is a method by which a person or company rents a server
to store data used to display a website, which is accessible through the
Internet.
■ Web hosting is an essential service for anyone that wants to set up a
website. Without a web host, you cannot share your website with any users.
It basically provides all of the services and technology that is required to
get your website onto the internet including storage space/servers.
■ Servers are powerful computers that have extremely large hard drives, or
an array of hard drives, which can be rented to those who want a website
on the Internet.
■ Shared hosting is one of the more common methods for website hosting.
It is also the cheapest, and least reliable. This is when several website
owners are sharing a single server including all resources such as CPU,
memory and drive space.
■ A Virtual Private Servers, or VPS, is a virtual machine running on top of a
real machine. Several VPS servers may run on a single real server machine.
■ The IP address is essential because there are many computers on the same
location that is called LAN (Local Area Network) and many LANs are
connected together that is called WAN (Wide Area Network), therefore,
each should have a unique identity.
■ Domain names are considered as the second name for IP address. It is
difficult to remember these number and domain names are simpler to
remember and understand. It is important to get a domain name for the
website and acts as an address.
■ DNS stands for Domain Name Server or Domain Name System. This
step is known to be the hardest of all. It basically keeps a record of the
information and is in charge of it i.e.
■ Computers communicate by using numbers, called IP addresses, to contact
each other, much like you use a phone number to dial a specific person’s
phone. Domain names on the internet are much like entries in a phone
book.
■ A website’s structure refers to how the website is set up, i.e. how the
individual subpages are linked to one another. It is particularly important
that crawlers can find all subpages quickly and easily when websites have
a large number of subpages.
262
Web Hosting
KNOWLEDGE CHECK
1. A service provider that manages the server used to host an organization
website and its connections to the Internet backbones is known as:
a. Client server
b. Internet service provider
c. Hosting provider
d. All of the above
2. The website for a company is hosted on a:
a. Web infrastructure
b. Web page
c. Web server
d. Web client
3. The website content of a company is accessed by an end-user through using:
a. Web client/server
b. Web server
c. Web e-mail
d. Web browser
4. A provider enabling home or business users access and web hosting services
for the Internet is referred to as:
a. Application service providers
b. Internet solutions providers
c. Internet service providers
d. Online solutions providers
5. The likelihood of a poor response from a website can be reduced through:
a. Selecting a dedicated server
b. Signing a service level agreement
c. Selecting high bandwidth connection
d Both the second and third answer above
6. The data storage space accessed via the Internet, usually used to host websites
and data files is called......................
a. Web server
b. Web page
c. Webmaster
d. Web space
7. The process of moving data from one storage device to another is .........................
a. Bandwidth
b. Migration
263
Basic Computer Coding: HTML
c. Server
d. Router
8. Web hosting based on type of servers are.
a. UNIX WINDOWS DOS
b. Dedicated Hosting Shared Hosting VPS Hosting
c. Web page Web site Web browser
d. Server Web server Webmaster
e. Web Hosting Email Hosting Script hosting
9. Web hosting service where more than one web site is hosted on the same
server.
a. VPS Hosting
b. Windows Hosting
c. Dedicated hosting
d. Shared hosting
10. An HTML/XHTML document that is available through the World Wide Web
and can be accessed through a web browser is called as .........................
a. Webmaster
b. Web server
c. Web page
d. Computer
e. Home page
11. Which of the following is NOT a common type of web hosting?
a. Shared hosting
b. Dedicated hosting
c. Virtual Reality hosting
d. Cloud hosting
12. What does the term “uptime” refer to in the context of web hosting?
a. The time it takes for a website to load
b. The percentage of time a server is operational and accessible
c. The duration of a website’s existence
d. The time it takes to transfer data between servers
13. What is the purpose of a domain name in web hosting?
a. To specify the programming language of a website
b. To define the layout and design of a website
c. To provide an easy-to-remember address for accessing a website
d. To determine the geographic location of a server
264
Web Hosting
14. What security feature is often used to encrypt data transmitted between a
user’s browser and a website?
a. SSL/TLS
b. VPN
c. Firewall
d. Antivirus
REVIEW QUESTIONS
1. What do you understand by web hosting?
2. Define the different types of web hosting services.
3. What is the difference between domains vs hosting vs website?
4. Describe the domain name registration process.
5. Write the four types of website structures.
6. Differentiate between web hosting and web publishing.
7. Explain the concept of a domain name server (DNS) in the context of web
hosting. How does it facilitate the connection between domain names and
IP addresses?
8. What is SSL/TLS, and why is it important for secure web hosting?
9. Discuss the role of backups in web hosting. Why is it crucial for website
owners to regularly back up their data?
265
Basic Computer Coding: HTML
REFERENCES
1. A History of Web Hosting [Infographic]. BizTech. 2012-02-24. Retrieved 2016-
11-04.
2. Buyya, Rajkumar; Yeo, Chee Shin; Venugopal, Srikumar (2008). “Market-
Oriented Cloud Computing: Vision, Hype, and Reality for Delivering IT
Services as Computing Utilities”. 2008 10th IEEE International Conference
on High Performance Computing and Communications. pp. 5–13.
3. Dawson, Christian. “Why Uptime Guarantees are Ridiculous”. Servint.
Retrieved 7 October 2014. a good SLA will clearly state how uptime is defined
and what you’ll receive if the “uptime promise” is not met.
4. Dawson, Christian. “Why Uptime Guarantees are Ridiculous”. Servint.
Retrieved 7 October 2014. a good SLA will clearly state how uptime is defined
and what you’ll receive if the “uptime promise” is not met.
5. InstantShift. “A Guide to Web Hosting Security Issues and Prevention”.
InstantShift - Web Designers and Developers Daily Resource. Retrieved
2016-10-31.
6. InstantShift. “A Guide to Web Hosting Security Issues and Prevention”.
InstantShift - Web Designers and Developers Daily Resource. Retrieved
2016-10-31.
7. Intark Han; Hong-Shik Park; Youn-Kwae Jeong; Kwang-Roh Park (2006). “An
integrated home server for communication, broadcast reception, and home
automation”. IEEE Transactions on Consumer Electronics. 52: 104–109.
8. Schultz, Eugene (2003). “Attackers hit Web hosting servers”. Computers &
Security. 22 (4): 273–283.
9. Vanvleet, Derek. “Google Apps vs. Office 365: What Does 99.9% Uptime
Really Mean?”. Cloud Sherpas. Retrieved 7 October 2014.
10. Ward, Mark (3 August 2006). “How the web went world wide”. BBC News.
Retrieved 24 January 2011.
266
CHAPTER 8
JAVASCRIPT
AND EXTERNAL
CONTENT
LEARNING OBJECTIVES
Here’s the syntax for an entire page with the 200 × 200
canvas inside:
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv=”Content-Type” content=”text/html;
charset=utf-8”>
<title>Canvas</title>
</head>
<body>
<canvas width=”200” height=”200”></canvas>
</body>
</html>
This HTML creates a canvas on the page that is ready
for content. But wait! What advantage does a canvas element
provide on a page? How do you make a cool animated clock Did You
or menu or other widget? Alas, therein lies the problem. When Know?
simply included in a page like the one shown, a tag doesn’t JavaScript
do anything. In fact, it’s just blank; go ahead and load that is the dominant
code into a canvas-compatible browser. client-side
scripting
So, how might you get the canvas to do something? The language of the
answer lies in the programming language that all modern Web, with 97% of
browsers understand: JavaScript. You bring the canvas element websites using it
for this purpose.
to life with JavaScript; everything within the canvas is drawn,
animated, and destroyed with JavaScript. You might not
know much, if anything, about JavaScript. After learning a bit
about JavaScript you’ll be able to make the canvas element
do some fun and interesting things!
269
Basic Computer Coding: HTML
8.2.2 Syntax
JavaScript can be implemented using JavaScript statements that are placed within
the <script>... </script> HTML tags in a web page.
You can place the <script> tags, containing your JavaScript, anywhere within
you web page, but it is normally recommended that you should keep it within
the <head> tags.
The <script> tag alerts the browser program to start interpreting all the text
between these tags as a script. A simple syntax of your JavaScript will appear as
follows.
<script ...>
JavaScript code
</script>
270
JavaScript and External Content
271
Basic Computer Coding: HTML
SET UP
1. In Notepad, type the following:
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8”>
<title>JavaScript 101</title>
</head>
<body>
<div id=”contentDiv”>Your first JavaScript page.</div>
</body>
</html>
2. Add some JavaScript to the page, placing it just before the closing
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8”>
<title>JavaScript 101</title>
</head>
272
JavaScript and External Content
<body>
<div id=”contentDiv”>Your first JavaScript page.</div>
<script type=”text/javascript”>
alert(“hello world”);
</script>
</body>
</html>
3. Save the file in Notepad as [Link].
4. View the page within a Web browser. You should receive
an alert such as this:
Keyword
Dialog
box (also
spelled dialogue
box, also called
a dialog) is a
common type
of window
in the GUI of
SET UP an operating
system.
1. Delete the following line from the code:
alert(“hello world”);
2. Between the <script> and </script> tags, place the following:
<script type=”text/javascript”>
var divContent = document.
getElementById(“contentDiv”);
[Link] = “#abacab”;
</script>
3. Save your work in Notepad.
4. Open the file in Internet Explorer to test it. Instead of a Hello
World dialog box, the text on the page appears with a gray
background:
273
Basic Computer Coding: HTML
274
JavaScript and External Content
It’s also possible to use jQuery hosted on a Content Delivery Network (CDN).
With the CDN-based jQuery, you can simply point the <script> tag toward the URL
of the library on the external CDN. Doing so looks like this:
<script type=”text/javascript”
src=”[Link]
However, as just noted, it’s recommended to host the file yourself for production
purposes on live sites rather than relying on the CDN. There’s nothing worse than
having your Web site up and operational but reliant on a CDN-based library Web
site that is down. It’s perfectly acceptable to use the CDN based version rather
than downloading jQuery yourself.
275
Basic Computer Coding: HTML
</body>
</html>
When viewed in a browser, you’ll receive an alert like this:
The code shown above includes the jQuery library, and then it uses both the
.ready() function and some other JavaScript to show an alert. This is an important
point about jQuery: you use it to help write JavaScript. jQuery is not JavaScript;
instead, it’s a tool that you use to help perform common JavaScript tasks and
sometimes to simplify tasks that are difficult to perform using JavaScript alone.
You’ve now seen how to get jQuery, how to include it in a Web page, and
how to run JavaScript code with the help of jQuery’s .ready() function. The next
item on the agenda is selecting elements.
276
JavaScript and External Content
<html>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8”>
<title>jQuery 101</title>
<script type=”text/javascript” src=”[Link]”></script>
</head>
<body>
<div id=”contentDiv”>Your second JavaScript page.</div>
<script type=”text/javascript”>
$(“#contentDiv”).css(“backgroundColor”, “#abacab”);
$(“#contentDiv”).fadeOut();
</script>
</body>
</html>
Viewing this page in a browser will result in the contentDiv fading out after a
certain default (and short) time period. If you find that time period too short, you
can specify the duration, as well. Time is measured in milliseconds for this (and
most other) functions in jQuery, so every second is 1000 milliseconds. Therefore,
to set the fade-out duration to 5 seconds, you would write:
$(“#contentDiv”).fadeOut(5000);
You’ve now seen how to download jQuery, connect it to your page, and use it to
select elements. And you just looked at a bonus example of a built-in function in jQuery
called .fadeOut(). This leads to a more generalized discussion of functions in jQuery
and Java Script.
277
Basic Computer Coding: HTML
278
JavaScript and External Content
Document Object Model (DOM) to try to get the correct code to execute at the
correct time.
jQuery includes several event-related functions such as .click() for responding
to mouse clicks, .submit() for responding to a form submission, .hover() to respond
when a mouse cursor hovers over an element, and several others. In fact, the
.ready() function that you saw earlier is an event handler.
You saw the .fadeOut() function in use. That function ran when the page loaded
(or more accurately, when the browser encountered the JavaScript). To make the
element fade out when a user clicks it with the mouse, you need to attach a
click event handler to that
element. In jQuery, you do this with the help of the .click() function, which
looks like the following example (I’ve highlighted the relevant code in bold):
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8”>
<title>jQuery 101</title>
<script type=”text/javascript” src=”[Link]”></script>
</head>
<body>
<div id=”contentDiv”>Your second JavaScript page.</div>
<script type=”text/javascript”>
$(“#contentDiv”).css(“backgroundColor”, “#abacab”);
$(“#contentDiv”).click(function() {
$(this).fadeOut(5000);
});
</script>
</body>
</html>
Note that the .click() function is attached directly to the <div> that has the id
of contentDiv. The .click() function itself calls another function (an anonymous
function, enclosed in curly brackets) which calls the .fadeOut() function. You’ll
notice that there’s a new part here, the $(this) identifier. The $(this) identifier refers
to the item that raised the event, so in the example shown, $(this) refers to the
contentDiv element. You could also write it like this:
$(“#contentDiv”).click(function() {
$(“#contentDiv”).fadeOut(5000);
279
Basic Computer Coding: HTML
});
When you load this page in a Web browser you’ll see a screen like the one
shown below. When you click within the <div> element, the entire <div> will
slowly fade out.
280
JavaScript and External Content
} else {
alert(“Form not correct”);
return false;
}
});
</script>
</body>
</html>
The code introduces a few new concepts, namely the if conditional. The code
uses the if conditional to test whether the value entered by the user matches what
you’re expecting from the text field on the form. The jQuery .val() function in the
preceding code is also new here. The .val() function obtains the value of whatever
has been entered into the text box (or whatever element has been selected). Finally,
when the text box is not filled in correctly, there’s a return false; statement. In this
context, return false; indicates that processing of the Web form should not continue,
and the form should not be submitted.
When submitted with a value of Yes in the text box, the code displays an alert
and continues with form submission. If the user enters anything else and submits
the form, the validation code displays an alert indicating that the form wasn’t
filled in correctly, and halts form submission to the server by returning false. A
more complex yet more user-friendly approach for handling errors is to change
the background color on the form field that was filled in incorrectly. Obviously,
for the one field form in this example, it’s clear which field is incorrect. But on
a more complex form, it may not be as obvious which field contains an incorrect
value. Here’s the code to change the background color:
$(“#myForm”).submit(function() {
if ($(“#firstName”).val() == “Yes”) {
alert(“Form entered correctly”);
} else {
$(“#firstName”).css(“backgroundColor”,”red”);
return false;
}
});
This code changes the backgroundColor of the form element identified by the
id first Name to red when filled in incorrectly. However, best practice dictates not
changing CSS style information within JavaScript code. It’s much better to add
and remove CSS styles from elements. Doing so makes troubleshooting easier and
results in cleaner code all around.
The CSS style might look like this:
281
Basic Computer Coding: HTML
.errorField {
background-color: red;
}
Then within the code, rather than changing the actual CSS background color,
I’ll apply the error class with the help of the .addClass() function, as shown in
the following:
$(“#firstName”).addClass(“errorClass”);
The full page, including JavaScript code and CSS style information, is shown
in the following code:
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8”>
<title>jQuery 101</title>
<script type=”text/javascript” src=”[Link]”></script>
<style type=”text/css”>
.errorClass {
background-color: red;
}
</style>
</head>
<body>
<form id=”myForm” name=”myForm” action=”#” method=”post”>
<p>Answer: <input id=”firstName” type=”text” name=”firstname”></p>
<p><input type=”submit” name=”formSubmit” value=”Check Form”></p>
</form>
<script type=”text/javascript”>
$(document).ready(function() {
$(“#myForm”).submit(function() {
if ($(“#firstName”).val() == “Yes”) {
$(“#firstName”).removeClass(“errorClass”);
alert(“Form entered correctly”);
} else {
$(“#firstName”).addClass(“errorClass”);
return false;
}
282
JavaScript and External Content
});
}); //end document ready function
</script>
</body>
</html>
Notice that the JavaScript code is wrapped within the .ready() function. While
this is not strictly necessary here, I wanted to illustrate how you can use .ready().
Also, you’ll note that upon form submission, the code uses the .removeClass()
function to remove the errorClass class from the form element. In practice, you
could move that .removeClass()call to any number of other places in the code,
including within the main .ready() function call, or within the .submit() function.
There is much, much more to error handling, jQuery, but with this basic
knowledge in hand, you can now explore why the HTML5 <canvas> tag is so
important.
Browsers that don’t understand the <canvas> tag will ignore it and display the
contents of the HTML found within it; in this case, a <p> tag.
To draw on the canvas you need to specify the coordinates at which you’d
like to begin. Canvas coordinates use a grid system, like the one shown in the
following image:
283
Basic Computer Coding: HTML
In the grid shown above, the coordinates 0,0 represent the top-most and left-
most cell in the grid and the numbers increase as you move both to the right and
down. The cells themselves represent pixels on the screen. The points along the
horizontal axis on the grid are called x coordinates while points along the vertical
axis are called y coordinates. You draw using combinations of lines and primitive
shapes. For example, you can create rectangles of various forms using functions
such as fillRect to draw a filled-in rectangle and strokeRect to draw an outlined
rectangle. Both of these functions accept x and y coordinates to determine where
they should begin drawing, along with a width and height specification. The code
to draw a 50 × 100-pixel rectangle beginning at x coordinate 10 and y coordinate
20 looks like this:
fillRect(10,20,50,100)
Before you start drawing though, you need a canvas. Additionally, you need
to call the getContext() function for the canvas as well. You’ll see examples of how
to do this in the following code example, which shows an entire page that uses
the tag to draw this rectangle.
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv=”Content-Type” content=”text/html; charset=utf-8”>
<title>Canvas</title>
<script type=”text/javascript”
src=”[Link]
</head>
<body>
<canvas width=”250” height=”250” id=”myCanvas”>
<p>Alternate content goes here</p>
</canvas>
<script type=”text/javascript”>
$(document).ready(function() {
var canvas = [Link](“myCanvas”);
284
JavaScript and External Content
if ([Link]) {
var canvasContext = [Link](“2d”);
[Link] = “blue”;
[Link](10,20,50,100);
} else {
// You could do something else here
// because the browser doesn’t support Keyword
// the canvas element. Mozilla
Firefox or
}
simply Firefox,
}); is a cross-
</script> platform, free
and open-source
</body> web browser
</html> developed by
the Mozilla
Foundation and
This code creates a element (and provides alternative its subsidiary,
content for non-HTML5 browsers). The bulk of the page the Mozilla
consists of the JavaScript code to draw the rectangle, as Corporation.
shown here:
var canvas = [Link](“myCanvas”);
if ([Link]) {
var canvasContext = [Link](“2d”);
[Link] = “blue”;
[Link](10,20,50,100);
} else {
// You could do something else here
// because the browser doesn’t support
// the canvas element.
}
This code retrieves the element with the id myCanvas, and
places that into a JavaScript variable called canvas. Next, the code
tests to see if the getContext() function is available. If this function
isn’t available, then the browser almost certainly doesn’t support the
<canvas> element. Therefore, attempting to use getContext() would
result in a JavaScript error. If, however, the getContext() function is
available, then the code continues by calling getContext(), setting
the fillStyle to blue, and drawing the rectangle.
Viewing this page in a -compatible browser such as
Mozilla Firefox results in a page with a blue rectangle, like
the one shown here:
285
Basic Computer Coding: HTML
286
JavaScript and External Content
287
Basic Computer Coding: HTML
288
JavaScript and External Content
The code in the example will dynamically change the grid to match the number
of blocks you specify by setting the numBlocks variable.
289
Basic Computer Coding: HTML
ROLE MODEL
BRENDAN EICH
Brendan Eich (/ˈaɪk/; born July 4, 1961) is an American
computer programmer and technology executive. He
created the JavaScript programming language and co-
founded the Mozilla project, the Mozilla Foundation,
and the Mozilla Corporation. He served as the Mozilla
Corporation’s chief technical officer before he was
appointed chief executive officer, but resigned shortly
after his appointment due to controversy over his opposition to same-sex marriage.
He subsequently became the CEO of Brave Software.
Early Life
Eich grew up in Pittsburgh; Gaithersburg, Maryland; and Palo Alto, and he
attended Ellwood P. Cubberley High School, graduating in the class of 1979. He
received his bachelor’s degree in mathematics and computer science at Santa Clara
University, and he received his master’s degree in 1985 from the University of
Illinois at Urbana–Champaign. Eich is Roman Catholic.
He began his career at Silicon Graphics, working for seven years on operating
system and network code. He then worked for three years at MicroUnity Systems
Engineering writing microkernel and DSP code.
290
JavaScript and External Content
Mozilla
In early 1998, Eich co-founded the free and open source software
project Mozilla with Jamie Zawinski and others, creating the [Link] website,
which was meant to manage open-source contributions to the Netscape source
code. He served as Mozilla›s chief architect. AOL bought Netscape in 1999. After
AOL shut down the Netscape browser unit in July 2003, Eich helped spin out
the Mozilla Foundation.
In August 2005, after serving as a lead technologist and as a member of the board
of directors of the Mozilla Foundation, Eich became chief technical officer (CTO)
of the newly founded Mozilla Corporation, meant to be the Mozilla Foundation’s
for-profit arm. Eich continued to “own” the Mozilla SpiderMonkey module, its
JavaScript engine, until he passed on the ownership of it to Dave Mandolin in 2011.
Brave Software
Eich is the CEO of Brave Software, an Internet browser platform company that
raised $2.5 million in early funding from angel investors. In January 2016, the
company released developer versions of its open-source, Chromium-based Brave
web browser, which blocks ads and trackers.
291
Basic Computer Coding: HTML
292
JavaScript and External Content
SUMMARY
■ JavaScript is a text-based programming language used both on the client-
side and server-side that allows you to make web pages interactive. Where
HTML and CSS are languages that give structure and style to web pages,
JavaScript gives web pages interactive elements that engage a user.
■ The canvas element enables advanced graphics and interactions in ways
that previously you could only achieve by using slow, plug-in–laden
pages. The canvas element is a free-form area where you can use images,
drawn graphics, animation, and text to enhance the user experience on
a Web page.
■ JavaScript is not Java; it bears no relation to the Java programming language,
the drink, or the country. JavaScript is a programming language that is
used primarily to provide additional functionality to Web pages and
applications, and it’s used heavily in the “Web 2.0” paradigm of highly
interactive Web sites.
■ Client-side JavaScript is the most common form of the language. The script
should be included in or referenced by an HTML document for the code
to be interpreted by the browser. It means that a web page need not be a
static HTML, but can include programs that interact with the user, control
the browser, and dynamically create HTML content.
■ JavaScript can be implemented using JavaScript statements that are placed
within the <script>... </script> HTML tags in a web page.
■ jQuery is an open source JavaScript file that not only removes the need
for developers to handle many of the cross-browser incompatibilities but
also simplifies much more advanced programming than would normally
be available to novice JavaScript programmers.
■ jQuery provides several other ways to select elements, including hierarchical
functions by which you can select the children of an element; a way to
select every other element except a specified element; an element’s parent
elements; and many other selectors.
293
Basic Computer Coding: HTML
KNOWLEDGE CHECK
1. Which type of JavaScript language is ……………..
a. Object-Oriented
b. Object-Based
c. Assembly-language
d. High-level
2. Which of the following is the correct output for the following JavaScript
code:
varx=5,y=1
var obj ={ x:10}
with(obj)
{
alert(y)
}
a. 1
b. Error
c. 10
d. 5
3. Which one of the following also known as Conditional Expression:
a. Alternative to if-else
b. Switch statement
c. If-then-else statement
d. immediate if
4. In JavaScript, what is a block of statement?
a. Conditional block
b. block that combines a number of statements into a single compound
statement
c. both conditional block and a single statement
d. block that contains a single statement
5. What will happen, if the following JavaScript code is executed?
var count =0;
while (count <10)
{
[Link](count);
count++;
}
294
JavaScript and External Content
a. An error is displayed
b. An exception is thrown
c. The values of count variable are logged or stored in a particular location
or storage
d. The value of count from 0 to 9 is displayed in the console
6. Which one of the following is the correct way for calling the JavaScript
code?
a. Preprocessor
b. Triggering Event
c. RMI
d. Function/Method
7. Which of the following is not JavaScript Data Types?
a. Undefined
b. Number
c. Boolean
d. Float
8. Inside which HTML element do we put the JavaScript?
a. <script>
b. <head>
c. <meta>
d. <style>
9. Which of the following is correct about features of JavaScript?
a. It can not Handling dates and time.
b. JavaScript is a object-based scripting language.
c. JavaScript is not interpreter based scripting language.
d. All of the above
10. Choose the correct JavaScript syntax to change the content of the following
HTML code.
a. [Link] (“letsfindcourse”).innerHTML = “I am a letsfindcourse”;
b. [Link] (“letsfindcourse”).innerHTML = “I am a
letsfindcourse”;
c. [Link] (“letsfindcourse”) = “I am a letsfindcourse”;
d. [Link] (“letsfindcourse”).innerHTML = I am a
letsfindcourse;
11. Which JavaScript function is commonly used to make asynchronous requests
to a server and update a webpage without a full page reload?
a. fetch()
b. update()
295
Basic Computer Coding: HTML
c. ajax()
d. reload()
12. What does the acronym “API” stand for in the context of web development?
a. Advanced Programming Interface
b. Application Programming Interface
c. Advanced Protocol Integration
d. Application Protocol Interface
13. Which JavaScript method is commonly used to access an HTML element by
its ID?
a. getElementByTag()
b. selectElement()
c. querySelector()
d. getElementById()
14. In the context of JavaScript, what is the DOM?
a. Document Object Model - a programming interface for web documents
b. Dynamic Ordering Mechanism - a method for arranging webpage elements
c. Data Object Model - a structure for storing JavaScript variables
d. Document Overlay Model - a technique for applying styles to HTML
documents
REVIEW QUESTIONS
1. What is JavaScript?
2. What are the different data types present in javascript?
3. What is DOM?
4. What are the jQuery functions used to provide effects?
5. What is the difference between javascript and jquery?
6. Describe the purpose of the XMLHttpRequest object in JavaScript. How
does it facilitate communication with servers to fetch external content?
7. Explain the Same-Origin Policy in the context of JavaScript. How does it
impact the ability to make requests to external domains?
296
JavaScript and External Content
REFERENCES
1. Baker, Loren (November 24, 2004). “Mozilla Firefox Internet Browser Market
Share Gains to 7.4%”. Search Engine Journal. Archived from the original on
May 7, 2021. Retrieved May 8, 2021.
2. Brendan Eich: An Introduction to JavaScript, JSConf 2010. p. 22m. Archived
from the original on August 29, 2020. Retrieved November 25, 2019. Eich:
“function”, eight letters, I was influenced by AWK.
3. Champeon, Steve (April 6, 2001). “JavaScript, How Did We Get Here?”. oreilly.
com. Archived from the original on July 19, 2016. Retrieved July 16, 2016.
4. Eich, Brendan (April 3, 2008). “Popularity”. Archived from the original on
July 3, 2011. Retrieved January 19, 2012.
5. Enzer, Larry (August 31, 2018). “The Evolution of the Web Browsers”.
Monmouth Web Developers. Archived from the original on August 31, 2018.
Retrieved August 31, 2018.
6. Flanagan, David. JavaScript: The Definitive Guide. 7th edition. Sebastopol,
California: O’Reilly, 2020.
7. Jean-Pharuns, Alix (July 30, 2015). “[Link] Is the Most Ingenious Hack
I’ve Ever Seen”. Motherboard. Vice. Archived from the original on January
27, 2018. Retrieved January 26, 2018.
8. McCracken, Harry (September 16, 2010). “The Unwelcome Return of “Best
Viewed with Internet Explorer””. [Link]. Archived from the
original on June 23, 2018. Retrieved July 16, 2016.
9. Mozilla Foundation, Mozilla Foundation Security Advisory 2005–41: Privilege
escalation via DOM property overrides Archived 2014-06-04 at the Wayback
Machine
10. Purdy, Kevin (June 11, 2009). “Lifehacker Speed Tests: Safari 4, Chrome 2”.
Lifehacker. Archived from the original on April 14, 2021. Retrieved May 8,
2021.
11. Server-Side JavaScript Guide. Oracle Corporation. December 11, 1998. Archived
from the original on March 11, 2021. Retrieved May 8, 2021.
12. Usage statistics of JavaScript as client-side programming language on websites.
[Link]. Archived from the original on 2021-08-13. Retrieved 2021-04-09.
297
CHAPTER 9
IMAGE AND
MULTIMEDIA
LEARNING OBJECTIVES
height provide control over the image display and enhance accessibility for users
with different needs.
Multimedia elements, which encompass audio and video content, are integrated
using the <audio> and <video> tags. These tags support a variety of file formats
and enable the inclusion of music, sound effects, and video clips directly within the
web page. Attributes like controls, autoplay, and loop offer customization options,
enhancing the user experience.
HTML supports embedding external multimedia content through iframes,
enabling seamless integration of content from platforms like YouTube or Vimeo.
This is achieved using the <iframe> tag, providing a window into the rich world
of multimedia available on the internet.
In the context of accessibility and user experience, providing descriptive
text through the alt attribute for images and utilizing captions for multimedia
content becomes crucial. These practices ensure that users with visual or auditory
impairments can still comprehend the essence of the content.
As technology continues to advance, HTML remains at the forefront of facilitating
a dynamic and visually captivating web experience. Understanding how to effectively
utilize image and multimedia elements not only enhances the aesthetic appeal of
a website but also contributes to creating a more immersive and inclusive online
environment.
When you use the img tag, you’re telling the browser to display the image right
within the web page, as shown in Figure 1. In doing so, remember the following
few things:
■ Your image should be in a web-friendly file format, such as GIF, JPEG,
or PNG.
■ The value of your src attribute should include the correct pathname and
location of your file. So, if the image you want to use is not located in
the same folder as the HTML page you’re working on, you need to tell
300
Image and Multimedia
the browser in which folder that image is located. For example, if you
want to include an image located one directory higher than the current
directory, you would use src=”../[Link]”, where the ../ tells the browser
to go up one directory before looking for the image file. If you want to
reference an image from another web site, you could use src=”[Link]
[Link]/images/ [Link]”, where the URL is the full name of
the image location on the other site.
■ In general, each image should serve a unique purpose and add something
to your web page. Because visitors have to wait while images download
to their computers, it’s wise not to bog down your page with gratuitous
graphics that serve little or no purpose.
Figure 1. By default, the browser displays the image within the web page wherever you
type the img tag. In this case, the image was the only content on the page, so it was placed
at the top of the page.
Stock Photography
The use of photography can often add a sense of professionalism
to a business web site, but many businesses don’t have the
budget to hire photographers to do private photo shoots for
them. If you’re in this predicament, have no fear. Plenty of
stock photography houses offer royalty-free photography to
be used for almost any purpose, except for resale. You can
purchase entire CDs of photographs with a particular theme
at your local computer or office supply store. These CDs
range in cost from $40 to $500, depending on the quality of
the work and the type of license you’re given.
You can also search online and purchase the right to use
an individual photograph. The costs vary according to how
you plan to use it. For example, if you want to purchase the
right to use a photo only on your web site, you can expect
to pay a minimal fee of as low as a few dollars (especially
on sites like [Link]). If, however, you want to use
the same image in all your printed publications, as well as
in any digital presentations, the fees typically start around
$100 and go up from there.
You might also check the software licenses that came
with your favorite graphics or presentation program. For
instance, registered owners of Microsoft Office have access to
Microsoft’s free image gallery at [Link]
clipart. When using any stock photography, be sure to read
302
Image and Multimedia
the terms of use and license carefully. While you may find free stock photography,
it’s often restricted only to noncommercial use. For more links, visit my web site:
[Link].
Clipart
Whenever you need a stock button, cartoon, line drawing, illustration, or other
graphic, you might try searching through some clipart libraries. You can find CDs
filled with various types of clipart at your local computer or office supply store
for $10–$150. (The cost typically depends on the quantity of graphics you receive.)
Probably thousands of online clipart galleries exist where you can search for the
type of graphic you want. Many artists publish their clipart on the Internet and
offer it free for personal use. License fees for commercial use of this clipart are
usually affordable but vary greatly according to the artist.
As with stock photography, you may receive some clipart free with the purchase
of another software program. For instance, registered owners of Microsoft Office
have access to Microsoft’s free clipart gallery: [Link]
For lists of online sources for stock photography and clipart, visit my web site:
[Link].
If you don’t know the size of your image, you can open it in a graphics editor,
such as Adobe Photoshop or Fireworks, to find out. Or you can use the browser
to determine the size of your images.
● In Firefox/Mozilla for the Mac and PC, as well as in Safari for the Mac
First, load the image by itself into the browser window (choose File |
Open or File | Open Page and locate the image file on your computer).
Then, look at the top of the browser window where the title is usually
displayed. When you view an image file, these browsers print the width
and height of the image (in that order) in the title.
303
Basic Computer Coding: HTML
If you were given an image that was 50 pixels high by 60 pixels wide,
you could change that size by specifying a different size in the HTML
(such as 50 pixels wide by 50 pixels high). This causes the browser to
attempt to redraw the image at the newly specified size.
304
Image and Multimedia
Figure 2. This screen shows how the browser displays the alternative text if it cannot find
the image. Without that alternative text, viewers wouldn’t have any idea what they were
supposed to see.
The good news is you can do something to help visitors to your site understand
the content of your images, even if they can’t see them. You can use the alt attribute
of the img tag to provide alternative text for an image.
<img src=”[Link]” width=”600” height=”412” alt=”Drawing of a Turtle” />
305
Basic Computer Coding: HTML
306
Image and Multimedia
As with any other linked elements in a web page, the visitor’s pointer turns
to a hand when she moves her mouse over the linked image (refer to Figures 3
and 4 for examples).
Figure 4. As an alternative, a text label has been added in this example to help users
understand where the link will take them.
So, looking back at the drawing of a turtle, an image map could be used to link
the eyes to one web page and the shell to a different one. Another example of an
image map is a picture of the United States, where each state could be designated
as a hot spot, with its own link.
307
Basic Computer Coding: HTML
310
Image and Multimedia
■ Background images should be small in file size. This avoids a long download
time. Take advantage of the fact that the browser repeats a background
image and cut your image down as much as possible.
To help clarify these points, look at Figure 5. If I told you the darker bar at
the top, as well as the word “Corinna” and the stars, are all in the background,
could you imagine what the background image itself looks like when it isn’t tiled?
Figure 6 gives the answer.
Figure 5. Here, a background image enables me to achieve a layered look because the
photo in the foreground lies over the top of the image in the background.
Figure 6. Before the image was tiled by the browser in Figure 5, it looked like this.
311
Basic Computer Coding: HTML
Because the original image was only 400 pixels tall, the browser was forced to
repeat it when the window was opened larger in Figure 7. To compensate for this,
I could add additional space to my image, making it long enough to avoid tiling
vertically. Testing your pages on different screen sizes is important to ensure your
background images are repeating as you expect. See Figure 8 for another example.
Another way to force the background image to remain stationary is to add the
background attachment property to the page’s style sheet. This property allows
the background to stay in place (when set to “fixed”) or to move when the page is
scrolled (when set to “scroll”). Similarly, you can even tell the browser whether or
not to repeat your background image at all, using the background-repeat property.
body {background-image: url(“[Link]”);
background-attachment: fixed;
background-repeat: no-repeat;}
Figure 7. The size of the original image (100 wide by 400 tall) is outlined here. Because
the image is shorter than the browser window, it repeats first to the right and then down.
Possible values of the background-repeat property are
■ repeat Specifies the file should repeat both horizontally and vertically
(which is the default)
■ repeat-x Specifies the file should repeat horizontally only
■ repeat-y Specifies the file should repeat vertically only
■ no-repeat Specifies the file should not repeat
312
Image and Multimedia
Keyword
XML
file is a file used
to store data
in the form of
hierarchical
elements. Data
stored in XML
files can be read
by computer
programs with
the help of
custom tags,
which indicate
the type of
element.
Figure 8. Here, I added 600 pixels to the height of the image,
making it 1,000 pixels high. This helps to ensure that visitors won’t
see the darker bar and “Corinna” again on this page.
313
Basic Computer Coding: HTML
Sound Formats
MP3 is the newest format for compressed recorded music. The term MP3 has
become synonymous with digital music. If your website is about recorded music,
MP3 is the choice.
314
Image and Multimedia
they might use to open your files. You could also provide a link to download the
appropriate plug-in.
For example, Flash, a file type requiring a plug-in, has become so popular that
it ships with most current browsers. Even so, you might have visited a web site
and noticed a window pop-up saying something about “downloading the Flash
player.” Flash files are popular because they’re small (which translates as “quick-
to-download!”) and can include sound, video, interactivity, and animation. Another
reason Flash is so popular is that the plug-in used to display Flash files is widely
available on a large variety of platforms and browsers.
Clicking the link shown in Figure 9 would cause one of three things to happen,
depending on how the system was set up.
■ It may prompt the user to download the file and either view it now or
save it for later (see Figure 10)
Figure 9. A link to a multimedia file is the same as any other link because it also uses the
a tag and the href attribute.
316
Image and Multimedia
Figure 10. When the browser doesn’t recognize a file type as one it should “play” within
the browser, it may prompt the user to download the file.
■ If the browser recognizes the file as one it is set up to display automatically,
it may take over and do just that (see Figure 11).
Figure 11. When the link is clicked, the browser may be able to play the video itself if the
appropriate plug-in or ActiveX control is installed.
Knowing that many systems may handle your multimedia files differently, try
to offer your visitors as much guidance and instruction as possible. For example,
list the size of the file you’re asking them to download, so they can consider
whether they want to wait for it to load to their system. In addition, provide
alternative ways of getting the information, and include it within the multimedia
files wherever possible.
317
Basic Computer Coding: HTML
318
Image and Multimedia
319
Basic Computer Coding: HTML
320
Image and Multimedia
The object tag can contain other HTML tags and attributes, including other
object tags. If the browser is capable of interpreting an object tag, it does so and
ignores the HTML contained within the opening and closing object tags. If it doesn’t
understand the object tag, it uses the HTML included in it instead. The benefit of
this is that you can offer a plug-in-free alternative to visitors who may not have
or want to use the plug-in. This might be accomplished with code similar to the
following:
<object type=”application/x-shockwave-flash” data=”[Link]”>
<param name=”height” value=”60” />
<param name=”width”” value=”200” />
<param name=”movie” value=”[Link]” />
<param name=”bgcolor” value=”#ffffff” />
<param name=”loop” value=”false” />
<a href=”[Link] title=”You
must install Flash to access this movie.”><img src=”[Link]”
width=”200” height=”60” alt=”Screen shot of movie - need Flash to
view” /></a>
</object>
321
Basic Computer Coding: HTML
322
Image and Multimedia
SUMMARY
■ Images, a cornerstone of web design, are incorporated using the <img>
tag. This tag allows developers to embed images directly into the HTML
document, enriching the visual appeal of the content. Attributes such as src
(source), alt (alternative text), and width and height provide control over
the image display and enhance accessibility for users with different needs.
■ Multimedia elements, which encompass audio and video content, are
integrated using the <audio> and <video> tags. These tags support a variety
of file formats and enable the inclusion of music, sound effects, and video
clips directly within the web page. Attributes like controls, autoplay, and
loop offer customization options, enhancing the user experience.
■ The use of photography can often add a sense of professionalism to a
business web site, but many businesses don’t have the budget to hire
photographers to do private photo shoots for them. If you’re in this
predicament, have no fear.
■ In Firefox/Mozilla for the Mac and PC, as well as in Safari for the Mac
First, load the image by itself into the browser window (choose File |
Open or File | Open Page and locate the image file on your computer).
■ In Internet Explorer Load the image into the browser window (choose File
| Open and locate the image file on your computer, or drag it from the
desktop into an open browser window). Then, right-click the image and
choose Properties. The size is displayed as dimensions (width × height).
■ The old HTML specifications enabled you to add a single image to be
used as the “scenery” in the background of your web page. This was
accomplished using the background attribute of the body tag, as in <body
background=”[Link]”>.
■ A link to a multimedia file is essentially the same as any other link. While
embedding a file can sometimes be problematic, a link to a file can be
especially useful because links are understood by all web browsers.
323
Basic Computer Coding: HTML
KNOWLEDGE CHECK
1. What HTML tag is used to embed images?
a. <img>
b. <picture>
c. <image>
d. <imgsrc>
2. Which attribute is used to specify the source (URL) of an image in HTML?
a. source
b. url
c. src
d. link
3. What is the purpose of the alt attribute in the <img> tag?
a. Image color
b. Image size
c. Image alternative text
d. Image alignment
4. Which HTML tag is used for embedding audio content?
a. <audio>
b. <sound>
c. <music>
d. <media>
5. What does the controls attribute do in the <video> tag?
a. Adjusts video contrast
b. Adds playback controls
c. Changes video size
d. Enables video looping
6. Which attribute is used to specify the URL of a video file in the <video>
tag?
a. src
b. file
c. media
d. url
7. How can you make a video automatically start playing in HTML?
a. <video autoplay>
b. <video start>
324
Image and Multimedia
c. <video play>
d. <video auto>
8. Which tag is used to embed external content, such as videos from YouTube,
in HTML?
a. <external>
b. <embed>
c. <iframe>
d. <extern>
9. What does the loop attribute do in the <audio> tag?
a. Adds echo effect
b. Repeats the audio playback
c. Adjusts audio volume
d. Enables surround sound
10. Why is providing alternative text (alt attribute) for images important in
HTML?
a. Enhances image colors
b. Improves image alignment
c. Ensures accessibility for screen readers
d. Controls image size
REVIEW QUESTIONS
1. What does the src attribute do?
2. Why is it important to specify the height and width of images in web
pages?
3. Which attribute must be added to the img tag to designate the image as
a client-side image map?
4. What are the four possible values of the clear property (used to clear
floats)?
5. What’s the difference between a plug-in and a helper application?
6. How can users determine which plug-ins are installed on their computers,
and how they can download new plug-ins?
7. What are two ways to include multimedia files in a web site?
8. What are two ways to specify the height and width of multimedia files
embedded with the object tag?
REFERENCES
1. Castro, Elizabeth and Hyslop . HTML5, and CSS, Eight Edition: (Visual
QuickStart Guide), Peachpit Press, 2013.
2. Devlin, Ian. HTML5 Multimedia: Develop and Design, Peachpit Press, 2011.
3. Felke-Morris, Web Development & Design Foundations with HTML5, 10th
Edition, Addison-Wesley, 2020.
4. Jones, Harrison (19 June 2013), Homepage Sliders: Bad For SEO, Bad For
Usability, archived from the original on 22 November 2013
5. Messner, Katie (22 April 2013), Image Carousels: Getting Control of the
MerryGo-Round, [Link], archived from the original on 10 October 2013
6. Pfeiffer, Silvia, and Green, Tom. Beginning HTML5 Media: Make the most
of the new video and audio standards for the Web, APress, 2015.
7. Rhea, John. A Beginner’s Guide to Learning HTML (and Smacking Zombies
Upside the Web Development), Undead Institute, 2018.
8. Smith, M., 2013. HTML: The Markup Language (an HTML language reference).
World Wide Web Consortium
9. Thatcher, Jim et al. Web Accessibility: Web Standards and Regulatory
Compliance, friends of ED, 2006.
326
INDEX
328
Index
329