Web Programming Unit 1
Web Programming Unit 1
PROGRAMMING
INTRODUCTION
► UNIT 1
FUNDAMENTALS OF WEB
► UNIT 2
HTML AND XHTML
► UNIT 3
JAVASCRIPT
► UNIT 4
JAVASCRIPT AND HTML DOCUMENTS
UNIT 1
FUNDAMENTALS OF WEB
• IP addresses : IP addresses are used to identify devices on the internet. These can include
IPv4 addresses such as 192.168.1.1, which is the default IP address. IPv4 addresses are
shorter than IPv6 addresses, which are designed to handle the increasing number of
connected devices.
• Routers : Routers forward data packets between computer networks. By using routing tables,
routers determine the best routes or paths for data transfer between devices.
• Domain name system : DNS converts human-readable domain names, such as
www.example.com, into machine-readable IP addresses. It also acts as a decentralized
directory that helps users navigate the internet.
• Web browsers. Web browsers or search engines -- including Apple Safari, Google
Chrome, Microsoft Edge and Mozilla Firefox -- let users access and engage with material on
the internet and also decipher and present web pages to them.
• ISPs : ISPs are companies that provide users with internet connectivity. They operate the
infrastructure, including the cables and routers needed to connect users to the global network.
• Firewalls and security measures. Incoming and outgoing network traffic on the internet is
monitored and controlled by different types of security firewalls and security measures.
Firewalls safeguard networks and devices against unauthorized internet access, cyber threats
and malicious activities.
What are the key features of the
internet?
► The internet has certain features that make it a powerful and versatile tool for communication,
information sharing and diverse online activities. Some key features of the internet include the
following:
• Worldwide availability. The internet is a global resource that's accessible to everyone. Today,
most people can use the internet even if they live in the most remote and deserted parts of the
world.
• Compatibility with other media types. Due to the standardized protocols and formats that it
offers, the internet facilitates compatibility with various media types. This enables seamless
integration and interaction across diverse multimedia such as photos, videos and audio files.
• Easy accessibility. Web browsers such as Chrome or Firefox are used to access the internet.
For end users and developers, these programs are simple to use, comprehend and easy to
develop.
• Affordability. The expenses associated with developing and maintaining internet services are
low. However, the costs vary depending on the type of services and providers being used.
Uses of the Internet
► Entertainment: The Internet is also used for entertainment. There are numerous
entertainment options available on the internet like watching movies, playing games,
listening to music, etc. You can also download movies, games, songs, TV Serial, etc.,
easily from the internet.
Advantages of the Internet
• Online Banking and Transaction: The Internet allows us to transfer money online
through the net banking system. Money can be credited or debited from one account to
the other.
• Education, Online Jobs, Freelancing: Through the Internet, we are able to get more
jobs via online platforms like LinkedIn and to reach more job providers. Freelancing on
the other hand has helped the youth to earn a side income and the best part is all this
can be done via the INTERNET.
• Entertainment: There are numerous options for entertainment online we can listen to
music, play games can watch movies, and web series, and listen to podcasts, YouTube
itself is a hub of knowledge as well as entertainment.
• New Job Roles: The Internet has given us access to social media, and digital products
so we are having numerous new job opportunities like digital marketing and social
media marketing online businesses are earning huge amounts of money just because
the Internet is the medium to help us to do so.
Continued…
• Time Wastage: Wasting too much time on the internet surfing social media apps
and doing nothing decreases your productivity rather than wasting time on
scrolling social media apps one should utilize that time in doing something
skillful and even more productive.
• Bad Impacts on Health: Spending too much time on the internet causes bad
impacts on your health physical body needs some outdoor games exercise and
many more things. Looking at the screen for a longer duration causes serious
impacts on the eyes.
Continued…
• Cyber Crimes: Cyberbullying, spam, viruses, hacking, and stealing data are some
of the crimes which are on the verge these days. Your system which contains all
the confidential data can be easily hacked by cybercriminals.
• Effects on Children: Small children are heavily addicted to the Internet watching
movies, and games all the time is not good for their overall personality as well as
social development.
• Bullying and Spreading Negativity: The Internet has given a free tool in the
form of social media apps to all those people who always try to spread
negativity with very revolting and shameful messages and try to bully each other
which is wrong.
WWW
► What is WWW?
► WWW stands for World Wide Web and is commonly known as the Web. The
WWW was started by CERN(European Council for Nuclear Research) in
1989. WWW is defined as the collection of different websites around the
world, containing different information shared via local servers(or computers).
► Web pages are linked together using hyperlinks which are HTML-formatted
and, also referred to as hypertext, these are the fundamental units of the
Internet and are accessed through Hypertext Transfer Protocol(HTTP). Such
digital connections, or links, allow users to easily access desired information
by connecting relevant pieces of information. The benefit of hypertext is it
allows you to pick a word or phrase from the text and click on other sites that
have more information about it.
History of the WWW
► The below diagram indicates how the Web operates just like client-server
architecture of the internet. When users request web pages or other information,
then the web browser of your system request to the server for the information
and then the web server provide requested services to web browser back and
finally the requested service is utilized by the user who made the request.
Continued…
► Features of WWW
• WWW is open source.
• It is a distributed system spread across various websites.
• It is a Hypertext Information System.
• It is Cross-Platform.
• Uses Web Browsers to provide a single interface for many services.
• Dynamic, Interactive and Evolving.
WWW Internet
WWW used protocols such as HTTP Internet used protocols such as TCP/IP
► The web browser is an application software to explore www (World Wide Web). It provides an
interface between the server and the client and it requests to the server for web documents
and services. It works as a compiler to render HTML which is used to design a webpage.
Whenever we search for anything on the internet, the browser loads a web page written in
HTML, including text, links, images, and other items such as style sheets and JavaScript
functions. Google Chrome, Microsoft Edge, Mozilla Firefox, and Safari are examples of web
browsers.
► Web Server: Web server is a program which processes the network requests of the
users and serves them with files that create web pages. This exchange takes place
using Hypertext Transfer Protocol (HTTP).
Basically, web servers are computers used to store HTTP files which makes a
website and when a client requests a certain website, it delivers the requested
website to the client. For example, you want to open Facebook on your laptop and
enter the URL in the search bar of google. Now, the laptop will send an HTTP
request to view the facebook webpage to another computer known as the webserver.
This computer (webserver) contains all the files (usually in HTTP format) which make
up the website like text, images, gif files, etc. After processing the request, the
webserver will send the requested website-related files to your computer and then
you can reach the website.One web server can handle multiple users.
Web Server ‘s examples
► There are many web servers available in the market both free and paid. Some of
them are described below:
► Apache HTTP server
► Microsoft Internet Information Services (IIS)
► Lighttpd
► Jigsaw Server
► Sun Java System
What is a URL (Uniform Resource
Locator)?
► A URL (Uniform Resource Locator, also called a web address) is a unique identifier used
to locate a resource on the internet. URLs consist of multiple parts -- including a protocol
and domain name -- that tell web browsers how and where to retrieve a resource.
► End users use URLs by typing them directly into a browser address bar or by clicking a
hyperlink found on a webpage, bookmark list, email or another application.
► How is a URL structured?
► The URL contains the name of the protocol needed to access a resource, as well as a
resource name. The first part of a URL identifies what protocol to use as the primary
access medium. The second part identifies the IP address or domain name -- and
possibly subdomain -- where the resource is located.
What is a URL (Uniform Resource
Locator)?
► URL protocols include HTTP (Hypertext Transfer Protocol) and HTTPS (HTTP
Secure) for web resources, mailto for email addresses, FTP for files on a File
Transfer Protocol server and telnet for a session to access remote computers. A
colon and two forward slashes follow most URL protocols, but only a colon follows
the mailto protocol.
► URLs can also specify the following optional information after the domain:
• A path to a specific page or file within a domain.
• A network port to use to make the connection.
• A specific reference point within a file, such as a named anchor in an HTML file.
• A query or search parameters used -- commonly found in URLs for search results.
Continued…
► URL examples
► When designing URLs, there are different theories about how to make the syntax. For
example, https://www.xyz.com/searchnetworking/definition/URL
► Parts of a URL
► Using the URL https://www.xyz.com/whatis/search/query?q=URL as an example,
components of a URL can include the following:
• The protocol or scheme. This is used to access a resource on the internet. Protocols
include http, https, ftp, mailto and file. The domain name system name reaches the
resource. In this example, the protocol is https.
• Host name or domain name. This is the unique reference that represents a webpage.
For this example, it is xyz.com.
• Subdomain. This precedes the main domain name. In this case, "www" denotes the
Word Wide Web. Other subdomain options include "blog," "mail" and "support."
• Port name. These usually aren't visible in URLs, but they're necessary. Ports 80 and
443 are the default ports for web servers, but there are other options. In a URL, ports
always follow a colon. For this example, https://www.xyz.com:443.
Continued…
• Path. A path refers to a file or location on the web server. For this example, the
path is whatis/search/query.
• Query. Found in the URL of dynamic pages, the query consists of a question
mark, followed by parameters or the query string. In this example, "?" marks the
beginning of the query.
• Parameters. These are pieces of information in a query string of a URL. Multiple
parameters can be separated by ampersands (&). In this example, the parameter
is "q=URL."
• Fragment. This is an internal page reference, which refers to a section within the
webpage. It appears at the end of a URL and begins with a sign (#). Although not
in the example above, an example could be #history in the URL
https://en.wikipedia.org/wiki/Internet#History.
What is MIME (Multipurpose Internet
Mail Extensions)?
► Emails with MIME formatting may be transmitted via standard protocols like SMTP, Post
Office Protocol (POP) or Internet Message Access Protocol (IMAP). The body of such
messages may consist of multiple parts. The header may be specified in non-ASCII
character sets MIME supports.
► Servers insert the MIME header at the beginning of an email transmission. Clients use
the MIME header to select an appropriate player application for the data type indicated
by the header. Some players are built into the web client or browser. For instance,
all browsers come with GIF and JPEG image players and can handle HTML files. Other
players may need to be downloaded.
► At the sender's end, MIME transforms non-ASCII data to 7-bit Network Virtual Terminal
(NVT) data. 7-bit ASCII can represent 128 characters. MIME then delivers this
transformed data to the client SMTP. At the recipient's end, the message is transferred
back to the original data, allowing them to see its contents, regardless of whether it
contains text, audio, video or some other kind of data.
Continued…
What is HTTP?
HTTP (Hypertext Transfer Protocol) is the set of rules for transferring files -- such as text, images, sound,
video and other multimedia files -- over the web. As soon as a user opens their web browser, they are
indirectly using HTTP. HTTP is an application protocol that runs on top of the TCP/IP suite of protocols,
which forms the foundation of the internet.
► An HTTP body. This is optional information the server needs from the request, such as
user forms -- username/password logins, short responses and file uploads -- that are being
submitted to the website.
► HTTP responses. The HTTP response message is the data received by a client
device from the web server. As its name suggests, the response is the server's reply to an
HTTP request. The information contained in an HTTP response is tailored to the context the
server received from the request. HTTP responses typically include the following data:
• HTTP status code, which indicates the status of the request to the client device.
Responses may indicate success, an informational response, a redirect, or errors on the
server or client side.
• HTTP response headers, which send information about the server and requested
resources.
• An HTTP body (optional). If a request is successful, this contains the requested data in
the form of HTML code, which is translated into a web page by the client browser.
HTTP vs. HTTPS
► Web Security deals with the security of data over the internet/network or web or while it
is being transferred over the internet. Web security is crucial for protecting web
applications, websites, and the underlying servers from malicious attacks and
unauthorized access. Web Security is an online security solution that will restrict access to
harmful websites, stop web-based risks, and manage staff internet usage.
► Security Consideration
• Updated Software: You need to always update your software. Hackers may be aware
of vulnerabilities in certain software, which are sometimes caused by bugs and can be
used to damage your computer system and steal personal data. Older versions of software
can become a gateway for hackers to enter your network. Software makers soon become
aware of these vulnerabilities and will fix vulnerable or exposed areas. That’s why It is
mandatory to keep your software updated, It plays an important role in keeping your
personal data secure.
• Beware of SQL Injection: SQL Injection is an attempt to manipulate your data or your
database by inserting a rough code into your query. For e.g. somebody can send a query to
your website and this query can be a rough code while it gets executed it can be used to
manipulate your database such as change tables, modify or delete data or it can retrieve
important information also so, one should be aware of the SQL injection attack.
CONTINUED…
• Data Validation: Data validation is the proper testing of any input supplied by
the user or application. It prevents improperly created data from entering the
information system. Validation of data should be performed on both server-side
and client-side. If we perform data validation on both sides that will give us the
authentication. Data validation should occur when data is received from an
outside party, especially if the data is from untrusted sources.
• Password: Password provides the first line of defense against unauthorized
access to your device and personal information. It is necessary to use a strong
password. Passwords must be complex to protect against brute force. It is good
to enforce password requirements such as a minimum of eight characters long
must including uppercase letters, lowercase letters, special characters, and
numerals.
WEB PROGRAMMER’S TOOLBOX
► Document languages and programming languages that are the building blocks
of the web and web programming.
► XHTML
► XML
► JavaScript
► Java, Perl, Ruby, PHP
► XHTML
To describe the general form and layout of documents .An XHTML document is a
mix of content and controls, Tags,specify something about how the content should
be arranged in the document.Attributes provide additional information about the
content of a tag.
CONTINUED…
► JavaScript
A client-side HTML-embedded scripting language
Dynamically typed and not object-oriented
Provides a way to access elements of HTML documents and dynamically
change them
► Cascading Style Sheets (CSS) is a style sheet language used for specifying
the presentation and styling of a document written in a markup language such
as HTML or XML . CSS is designed to enable the separation of content and
presentation, including layout, colors, and fonts.
HTML
► HyperText
► We must first examine the idea of hypertext in order to comprehend the origins of
HTML. Early 20th-century pioneers like Vannevar Bush proposed the concept of tying
information together through hypertext, envisioning a "memex" machine that could
organize enormous volumes of information using linked microfilm.
► However, Ted Nelson, an American philosopher and sociologist, first used the word
"hypertext" in the 1960s. Nelson's idea of hypertext was to develop a network of
connected text and multimedia that permitted non-linear information navigation.
CONTINUED…
Continued…
► 1998 The W3C( World Wide Web Consortium ) decided to shift focus to an
XML-based HTML equivalent called XHTML
► 1999 HTML 4.01, which became an official standard in December 1999,
was the most widely used version in the early 2000s.
► 2000 XHTML 1.0, completed in 2000, was a combination of HTML4 in XML.
► 2003 The introduction of XForms reignited interest in evolving HTML itself
rather than replacing it with new technologies. This new theory recognized
that XML was better suited for new technologies like RSS and Atom, while
HTML remained the cornerstone of the web.
History and Evolution
► History
► It was developed by the World Wide Web Consortium (W3C) and helps web
developers transition from HTML to XML. With XHTML, developers can enter the
XML world with all its features while still ensuring backward and future
compatibility of the content. The XHTML family includes three document types;
the first is XHTML 1.0, which was recommended by W3C on January 26, 2000.
The second is XHTML 1.1, which was recommended by W3C on May 31, 2001.
► The third is XHTML5, a standard used for developing an XML adaptation of the
HTML5 specification. An XHTML document must have an XHTML <!DOCTYPE>
declaration.
Key Syntax Rules for XHTML
► The basic syntax for XHTML (Extensible Hypertext Markup Language) is similar to that
of HTML but adheres to stricter rules derived from XML. Below are the key principles
and components that define valid XHTML syntax.
► 1. Well-Formedness:
•Every element must have a closing tag or be self-closed.
•Attributes must be quoted (single or double quotes).
•2. Lowercase Tags:
•All element names and attribute names must be in lowercase.
•3. Proper Nesting:
•Elements must be properly nested. For example, if you open a <div>, you must close it
before closing any containing elements.
•4. DOCTYPE Declaration:
•A DOCTYPE declaration is required at the beginning of the document.
•5. Self-Closing Tags:
•Tags that don’t have any content must be self-closed with a slash (/) before the closing angle
bracket.
Basic Structure of an XHTML Document
► 1.DOCTYPE Declaration:
Specifies the version of XHTML being used (XHTML 1.0 Transitional in this case). DTD
stands for Document Type Definition. It is a set of markup declarations that define a
document type for an XML or XHTML document.
► 2. Root Element:
The <html> element is the root of the document. The xmlns attribute defines the
XML namespace.
3. Head Section:
The <head>
section contains metadata about the document, such as the title
and character set.
Continued…
4. Body Section:
The <body> section contains the visible content of the webpage. It includes
headings, paragraphs, images, links, etc.
► 5. Self-Closing Tags:
The <img> tag is self-closed with a slash, indicating that it does not
have an end tag
Breakdown of the DOCTYPE
Declaration
1.<!DOCTYPE html>:
•This specifies that the document is an HTML document.
•XHTML (which is an XML-based version of HTML).
2.PUBLIC:
•This indicates that the document is using a public identifier.
•This means the document is compliant with a publicly available standard.
4.-//W3C//: This indicates that the document is based on a specification from the World Wide Web
Consortium (W3C), which is the main international standards organization for the web.
Continued…
5.DTD XHTML 1.0 Transitional: This specifies that the document conforms to the
XHTML 1.0 Transitional DTD.
The "Transitional" part indicates that this DTD allows for a mix of HTML-like features and
XML-compliance, making it more lenient than the strict version.
6. //EN: This indicates that the document is in English.
7."http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd":
•This is the system identifier (URI) that points to the actual DTD file online.
• While not always necessary for browsers, it serves as a reference for validation tools and for those
•wanting to understand the document type's structure.
HTML Introduction
❑ The contents of a page title is very important for search engine optimization
(SEO)! The page title is used by search engine algorithms to decide the order
when listing pages in search results.
► <!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
</body>
</html>
Example Explained
Components Description
The declaration is not an HTML tag. This is an info to the
<!DOCTYPE html>
browser about what document type to expect.
They are the basic structure of an HTML document that
surrounds the content and applies meaning to it. Tags are
Tags
enclosed within angle braces <tag name>. Most of the tags
have their corresponding closing tags except few tags.
An attribute is used to define the characteristics of
Attributes an HTML element that appears inside the opening tag and
their values used inside the quotation marks.
It is a collection of start and end tags with the content
Elements
inserted in between them.
It is used to define the headings of a page. There are six
levels of headings defined by HTML. These 6 heading
Heading
elements are h1, h2, h3, h4, h5, and h6; with h1 being the
highest level and h6 being the least.
To illustrates the Basic HTML structure.
► <!DOCTYPE html>
► <html lang="en">
► <head>
► <meta charset="UTF-8">
► <meta name="viewport"
► content="width=device-width, initial-scale=1.0">
► <title>HTML</title>
► </head>
► <body>
► <!--Contents of the webpage-->
► <p>First webpage</p>
► </body>
► </html>
HTML Headings
► The HTML heading tags are used to create headings for the content of a webpage.
These tags are typically placed inside the body tag. HTML offers six heading tags, from
<h1> to <h6>, each displaying the heading in a different font size.
► Syntax:
► <h1></h1>
► <h2></h2>
► <h3></h3>
► <h4></h4>
► <h5></h5>
► <h6></h6>
To demonstrate the use of 6 heading tags from
<h1> to <h6> in HTML.
► <!DOCTYPE html>
► <html lang="en"> OUTPUT:
► <head>
► <meta charset="UTF-8">
► <meta name="viewport"
► content="width=device-width, initial-scale=1.0">
► <title>HTML heading tag</title>
► </head>
► <body>
► <h1>Heading 1 (h1)</h1>
► <h2>Heading 2 (h2)</h2>
► <h3>Heading 3 (h3)</h3>
► <h4>Heading 4 (h4)</h4>
► <h5>Heading 5 (h5)</h5>
► <h6>Heading 6 (h6)</h6>
► </body>
► </html>
HTML Paragraph and Break Elements
► HTML <p> tags are used to write paragraph statements on a webpage. They
start with the <p> tag and end with </p>. The HTML <br> tag is used to insert a
single line break and does not require a closing tag. In HTML, the break tag is
written as <br>.
► Syntax:
// for Parapgraph
► <p> Content... </p>
// for Break
► <br>
HTML Images
► Syntax:
► <img src="geeks.png“ width="104" height="142">
To illustrates the use of the <img> tag
for inserting the images in HTML.
► <!DOCTYPE html>
► <html lang="en">
► <head>
► <meta charset="UTF-8">
► <meta name="viewport"
► content="width=device-width, initial-scale=1.0">
► <title>HTML img tag</title>
► </head>
► <body>
► <img src=“picture.png">
► </body>
► </html>
What are the basic rules of HTML?
• HTML employs tags to structure content, defining elements like headings, paragraphs,
lists, and links, facilitating document organization and readability for web browsers.
• Compatible with various devices and operating systems, HTML ensures consistent
rendering and accessibility across different platforms.
• Supports interactive elements like forms and multimedia embedding, enabling user
engagement and dynamic content creation within web pages.
• Provides semantic elements like <header>, <footer>, and <article> for conveying
meaningful document structure, improving SEO and accessibility.
• Easily integrates with other technologies like CSS for styling and JavaScript for dynamic
behavior, allowing developers to create rich, interactive web experiences.
HTML Lists
► HTML lists allow web developers to group a set of related items in lists.
► Example
► An unordered HTML list:
• Item
• Item
• Item
• Item
Continued…
► An unordered list starts with the <ul> tag. Each list item
starts with the <li> tag.
► The list items will be marked with bullets (small black
circles) by default:
► Example
► <ul>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>
Ordered HTML List
► An ordered list starts with the <ol> tag. Each list item
starts with the <li> tag.
► The list items will be marked with numbers by default:
► Example
► <ol>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
HTML Tables
► HTML tables allow web developers to arrange data into rows and
columns.
► Table Cells
Each table cell is defined by a <td> and a </td> tag.
►
<table>
<tr>
<td>Emil</td>
<td>Tobias</td>
<td>Linus</td>
</tr>
</table>
► <td> stands for table data.
Continued…
► A table cell can contain all sorts of HTML elements: text, images, lists,
links, other tables, etc.
► Table Rows
► Each table row starts with a <tr> and ends with
a </tr> tag.
► Example
Continued…
► <table>
<tr>
<td>Emil</td>
<td>Tobias</td>
<td>Linus</td>
</tr>
<tr>
<td>16</td>
<td>14</td>
<td>10</td>
</tr>
</table>
Table Headers
► Sometimes you want your cells to be table header cells. In those cases use the <th> tag instead
of the <td> tag.
► Example
► <table>
<tr>
<th>Person 1</th>
<th>Person 2</th>
<th>Person 3</th>
</tr>
<tr>
<td>Emil</td>
<td>Tobias</td>
<td>Linus</td>
</tr>
<tr>
<td>16</td>
<td>14</td>
<td>10</td>
</tr>
</table>