Web Tech - 1-26-115
Web Tech - 1-26-115
Introduction to HTML,
HTTP and PHP
Objectives…
To understand Basic Concepts in HTML
To learn Basics of HTTP
To study Basic Concepts of PHP
To learn Language Basics and Lexical Structure of PHP
1.0 INTRODUCTION
• Web technologies refer to techniques and tools that are used to produce fully-featured
Websites and Web applications.
• A Website is a collection of web pages. A document on the Web is called a Web page
and is identified by a unique address called the Uniform Resource Locator (URL).
• A Web application (Web app) is an application program that is stored on a Web server
and delivered over the Internet through a Browser.
• The two types of Web pages are static web page and dynamic web page. The content
(data and information) in static web pages does not get changed until someone
changed it manually while the content in dynamic web pages changes dynamically
(runtime).
• The two distinct parts of a website are the frontend (refers to all those parts of a
website that a user can see on their screen and interact with) and the backend
(involves the hidden mechanisms where functions, methods, and data manipulation
happens).
• The World Wide Web (WWW) consists of files, called pages or web pages, which
contain information and links to resources throughout the Internet.
• In simple word, all publicly accessible websites collectively constitute the World Wide
Web.
• A web page is an electronic document written in a computer language called HTML
(HyperText Markup Language). HTML is the standard markup language for creating
Web pages and Web applications.
• Web design is the process of creating websites. Website is a collection of related web
pages that may contain text, images, audio and video.
1.1
Web Technologies - I Introduction to HTML, HTTP and PHP
• A web browser or a browser (client) is application software for accessing the World
Wide Web. Some popular web browsers are Opera, Mozilla Firefox, Google Chrome,
and Safari.
• When a user requests a web page from a particular website, the web browser
retrieves the necessary content from a Web server (server) and then displays the page
on the user's device like desktops, laptops, tablets, and smart phones.
• Web development, or web programming, refers to the design of software applications
for a Web site. Web publishing or Online publishing, is the process of publishing
content on the Internet.
• Web technology is a collective name for technologies primarily for the World Wide
Web (WWW) or Web. These technologies includes Markup Language (HTML),
Programming languages (JavaScript, Python, PHP etc.), Frameworks (Node.js,
Angular.js, .NET, Drupal etc.), Databases (MongoDB, PostgreSQL, MySQL etc.) CSS
(Cascading Style Sheet), Libraries (JQuery), Data formats (XML (Extensible Markup
Language), JSON (JavaScript Object Notation)) and so on.
• In this chapter we will study HTML, CSS, HTTP and PHP technologies related to web
technologies.
• An HTML file is a text file with extension .htm or .html. To create the HTML source
document, we need an HTML Editor. An HTML editor is a program for editing HTML,
the markup of a web page.
• An HTML editor is a computer program used for creating and editing Web pages.
There are two main varieties of HTML editors i.e. text and WYSIWYG (What You See Is
What You Get) editors.
• A text editor is a type of program used for editing plain text files. A text-based HTML
editor includes Notepad on Windows, GNU Emacs on UNIX/Linux, or SimpleText on
the Macintosh.
• The WYSIWYG editors provide an editing interface which resembles how the page will
be displayed in a web browser like Adobe Dreamweaver, KomodoIDE, EditPlus etc.
• Other professional text editors for HTML include Notepad++, Sublime Text, Vim, Atom,
and Visual Studio Code and so on.
HTML Page Structure:
• Fig. 1.1 shows page structure of HTML. A web page is also known as HTML page or
HTML document.
• A basic HTML page starts with the Document Type Declaration also called DOCTYPE
declaration before the <html> tag. The <!DOCTYPE> declaration represents the
document type.
• The Document Type Declaration is not an HTML tag; it is an instruction to the web
browser about what version of HTML the page is written in.
• The current version of HTML is HTML5 and it makes use of the only one declaration
<!DOCTYPE html>.
<!DOCTYPE>
<html>
<head>
</head>
<body>
</body>
</html>
• The entire HTML document is contained within an opening <html> tag and a closing
</html> tag.
• Within the <html> tag, the document is divided into a head and a body. The <head> tag
contains descriptive information about the document itself, such as its title, the style
sheet(s) it uses and so on.
• The <body> tag contains the entire information or content about the web page and its
behavior. It also contains the information that we want to display on a Web page.
Example for creating an html document:
<!DOCTYPE html>
<html>
<head>
<title>
</title>
<body>
<h1>Nirali Prakashan</h1>
<p>Textbook Publication Firm.</p>
</body>
</head>
</html>
Output:
element
Fig. 1.2: Element in HTML
• Fig. 1.3 shows an example of HTML element. In this example, the HTML element is a
paragraph <p> opening and closing tags with “My paragraph...” content that will
display on the web page.
1.4
Web Technologies - I Introduction to HTML, HTTP and PHP
HTML element
2. Singular Tags: The singular tag is also known as a stand-alone tag or empty tag.
The stand-alone tag does not have companion tag or closing tag. For example <br>
tag will insert a line break. This tag does not require any companion tag or a
closing tag.
Basic HTML Tags:
• HTML contains following basic tags:
1. <html> Tag: The <html> tag represents the root of an HTML document. The <html>
tag is the container that contains all other HTML elements (except for the
<!DOCTYPE> declaration which is located before the opening HTML tag). The
<html> tag tells the browser that this is an HTML document.
Syntax: <html>…………</html>
Attribute Description
1. Manifest This attribute specifies the address of the document's
application cache manifest and the value must be a valid URL.
2. <title> Tag: The <title> tag is used for declaring the title, or name, of the HTML
document. The title is usually displayed in the browser's title bar (at the top) or the
<title> tag defines a title in the browser toolbar. It is also displayed in browser
bookmarks and search results.
Syntax: <title>…………</title>
3. <head> Tag: The <head> tag is a container for all the head elements and must
include a title for the document, and can include scripts, styles, meta information,
and so on.
Syntax: <head>…………</head>
4. <body> Tag: The <body> tag defines the document's body. The body tag is placed
between the </head> and the </html> tags. The <body> tags contains all the
contents of an HTML document, such as text, hyperlinks, images, tables, lists, etc.
Syntax: <body>………</body>
Attributes of <body> Tag:
Attribute Value Description
1. alink color This attribute specifies the color of an active link
in a document.
2. background URL This attribute specifies a background image for a
document.
3. bgcolor color This attribute specifies the background color of a
document.
contd. …
1.6
Web Technologies - I Introduction to HTML, HTTP and PHP
1.7
Web Technologies - I Introduction to HTML, HTTP and PHP
5. <strong> The <strong> tag is used for indicating strong importance for its
contents. The strong tag surrounds the emphasized word/phrase.
Syntax: <strong>……</strong>
6. <sub> The <sub> tag defines subscript text. Subscript text appears half a
character below the baseline. Subscript text can be used for chemical
formulas, like H2O.
Syntax: <sub>……</sub>
7. <sup> The <sup> tag defines superscript text. Superscript text appears half a
5
character above the baseline like 10 .
Syntax: <sup>……</sup>
8. <ins> The <ins> tag defines a text that has been inserted into a document.
Syntax: <ins>……</ins>
9. <del> The <del> tag defines text that has been deleted from a document.
Syntax: <del>……</del>
10. <u> The <u> tag usually results in the text being underlined. Anything that
appears in a <u>...</u> element is displayed with underline,
Syntax: <u>……</u>
11. <strike> Anything that appears in a <strike> tag is displayed with strikethrough,
which is a thin line through the text like, strikethrough.
Syntax: <strike>……</strike>
12. <big> The content of the <big> element is displayed one font size larger than
the rest of the text surrounding it.
Syntax: <big>……</big>
Example for text formatting tags:
<!DOCTYPE html>
<html>
<head>
<title> Example of HTML Text Formatting Tags </title>
</head>
<body>
<p>Nirali Prakashan</p>
<font size="4">Wecome to <b>Nirali Prakashan.</b> <br/></font>
<font size="2"><i>Nirali Prakashan</i> is a textbook publication
firm.<br/></font>
<font face="verdana" color="black">Nirali Prakashan <u>publised
more than 3500 book titles.</u></font>
</body>
</html>
Output:
1.8
Web Technologies - I Introduction to HTML, HTTP and PHP
3. <p> Tag: HTML documents are divided into paragraphs. The HTML <p> tag is used
for defining a paragraph.
Syntax: <p>…………</p>
Attributes for Paragraph Tag:
4. <br> Tag: The HTML <br> tag is used for specifying a line break. The <br> tag is an
empty tag. In other words, it has no end tag. Syntax: <br/>
5. <center> Tag: The <center> tag is used to center-align text.
1.9
Web Technologies - I Introduction to HTML, HTTP and PHP
6. Non breaking Spaces: Suppose we were to use the phrase "14 Angry Men." Here
we would not want a browser to split the "14" and "Angry" across two lines. A good
example of this technique appears in the movie "14 Angry Men." In cases where
we do not want the client browser to break text, we should use a non-breaking
space entity ( ) instead of a normal space. For example, when coding the "14
Angry Men" paragraph, we would use something similar to the following code:
<p>A good example of this technique appears in the movie
"14 Angry Men."</p>
7. <div> Tag: The <div> tag defines a division or a section in an HTML document. The
<div> tag is used to group block-elements to format them with CSS.
Syntax: <div>…………</div>
Attribute Value Description
1. align left Align attribute specifies the alignment of the content inside
right a <div> element
center
justify
Example for <div> tag:
<!DOCTYPE html>
<html>
<head>
<title> Example of HTML div Tag </title>
</head>
<body>
<div style="background-color:orange;text-align:center">
<p>Nirali Prakashan</p>
</div>
<div style="background-color:pink;text-align:center">
<p>Pragati Group</p>
</div>
</body>
</html>
Output:
8. <span> Tag: The <span> tag is used for grouping and applying styles to inline
elements.
Syntax: <span>…………</span>
1.10
Web Technologies - I Introduction to HTML, HTTP and PHP
9. <hr> Tag: The HTML <hr> tag is used for specifying a horizontal rule in an HTML
document. The <hr> tag is used for creating a horizontal line which separate
content (or define a change) in an HTML page.
Syntax: <hr/>
Attributes for <hr> Tag:
Attribute Value Description
1. align left This attribute specifies the alignment of a <hr>
center element.
right
2. noshade noshade This attribute specifies that a <hr> element should
render in one solid color (no-shaded), instead of a
shaded color.
3. size pixels This attribute specifies the height of a <hr> element.
4. width pixels % This attribute specifies the width of a <hr> element.
1.11
Web Technologies - I Introduction to HTML, HTTP and PHP
10. <font> Tag: Fonts play very important role in making a website more user friendly
and increasing content readability. The <font> tag specifies the font face, font size,
and font color of text.
Syntax: <font>…………</font>
Attributes for <font> tag:
Attribute Value Description
1. color rgb(x,x,x) This attribute specifies the color of text.
#xxxxxx
colorname
2. face font_family This attribute specifies the font of text.
3. size number This attribute specifies the size of text.
Example for <font> tag:
<!DOCTYPE html>
<html>
<head>
<title> Example for HTML font Tag </title>
</head>
<body>
<p><h2>Nirali Prakashan</h2></p>
<font size="4" color="red">Wecome to Nirali Prakashan. <br/></font>
<font size="2" color="blue">Nirali Prakashan is a textbook
publication firm.<br/></font>
<font face="verdana" color="black">Nirali Prakashan publised more
than 3500 book titles.</font>
</body>
</html>
1.12
Web Technologies - I Introduction to HTML, HTTP and PHP
Output:
1.13
Web Technologies - I Introduction to HTML, HTTP and PHP
Concept of URL:
• Each and every web page has a unique address, called a Uniform Resource Locator
(URL) that identifies its location on the Internet.
Parts of URL:
• URL has several parts i.e., the protocol, the domain name, the directory or folder, and
the filename and its extension. Below is an example of URL and the corresponding
parts.
https://www.niraliprakashan.com/html/index.htm
2. Relative: A relative URL indicates where the resource is in relation to the current
page. Given URL is added with the <base> element to form a complete URL. For
example, /html/html_text_links.htm. There are two types of relative URLs:
(i) In Document Relative URLs, the document address is given in relation with
the originating document.
(ii) In Server Relative URLs, the document address is given in relation with the
server on which the document is present.
Lists in HTML:
• In HTML, we can list out the items, subjects or menu in the form of a list. HTML gives
us three different types of lists as explained below:
1. Unordered Lists: An unordered list is a collection of related items that have no
special order or sequence. Unordered list is created by using <ul> tag. Each item in
the list is marked with a bullet. The bullet itself comes in three flavors: squares,
discs, and circles.
2. Ordered Lists: The Ordered list is created by using <ol> tag. Each item in the list is
marked with a number. The numbering starts at one and is incremented by one
for each successive ordered list element tagged with <li> tag.
3. Definition Lists: The definition list is the ideal way to present a glossary, list of
terms, or other name/value list. Definition List makes use of <dl>, <dt> and
<dd>tags.
• Metadata is data (information) about data. Meta elements are typically used to specify
page description, keywords, author of the document, last modified and other
metadata.
• The <meta> tag is used for declaring metadata for the HTML document. The <meta>
tag always goes inside the head element.
Syntax: <meta name = string content = string>
1. <li> List Tag: The <li> tag defines a list item. The <li> tag is used in ordered lists
(<ol>), unordered lists (<ul>), and in menu lists (<menu>).
Syntax: <li>………</li>
Attributes Value Description
1. type 1 This attribute specifies which kind of bullet point
A will be used.
a
I
i
disc
square
circle
2. value number This attribute specifies the value of a list item.
1.16
Web Technologies - I Introduction to HTML, HTTP and PHP
2. <ul> Unordered List Tag: An unordered list starts with the <ul> tag. Each list item
starts with the <li> tag. The <ul> tag defines an unordered (bulleted) list.
Syntax: <ul>………</ul>
Attributes Value Description
1. compact compact This attribute specifies that the list should render
smaller than normal.
2. type disc This attribute specifies the kind of marker to use in
square the list.
circle
Example for <ul> tag:
<!DOCTYPE html>
<html>
<head>
<h3>An Unordered List Example</h3>
<body>
<h4>Disc bullets list:</h4>
<ul type="disc">
<li>Apples</li>
<li>Bananas</li>
<li>Lemons</li>
<li>Oranges</li>
</ul>
<h4>Circle bullets list:</h4>
<ul type="circle">
<li>Apples</li>
<li>Bananas</li>
<li>Lemons</li>
<li>Oranges</li>
</ul>
<h4>Square bullets list:</h4>
<ul type="square">
<li>Apples</li>
<li>Bananas</li>
<li>Lemons</li>
<li>Oranges</li>
</ul>
</body>
</head>
</html>
1.17
Web Technologies - I Introduction to HTML, HTTP and PHP
Output:
• Nested List: One list inside another list is known as nesting of list or nested list. We
can nested unordered list as follows:
<!DOCTYPE html>
<html>
<body>
<h4>A nested List:</h4>
<ul>
<li>Coffee</li>
<li>Tea
<ul>
<li>Black tea</li>
<li>Green tea
<ul>
<li>China</li>
<li>Africa</li>
</ul>
</li>
</ul>
</li>
<li>Milk</li>
</ul>
</body>
</html>
1.18
Web Technologies - I Introduction to HTML, HTTP and PHP
Output:
3. <ol> Ordered List Tag: An ordered list starts with the <ol> tag. Each list item starts
with the <li> tag. Each item in the list is marked with a number.
Syntax: <ol>…………</ol>
Attributes Value Description
1. compact compact This attribute specifies that the list should render
smaller than normal.
2. reversed reversed This attribute specifies that the list order should be
descending like 9,8,7...
3. start number This attribute specifies the start value of an
ordered list.
4. type 1 This attribute specifies the kind of marker to use in
A the list.
a
I
i
1.19
Web Technologies - I Introduction to HTML, HTTP and PHP
<h4>Letters list:</h4>
<ol type="A">
<li>Apples</li>
<li>Bananas</li>
<li>Lemons</li>
</ol>
<h4>Lowercase letters list:</h4>
<ol type="a">
<li>Apples</li>
<li>Bananas</li>
<li>Lemons</li>
</ol>
<h4>Roman numbers list:</h4>
<ol type="I">
<li>Apples</li>
<li>Bananas</li>
<li>Lemons</li>
</ol>
<h4>Lowercase Roman numbers list:</h4>
<ol type="i">
<li>Apples</li>
<li>Bananas</li>
<li>Lemons</li>
</ol>
</body>
</head>
</html>
Output:
1.20
Web Technologies - I Introduction to HTML, HTTP and PHP
4. Definition Lists: A definition list is a list of items, with a description of each item.
The <dl> tag defines a definition list. The <dl> tag is used to provide a list of items
with associated definitions.
Syntax: <dl>…………</dl>
Definition list makes use of following two tags:
(i) <dt>: The <dt> tag is used inside dl. It marks up a term whose definition is
provided by the next dd. The dt tag may only contain text-level markup.
(ii) <dd>: The <dd> tag is used inside a dl definition list to provide the definition of
the text in the dt tag. It may contain block elements but also plain text and
markup.
Example for definition list:
<!DOCTYPE html>
<html>
<body>
<h4>A Definition List:</h4>
<dl>
<dt>Coffee</dt>
<dd>Black hot drink</dd>
<dt>Milk</dt>
<dd>White cold drink</dd>
</dl>
</body>
</html>
Output:
Images in HTML:
• It is true that one single image is worth than thousands of words. So as a web
developer we should have clear understanding on how to use images in the web
pages.
• Images are used in many ways to enhance the look of a Web page and make it more
interesting and colorful.
• There are basically following two types of graphic programs for images:
1. Bitmap (or Raster) images are stored as a series of tiny dots called pixels. Each
pixel is actually a very small square that is assigned a color, and then arranged in a
pattern to form the image. Bitmap graphics can be edited by erasing or changing
the color of individual pixels using a program such as Adobe Photoshop.
1.21
Web Technologies - I Introduction to HTML, HTTP and PHP
2. Vector images are not based on pixel patterns, but instead use mathematical
formulas to draw lines and curves that can be combined to create an image from
geometric objects such as circles and polygons. Vector images are edited by
manipulating the lines and curves that make up the image using a program such
as Adobe Illustrator.
1.22
Web Technologies - I Introduction to HTML, HTTP and PHP
• We will insert any image in our web page by using <img> tag.
Syntax:
<img src="image URL" attr_name="attr_value"... more attributes />
Attributes Value Description
1. alt text This attribute specifies an alternate text for an
image.
2. src URL This attribute specifies the URL of an image.
3. align top This attribute specifies the alignment of an
bottom image according to surrounding elements.
middle
left
right
4. border pixels This attribute specifies the width of the
border around an image.
5. crossoriginNew anonymous This attribute allow images from third-party
use- sites that allow cross-origin access to be used
credentials with canvas.
6. height pixels This attribute specifies the height of an image.
7. hspace pixels This attribute specifies the whitespace on left
and right side of an image.
8. ismap ismap This attribute specifies an image as a server-
side image-map.
9. longdesc URL This attribute specifies the URL to a document
that contains a long description of an image.
10. src URL This attribute specifies the URL of an image.
11. usemap #mapname This attribute specifies an image as a client-
side image-map.
12. vspace pixels This attribute specifies the whitespace on top
and bottom of an image.
13. width pixels This attribute specifies the width of an image.
Example for image:
<!DOCTYPE html>
<html>
<head>
<meta name="GENERATOR" content="MICROSOFT FRONTPAGE 4.0">
<meta name="PROGID" content="FRONTPAGE.EDITOR.DOCUMENT">
<title>IMAGE SPACING</title>
</head>
<body>
<p>
1.23
Web Technologies - I Introduction to HTML, HTTP and PHP
Image as a Link:
• Anything can be a link i.e., text or images. To make an image into a link we simply put
the image tag inside the tag for a link. The tag would look like this:
<a href="http://www.anycartoonsite.com"><img src="z:\book\mikey.jpg"></a>
1.24
Web Technologies - I Introduction to HTML, HTTP and PHP
<body>
IMAGE LINK EXAMPLE
<p>
<a href = "HTTP://WWW.YAHOO.COM" ><img src = "http://images4.wikia.
nocookie.net/__cb20120710211159/cartoons/images/8/80/Mickey_Mouse.jpg"
border = "0" width ="90" height = "80"> </a>
</p>
</body>
</html>
Output:
Frames in HTML:
• With frames, we can display more than one HTML document in the same browser
window. Each HTML document is called a frame, and each frame is independent of the
others. A collection of frames in the browser window is known as a frameset.
• The frameset, frame, and noframes tags are supported in previous versions of HTML
such as HTML 4.01 and not supported in HTML5.
1.25
Web Technologies - I Introduction to HTML, HTTP and PHP
• The <iframe> tag specifies an inline frame. An inline frame is used to embed another
document within the current HTML document.
• The <iframe> tag defines a rectangular region within the document in which the
browser displays a separate document, including scrollbars and borders.
• HTML5 has added some new attributes, and several HTML 4.01 attributes are removed
from HTML5.
Syntax: <iframe> … </iframe>
Attributes for <iframe> tag:
Attributes Value Description
1. height pixels This attribute specifies the height of an
<iframe>.
2. name text This attribute specifies the name of an
<iframe>.
3. sandbox allow-forms This attribute enables an extra set of
allow-pointer-lock restrictions for the content in an <iframe>.
allow-popups
allow-same-origin
allow-scripts
allow-top-navigation
4. src URL This attribute specifies the address of the
document to embed in the <iframe>.
5. srcdoc HTML_code This attribute specifies the HTML content of
the page to show in the <iframe>
6. width pixels This attribute specifies the width of an
<iframe>.
1.26
Web Technologies - I Introduction to HTML, HTTP and PHP
• Table heading can be defined using <th> tag or the <th> tag defines a header cell in an
HTML table. An HTML table has two kinds of cells:
(i) Header Cells: Contains header information (created with the <th> element), and
(ii) Standard Cells: Contains data (created with the <td> element).
1.29
Web Technologies - I Introduction to HTML, HTTP and PHP
• The <tr> tag defines a row in an HTML table. A <tr> element contains one or more <th>
or <td> elements.
• The <td> tag defines a standard cell in an HTML table. The <td> tag is used to mark up
individual cells inside a table row.
• The <caption> tag defines a table caption. The <caption> tag is used to provide a
caption for a table. This caption can either appear above or below the table.
• Tables can be divided into three portions namely a header, a body, and a foot. The
head and foot are rather similar to headers and footers in a word-processed document
that remain the same for every page, while the body is the main content of the table.
1.30
Web Technologies - I Introduction to HTML, HTTP and PHP
• The three elements for separating the head, body, and foot of a table are:
o <thead>: To create a separate table header.
o <tbody>: To indicate the main body of the table.
o <tfoot>: To create a separate table footer.
Example:
<!DOCTYPE html>
<html>
<head>
<title>Practice HTML table footer, header and body</title>
</head>
<body>
<p>Try with different footer, heard and body parts</p>
<table border="1" width="100%">
<thead>
<tr>
<td colspan="4">This is the head of the table</td>
</tr>
</thead>
<tfoot>
<tr>
<td colspan="4">This is the foot of the table</td>
</tr>
</tfoot>
<tbody>
<tr>
<td>Cell 1</td>
<td>Cell 2</td>
<td>Cell 3</td>
<td>Cell 4</td>
</tr>
<tr>
...more rows here containing four cells...
</tr>
</tbody>
1.31
Web Technologies - I Introduction to HTML, HTTP and PHP
<tbody>
<tr>
<td>Cell 1</td>
<td>Cell 2</td>
<td>Cell 3</td>
<td>Cell 4</td>
</tr>
<tr>
...more rows here containing four cells...
</tr>
</tbody>
</table>
</body>
</html>
Output:
• Cellspacing attribute defines the width of the border, while cellpadding attribute
represents the distance between cell borders and the content within.
Example for cellspacing and cellpadding:
<!DOCTYPE html>
<html>
<head>
<title>HTML Table Cellpadding</title>
</head>
<body>
<table border = "1" cellpadding = "10" cellspacing = "10">
<tr>
<th>Name</th>
<th>Salary</th>
</tr>
<tr>
1.32
Web Technologies - I Introduction to HTML, HTTP and PHP
<td>Ramesh Salvi</td>
<td>5000</td>
</tr>
<tr>
<td>Amar Dube</td>
<td>7000</td>
</tr>
</table>
</body>
</html>
Output:
• We will use colspan attribute if we want to merge two or more columns into a single
column. Similar way we will use rowspan if we want to merge two or more rows.
Example for colspan amd rowspan attributes:
<!DOCTYPE html>
<html>
<head>
<title>Practice HTML table spans</title>
</head>
<body>
<p>Merge two or more rows or columns and then see the result:</p>
<table border="1">
<tr>
<th>Column 1</th>
<th>Column 2</th>
<th>Column 3</th>
</tr>
<tr><td rowspan="2">Row 1 Cell 1</td>
<td>Row 1 Cell 2</td><td>Row 1 Cell 3</td></tr>
<tr><td>Row 2 Cell 2</td><td>Row 2 Cell 3</td></tr>
<tr><td colspan="3">Row 3 Cell 1</td></tr>
</table>
</body>
</html>
1.33
Web Technologies - I Introduction to HTML, HTTP and PHP
Output:
Nested Tables:
• We can use one table inside another table is called as nesting of tables (or nested
tables). Not only tables we can use almost all the tags inside table data tag <td>.
Example for nested tables:
<!DOCTYPE html>
<html>
<head>
<title>HTML Nested table</title>
</head>
<body>
<table border="1">
<tr>
<td>
<table border="1">
<tr>
<th>Name</th>
<th>Salary</th>
</tr>
<tr>
<td>Ramesh Salvi</td>
<td>5,700</td>
</tr>
<tr>
<td>Amar Dube</td>
<td>7,500</td>
</tr>
</table>
</td>
<td>
<ul>
<li>This is another cell</li>
<li>Using list inside this cell</li>
</ul>
1.34
Web Technologies - I Introduction to HTML, HTTP and PHP
</td>
</tr>
<tr>
<td>Row 2, Column 1</td>
<td>Row 2, Column 2</td>
</tr>
</table>
</body>
</html>
Output:
1.35
Web Technologies - I Introduction to HTML, HTTP and PHP
Attributes:
Attributes Value Description
1. accept file_type This attribute specifies a comma-separated
list of file types that the server accepts (that
can be submitted through the file upload).
2. accept-charset character_set This attribute specifies the character
encodings that are to be used for the form
submission.
3. action URL This attribute specifies where to send the
form-data when a form is submitted.
4. autocomplete on This attribute specifies whether a form
off should have autocomplete on or off.
5. enctype application/x- This attribute specifies how the form-data
www-form- should be encoded when submitting it to
urlencoded the server (only for method="post").
multipart/form-
data
text/plain
6. method get This attribute specifies the HTTP method to
post use when sending form-data.
7. name text This attribute specifies the name of a form.
8. novalidate novalidate This attribute specifies that the form should
not be validated when submitted.
9. target _blank This attribute specifies where to display the
_self response that is received after submitting
_parent the form.
_top Target to open the given URL:
_blank : The target URL will open in a new
window.
_self : The target URL will open in the
same frame as it was clicked.
_parent : The target URL will open in the
parent frameset.
_top : The target URL will open in the
full body of the window.
1.36
Web Technologies - I Introduction to HTML, HTTP and PHP
• Users interact with forms through named controls. A control's "control name" is given
by its name attribute. The <form> element can contain one or more of the form
elements: <input>, <textarea>, <button>, <select>, <option>, <fieldset>, <label> etc.
HTML <input> Tag:
• The most important form element is the <input> tag which defines an input control.
• The <input> tag are used within a <form> element to declare input controls that allow
users to input data. An input field can vary in many ways, depending on the type
attribute.
Syntax: <input type= " ">
Attributes:
Attributes Value Description
1. accept audio/* This attribute specifies the types of files that the
video/* server accepts (only for type="file").
image/*
MIME_type
2. align left This attribute specifies the alignment of an image
right input (only for type="image").
top
middle
bottom
3. alt text This attribute specifies an alternate text for an
image (only for type="image").
4. checked checked This attribute specifies that an <input> element
should be preselected when the page loads (for
type="checkbox" or type="radio").
5. disabled disabled This attribute specifies that an <input> element
should be disabled.
6. maxlength number This attribute specifies the maximum number of
characters allowed in an <input> element.
7. name name This attribute specifies the name of an <input>
element.
8. readonly readonly This attribute specifies that an input field should
be read-only.
9. size number This attribute specifies the width, in characters, of
an <input> element.
contd. …
1.37
Web Technologies - I Introduction to HTML, HTTP and PHP
10. src URL This attribute specifies the URL of the image to use
as a submit button (only for type="image").
11. type button This attribute specifies the type of <input> element.
checkbox
file
hidden
image
password
radio
reset
submit
text
2. Password Field: Password fields are similar to text fields. The difference is that what
is entered into a password field shows up a dot on the screen. This is, of course, to
prevent others from reading the password on the screen.
Syntax: <input type = "password">
Attribute Explanation
1. size= Characters shown.
2. maxlength= Max characters allowed.
3. name= Name of the field.
4. value= Initial value in the field.
5. align= Alignment of the field.
6. tabindex= Tab order of the field.
<div align="center">
Enter Password: <input type="password" size="25">
<br><br>
</div>
</form>
</body>
</html>
Output:
3. <label> Tag: The <label> tag defines a label for an <input> element.
4. <fieldset> Tag: <fieldset> tag defines a border around elements in a form. The
<fieldset> tag is used to group related elements in a form. The <fieldset> tag draws a
box around the related elements.
Attributes:
Attribute Value Description
1. disabled disabled This attribute specifies that a group of related form
elements should be disabled.
2. form form_id This attribute specifies one or more forms the field
set belongs to.
3. name text This attribute specifies a name for the field set.
Example for <fieldset> tag: The <legend> tag defines a caption for a <fieldset> element.
<!DOCTYPE html>
<html>
<body>
<form>
<fieldset>
<legend><b>User Information:</b></legend>
Name: <input type="text"><br>
Email: <input type="text"><br>
Date of birth: <input type="text">
</fieldset>
</form>
</body>
</html>
1.40
Web Technologies - I Introduction to HTML, HTTP and PHP
Output:
5. Hidden Field: Hidden fields are similar to text fields. The difference is that the hidden
field does not show on the page. Therefore the visitor cannot type anything into a
hidden field, which leads to the purpose of the field.
Syntax: <input typ = "hidden">
Attribute Explanation
6. <textarea> Tag: It defines a multi-line text input control. The size of a text area is
specified by the cols and rows attributes.
Syntax: <textarea>………</textarea>
1.41
Web Technologies - I Introduction to HTML, HTTP and PHP
7. Radio Buttons: Radio buttons are used when only one option is required to be
selected. They are created using <input> tag.
Syntax: <input type="radio">
Following is the list of important radiobox attributes:
(i) type: Indicates that you want to create a radiobox.
(ii) name: Name of the control.
(iii) value: Used to indicate the value that will be sent to the server if this option is
selected.
(iv) checked: Indicates that this option should be selected by default when the page
loads.
1.42
Web Technologies - I Introduction to HTML, HTTP and PHP
8. Checkbox Control: Checkboxes are used when more than one option is required to be
selected. They are created using <input> tag.
Syntax: <input type="checkbox">
Following is the list of important checkbox attributes:
(i) type: Indicates that you want to create a checkbox.
(ii) name: Name of the control.
(iii) value: The value that will be used if the checkbox is selected. More than one
checkbox should share the same name only if you want to allow users to select
several items from the same list.
(iv) checked: Indicates that when the page loads, the checkbox should be selected.
Example for checkboxes:
<!DOCTYPE html>
<html>
<head>
<title>Practice HTML input checkbox tag</title>
</head>
<body>
1.43
Web Technologies - I Introduction to HTML, HTTP and PHP
9. <select>Tag: The <select> tag is used to create a drop-down list. Drop-down list is used
when we have many options available to be selected but only one or two will be
selected. The <option> tags inside the <select> element define the available options in
the list.
Syntax: <select>…………</select>
Attributes Value Description
1. disabled disabled This attribute specifies that a drop-down list should
be disabled.
2. multiple multiple This attribute specifies that multiple options can be
selected at once.
3. name name This attribute defines a name for the drop-down
list.
4. size number This attribute specifies defines the number of
visible options in a drop-down list.
10. Creating Button: The <button> tag defines a push button. We can create clickable
button using <input> tag.
Syntax: <button>……………</button>
Attributes Value Description
1. disabled disabled This attribute specifies that a button should be
disabled.
2. name name This attribute specifies the name for a button.
3. type button This a3ttribute specifies the type of button. The
reset submit value creates a button that automatically
submit submits a form. The reset value creates a button
that automatically resets form controls to their
initial values. The button value creates a button that
is used to trigger a client-side script when the user
clicks that button.
4. value text This attribute specifies the initial value for a button.
Example for <button> tag:
<!DOCTYPE html>
<html>
<body>
<form name="input" action="html_form_action.asp" method="get">
First name: <input type="text" name="FirstName"
value="Mickey" /><br />
Last name: <input type="text" name="LastName" value="Mouse" /><br />
<input type="submit" value="Submit" />
</form>
<p>If you click the "Submit" button, the form-data will be sent
to a page called "html_form_action.asp".</p>
</body>
</html>
1.45
Web Technologies - I Introduction to HTML, HTTP and PHP
Output:
Example:
<!DOCTYPE html>
<html>
<body>
<form action="/cgi-bin/hello_get.cgi" method="get">
First name:
<input type="text" name="first_name" /><br>
Last name:
<input type="text" name="last_name" />
<input type="submit" value="Submit" />
<input type="reset" value="Reset" />
</form>
</body>
</html>
Output:
11. <option> Tag: It defines an option in a select list. The <option> tag go inside a <select>
element.
Syntax: <option>……………</option>
Attributes Value Description
1. disabled disabled This attribute specifies that an option should be
disabled.
2. label text This attribute specifies a shorter label for an
option.
3. selected selected This attribute specifies that an option should be
pre-selected when the page loads.
4. value text This attribute specifies the value to be sent to a
server.
Example for <option> tag:
<!DOCTYPE html>
<html>
<body>
<form name="myform" action="nextpage.html" method="post" >
1.46
Web Technologies - I Introduction to HTML, HTTP and PHP
</select><br><br>
<input type="submit" name="button" value="Submit data">
</form>
</body>
</html>
Output:
Fig. 1.6
• Various semantic elements in HTML5 are explained below:
1. HTML5 <article> Element:
• The <article> element is used to represent an article. The <article> element specifies
independent, self-contained content.
1.48
Web Technologies - I Introduction to HTML, HTTP and PHP
• Examples of article content could include a forum post, a newspaper article, a blog
entry, or a user-submitted comment.
Syntax: <article>…..</article>
1.49
Web Technologies - I Introduction to HTML, HTTP and PHP
<a href="/html/">Dreamweaver</a> |
<a href="/html/">Ajax</a> |
<a href="/jquery/">jQuery</a>
</nav>
<p><strong>Note:</strong> The nav tag is not supported in
Internet Explorer 8 and earlier versions.</p>
</body>
</html>
Output:
1.50
Web Technologies - I Introduction to HTML, HTTP and PHP
1.52
Web Technologies - I Introduction to HTML, HTTP and PHP
1.53
Web Technologies - I Introduction to HTML, HTTP and PHP
1.54
Web Technologies - I Introduction to HTML, HTTP and PHP
nav {
float: left;
width: 20%;
height: 200px;
background: #282828;
padding: 60px 10px;
}
nav ul {
list-style-type: none;
padding: 0;
}
nav ul li a {
text-decoration: none;
color: #fff;
}
article {
float: left;
padding: 80px 10px;
width: 80%;
background-color: #fff;
height: 200px;
text-align: center;
}
section:after {
content: "";
display: table;
clear: both;
}
footer {
background-color: #000;
padding: 20px;
text-align: center;
color: white;
}
</style>
<body>
<h1>HTML Semantics Demo</h1>
<header>This is Header</header>
1.55
Web Technologies - I Introduction to HTML, HTTP and PHP
<section>
<nav>
<ul>
<li><a href="#">Home</a></li>
<li><a href="#">About</a></li>
<li><a href="#">Contact</a></li>
</ul>
</nav>
<article>This is an article element.</article>
</section>
<footer>This is Footer</footer>
</body>
</html>
Output:
1.57
Web Technologies - I Introduction to HTML, HTTP and PHP
• The HTML <source> tag is used to specify multiple media resources on media elements
such as <audio> and <video>.
• The <object> tag defines an embedded object within an HTML document. Use this
element to embed multimedia (like audio, video, Java Aapplets, ActiveX, PDF, and
Flash) in the web pages.
• The HTML <audio> tag is used to specify audio on an HTML document.
Syntax: <audio>…</audio>
Attribute Value Description
1. autoplay autoplay This attribute specifies that the audio will start
playing as soon as it is ready.
2. controls controls This attribute specifies that audio controls should
be displayed (such as a play/pause button etc).
3. loop loop This attribute specifies that the audio will start over
again, every time it is finished.
4. muted muted This attribute specifies that the audio output should
be muted.
5. preload auto This attribute specifies if and how the author
metadata thinks the audio should be loaded when the page
none loads.
6. src URL This attribute specifies the URL of the audio file.
1.58
Web Technologies - I Introduction to HTML, HTTP and PHP
• The <video> tag is used to specify video on an HTML document. The <video> tag
specifies video, such as a movie clip or other video streams.
Syntax: <video>…</video>
Attributes:
Attribute Value Description
1. autoplay autoplay This attribute specifies that the video will start
playing as soon as it is ready.
2. controls controls This attribute specifies that video controls
should be displayed (such as a play/pause
button etc).
3. height pixels This attribute sets the height of the video
player.
4. loop loop This attribute specifies that the video will start
over again, every time it is finished.
5. muted muted This attribute specifies that the audio output of
the video should be muted.
6. poster URL This attribute specifies an image to be shown
while the video is downloading, or until the
user hits the play button.
7. preload auto This attribute specifies if and how the author
metadata thinks the video should be loaded when the
none page loads.
8. src URL This attribute specifies the URL of the video
file.
9. width pixels This attribute sets the width of the video
player.
Example for <video> tag:
<!DOCTYPE html>
<html>
<body>
<video width="320" height="240" controls>
<source src="movie.mp4" type="video/mp4">
<source src="movie.ogg" type="video/ogg">
Your browser does not support the video tag.
</video>
<p><strong>Note:</strong> The video tag is not supported in Internet
Explorer 8 and earlier versions.</p>
</body>
</html>
1.59
Web Technologies - I Introduction to HTML, HTTP and PHP
Output:
1.60
Web Technologies - I Introduction to HTML, HTTP and PHP
Fig. 1.7
Syntax of CSS: selector { property: value }
Example: We can define a table border as follows:
table{ border:1px solid #C00; }
Here, table is a selector and border is a property and given value 1px solid #C00 is the
value of that property. We can define selectors in various simple ways based on our
comfort.
• CSS selectors are used to "find" (or select) the HTML elements we want to style. Let us
see these selectors one by one.
1. Type Selectors: A type selector sometimes referred to as an element selector
selects HTML elements based on the element name such as <p>, <h1>, <div> and so
on. The example to give a color to all level 1 headings like this:
h1 {
color: #36CFFF;
}
1.61
Web Technologies - I Introduction to HTML, HTTP and PHP
This rule renders the content in black for every element with id attribute set 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 above example all level 2 headings will be displayed in black color only when
those headings will lie within tags having id attribute set to black.
6. Child Selectors: The child selector selects all elements that are the children of a
specified element. Consider the following example:
body > p {
color: #000000;
}
This rule will render all the paragraphs in black if they are direct child of <body>
element. Other paragraphs put inside other elements like <div> or <td> etc. would
not have any effect of this rule.
7. Attribute Selectors: We can also apply styles to HTML elements with particular
attributes. The attribute selector is used to select elements with a specified
attribute or attribute value. The style rule below will match all input elements that
have a type attribute with a value of text:
input[type="text"]{
color: #000000;
}
The advantage to this method is that the <input type="submit" /> element is
unaffected, and the color applied only to the desired text fields.
There are following rules applied to attribute selector.
o p[lang]: Selects all paragraph elements with a lang attribute.
o p[lang="fr"]: Selects all paragraph elements whose lang attribute has a value
of exactly "fr".
o p[lang~="fr"]: Selects all paragraph elements whose lang attribute contains
the word "fr".
o p[lang|="en"]: Selects all paragraph elements whose lang attribute contains
values that are exactly "en", or begin with "en-".
1.63
Web Technologies - I Introduction to HTML, HTTP and PHP
Multiple Style Rules: We may need to define multiple style rules for a single
element. We can define these rules to combine multiple properties and
corresponding values into a single block as defined in the following example:
h1
{
color: #36C;
font-weight: normal;
letter-spacing: .4em;
margin-bottom: 1em;
text-transform: lowercase;
}
Here, all the property and value pairs are separated by a semi colon (;). We can
keep them in a single line or multiple lines.
For better readability we keep them into separate lines. For a while do not bother
about the properties mentioned in the above block.
8. Grouping Selectors: The grouping selector selects all the HTML elements with the
same style definitions. We can apply a style to many selectors if we like. Just
separate the selectors with a comma as given in the following example:
h1, h2, h3 {
color: #36C;
font-weight: normal;
letter-spacing: .4em;
margin-bottom: 1em;
text-transform: lowercase;
}
This define style rule will be applicable to h1, h2 and h3 element as well. The order
of the list is irrelevant. All the elements in the selector will have the corresponding
declarations applied to them.
We can combine various class selectors together as shown below:
#content, #footer, #supplement {
position: absolute;
left: 510px;
width: 200px;
}
1.64
Web Technologies - I Introduction to HTML, HTTP and PHP
3. External CSS:
• An external style sheet is ideal when the style is applied to many pages. With an
external style sheet, we change the look of an entire web site by changing one file.
1.66
Web Technologies - I Introduction to HTML, HTTP and PHP
• External CSS contains only CSS code and is saved with a ".css" file extension. This CSS
file is referred from HTML file using the <link> tag.
• To use an external style sheet, add a <link> tag in the <head> section of each HTML
page.
CSS Code:
p {
text-align: center;
color: white;
}
body {
background-color: green;
}
• Save the above file as sample.css
HTML Code:
<!DOCTYPE html>
<html>
<head>
<link rel="stylesheet" type="text/css" href="sample.css" />
</head>
<body>
<p> This is an example for inserting CSS externally. </p>
</body>
</html>
Output:
o Padding is the second inner most box, sits outside of the content area. The padding
is the space between the content area box and the border box of the HTML
element. The size of padding box can be controlled using padding and related
properties.
o Border is the second outer most box sits inside the margin, and surrounds the
padding and content of the HTML element. The border box wraps the content and
any padding. Its size and style can be controlled using border and related
properties.
o Margin is the outermost box that consists of transparent space outside of the
border of an element. The margin box wrapping the content, padding and border
as whitespace between this box and other elements. Its size can be controlled
using margin and related properties.
Margin
Border
Padding
Content
CSS Text Properties: Defines how to manipulate text using CSS properties.
1. The color property is used to set the color of a text.
2. The direction property is used to set the text direction.
3. The letter-spacing property is used to add or subtract space between the letters
that make up a word.
4. The word-spacing property is used to add or subtract space between the words of
a sentence.
5. The text-indent property is used to indent the text of a paragraph.
6. The text-align property is used to align the text of a document.
7. The text-decoration property is used to underline, overline, and strikethrough
text.
8. The text-transform property is used to capitalize text or convert text to uppercase
or lowercase letters.
9. The white-space property is used to control the flow and formatting of text.
10. The text-shadow property is used to set the text shadow around a text.
CSS Font Properties: Defines how to set fonts of a content, available in an HTML element.
1. The font-family property is used to change the face of a font.
2. The font-style property is used to make a font italic or oblique.
3. The font-variant property is used to create a small-caps effect.
4. The font-weight property is used to increase or decrease how bold or light a font
appears.
5. The font-size property is used to increase or decrease the size of a font.
6. The font property is used as shorthand to specify a number of other font
properties.
CSS Background Properties: Defines how to set backgrounds of various HTML elements.
1. The background-color property is used to set the background color of an element.
2. The background-image property is used to set the background image of an
element.
3. The background-repeat property is used to control the repetition of an image in
the background.
4. The background-position property is used to control the position of an image in
the background.
5. The background-attachment property is used to control the scrolling of an image
in the background.
6. The background property is used as a shorthand to specify a number of other
background properties.
1.69
Web Technologies - I Introduction to HTML, HTTP and PHP
CSS Border Properties: The border properties allow you to specify how the border of the
box representing an element should look.
1. The border-color specifies the color of a border.
2. The border-style specifies whether a border should be solid, dashed line, double
line, or one of the other possible values.
3. The border-width specifies the width of a border.
CSS Margin Properties: Defines the space around an HTML element.
1. The margin specifies a shorthand property for setting the margin properties in
one declaration.
2. The margin-bottom specifies the bottom margin of an element.
3. The margin-top specifies the top margin of an element.
4. The margin-left specifies the left margin of an element.
5. The margin-right specifies the right margin of an element.
CSS Link Properties: Defines how to set different properties of a hyper link using CSS.
1. The :link signifies unvisited hyperlinks.
2. The :visited signifies visited hyperlinks.
3. The :hover signifies an element that currently has the user's mouse pointer
hovering over it.
4. The :active signifies an element on which the user is currently clicking.
CSS List Properties: Defines how to control list type, position, style, etc., using CSS.
1. The list-style-type allows us to control the shape or appearance of the marker.
2. The list-style-position specifies whether a long point that wraps to a second line
should align with the first line or start underneath the start of the marker.
3. The list-style-image specifies an image for the marker rather than a bullet point
or number.
4. The list-style serves as shorthand for the preceding properties.
5. The marker-offset specifies the distance between a marker and the text in the list.
CSS Table Properties: Defines how to set different properties of an HTML table using
CSS.
1. 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.
2. The border-spacing specifies the width that should appear between table cells.
3. The caption-side captions are presented in the <caption> element. By default,
these are rendered above the table in the document. We use the caption-
side property to control the placement of the table caption.
4. The empty-cells specifies whether the border should be shown if a cell is empty.
5. The table-layout allows browsers to speed up layout of a table by using the first
width properties it comes across for the rest of a column rather than having to
load the whole table before rendering it.
1.70
Web Technologies - I Introduction to HTML, HTTP and PHP
li {
float: left;
}
li a {
display: block;
padding: 8px;
background-color: #dddddd;
}
</style>
</head>
<body>
<ul>
1.71
Web Technologies - I Introduction to HTML, HTTP and PHP
<li><a href="d:\Ty\home.html">Home</a></li>
<li><a href="d:\Ty\news.html">News</a></li>
<li><a href="d:\Ty\contact.html">Contact</a></li>
<li><a href=""d:\Ty\About.html">About</a></li>
</ul>
<p> PDEAs A.M. College </p>
<p>A background color is added to the links to show the link
area. The whole link area is clickable, not just the text.</p>
</body>
</html>
Output:
• In above example the, list-style-type: none; - Removes the bullets. A navigation bar
does not need list markers. Set margin: 0; and padding: 0; to remove browser default
settings.
• The web is a collection of files known as web pages. These web pages (or web site)
reside on a computer known as a web server.
• A web server interacts with the client through the web browser and processes
requests, sent by the client.
• The primary function of a web server is to store, process and deliver web pages to
clients.
1.72
Web Technologies - I Introduction to HTML, HTTP and PHP
• The function of a typical Web server is shown in Fig. 1.9. The communication between
client and server takes place using the HyperText Transfer Protocol (HTTP).
• To view a website, the browser sends a request to the server. On receiving the request,
the server sends (response) the appropriate web page to the client's machine.
• The client's machine (browser) receives the web page and displays onto the user's
computer screen.
• To view Web pages, we need a Web browser which is a software program that
requests, downloads and displays Web pages stored on a Web server.
• Web browser used to access the Internet and the WWW. It is basically used to access
and view the web pages of the various websites available on the Internet.
• A Web browser (a browser) is application software for retrieving, presenting, and
traversing information resources on the Internet and World Wide Web (WWW).
1.73
Web Technologies - I Introduction to HTML, HTTP and PHP
• A browser can be defined as, "a software used to locate, retrieve and display content
on the Internet and World Wide Web, including web pages, images, audio, video and
other files".
• Browsers are of two types as explained below:
1. Graphical Browsers: These browsers allow retrieval of text, images, audio, and
video. Navigation is accomplished by pointing and clicking with a mouse on
highlighted words and graphics. Both Netscape Navigator and Internet Explorer
are graphical browsers.
2. Text Browsers: These browsers provide access to the web in text-only mode.
Navigation is accomplished by highlighting emphasized words on the screen with
the arrow up and down keys, and then pressing the Enter key to follow the link.
Lynx is an example of text-based browser.
• Web browser is application software that allows us to view and explore information
on the web. Common and popular Web Browsers are explained below:
1. Opera ( ): Opera is a web browser developed by Opera Software. The latest
version is available for Windows, macOS, and Linux operating systems. Opera is a
fast and secure browser.
2. Internet Explorer ( ): Internet Explorer (IE) is a web browser from Microsoft. IE
was released as the default browser with Windows 95 (1995). Internet Explorer
connects your computer to the Web through an Internet connection. The browser
lets you view, print, and search for information on the Web.
3. Mozilla Firefox ( ): Firefox is a free and open source web browser developed
for Microsoft Windows, Mac OS X, and Linux (with its mobile versions available
for Android, and Firefox OS) co-ordinated by Mozilla Corporation and Mozilla
Foundation.
4. Safari ( ): Safari is web browser that was produced and developed by Apple
Inc. which functions on a Mac OX, iOS, and Windows operating system.
5. Google Chrome ( ): Google Chrome is a freeware browser developed by Google
using the WebKit layout engine.
Differences between Web Browser and Web Server:
Sr.
Web Browser Web Server
No.
1. Web browser is software which is Web server is a software which
used to browse and display web pages provides the documents when
available over the internet. requested by web browsers.
2. A web browser sends request to Web server sees and approves those
server for web based documents. requests made by web browsers and
sends the document in response.
contd. …
1.74
Web Technologies - I Introduction to HTML, HTTP and PHP
Client Server
Time Client Request
Method URI HTTP-version
General-header
Request-header
Entity-header
Entity-body
Server Response
HTTP-version Status-code Reason-Phrase
General-header
Respons-header
Entity-header
Entity-body
1.75
Web Technologies - I Introduction to HTML, HTTP and PHP
• The HTTP protocol is based on the client-server based architecture where Web
browsers act as clients and the Web server acts as a server.
• The Client (also called as HTTP client) and server (also called as HTTP server)
communicate by sending messages.
• The client sends a request message (also called as HTTP Request) to the server. The
server, in turn, returns a response message (also called as HTTP Response).
• Fig. 1.10 shows the HTTP transaction (request and response) between the client and
server.
HTTP Messages:
• HTTP message is used to show how data is exchanged between the client and the
server. It is based on client-server architecture.
• An HTTP client is a program that establishes a connection to a server to send one or
more HTTP request messages.
• An HTTP server is a program that accepts connections to serve HTTP requests by
sending an HTTP response messages.
• HTTP messages are simple, line-oriented sequences of characters. There are two types
of HTTP messages i.e. request message and response message.
• The HTTP messages sent from web clients to web servers are called request messages
while the messages from servers to clients are called response messages.
• The formats of the request and response messages are shown in Fig. 1.11.
Headers Headers
Body Body
(present only in (present only in
some messages) some messages)
Request Headers: The HTTP Request Header contains optional header information
sent by the client like MIME type the browser accepts, information about the web
browser etc.
For example: Accept: image/gif, image/jpeg, text/*, */*
Accept-Language: en-us
Host: www.example.com
User-Agent: Mozilla (x11; I; Linux 2.0.32 i586)
After header the HTTP request contains a blank line which indicates the end of the
header section.
Request Body: In case of GET method the HTTP request body is empty, and with the
POST method it contains additional data. Message body is optimal in HTTP request.
2. HTTP Response Message: The web server receives the request from client, processes
it and sends a response back to the client browser through Response message.
Status Line: The first line is called status line which looks like this:
HTTP/1.1 200 OK
This line specifies the protocol version, a status code, and a description of that code. In
this case, the status code is “200”, meaning that the request was successful (hence the
description “OK”).
Response Headers: The response header gives client additional information about
the response like information about the web server software, MIME type of the data
included in the response etc.
For example: Date: Sat, 26 Jan 2002 20:25:12 GMT
Server: Apache 1.3.22 (Unix) mod_perl/1.26 PHP/4.1.0
Content-Type: text/html
Content-Length: 141
After header the HTTP request contains a blank line which indicates the end of the
header section.
Response Body: If the response was successful, the HTTP response body contains the
HTML code, ready for the browser interpretation. If unsuccessful, a failure code is
sent.
Example for HTTP Request Message and HTTP Response Message: HTTP request to
fetch hello.htm page from the web server running on niraliprakashan.com. The HTML
code given below:
<html>
<body>
<h1>Hello, World!</h1>
</body>
</html>
1.77
Web Technologies - I Introduction to HTML, HTTP and PHP
Client Request:
GET /hello.htm HTTP/1.1
User-Agent: Mozilla/4.0 (compatible; MSIE5.01; Windows NT)
Host: www.niraliprakashan.com
Accept-Language: en-us
Accept-Encoding: gzip, deflate
Connection: Keep-Alive
Server Response:
HTTP/1.1 200 OK
Date: Mon, 27 Jul 2009 12:28:53 GMT
Server: Apache/2.2.14 (Win32)
Last-Modified: Wed, 22 Jul 2009 19:15:56 GMT
Content-Length: 88
Content-Type: text/html
Connection: Closed
• PHP is a server side scripting language which is used to create dynamic and
interactive web pages.
• A script is a set of programming instructions that is interpreted at runtime. A scripting
language is a language that interprets scripts at runtime.
• Server side scripts are interpreted on the server while client side scripts are
interpreted by the client.
• PHP is a server side script that is interpreted on the server while JavaScript is an
example of a client side script that is interpreted by the client browser.
• PHP is a recursive acronym for "PHP: Hypertext Preprocessor". PHP is an open-source,
interpreted, and object-oriented scripting language that can be executed at the
server-side.
• PHP files can contain text, HTML, CSS, JavaScript, and PHP code. PHP codes are
executed on the server, and the result is returned to the browser as plain HTML. PHP
files have extension ".php".
• PHP 7 is a major release of PHP programming language in 2015 and is touted to be a
revolution in the way web applications can be developed and delivered for mobile to
enterprises and the cloud.
• The latest version of PHP is PHP 8 was released on November 26, 2020. Facebook,
Flickr and Yahoo are the examples of PHP applications.
• PHP is a server side scripting language that is embedded in HTML. It is used to manage
dynamic content, databases, session tracking, even build entire e-commerce sites.
1.78
Web Technologies - I Introduction to HTML, HTTP and PHP
File
Yes contains
PHP
scripts?
3. Existing Libraries Support: Lot of functions for common web development task
e.g. Sending E-mail, XML parsing etc.
4. Portability: PHP support on all major operating system like Windows, Mac OS,
Linux etc. A PHP application developed in one operating system can be easily
executed in other operating system also.
5. Simplicity: In PHP there is no need to include libraries, special compilation
directives, or anything of the sort.
6. Efficiency: PHP is efficient in a multiuser environment such as the WWW. PHP
also support object-oriented programming with similar syntax and feature as C++
and Java.
7. Flexibility: Because PHP is an embedded language, it is extremely flexible towards
meeting the needs of the developer. PHP code can be easily embedded within
HTML tags and script.
8. Familiarity: In PHP many of the language’s constructs are borrowed from C and
Perl. PHP has easily understandable syntax. Programmers are comfortable coding
with it.
9. Security: PHP is a secure scripting language to develop the website. It consists of
multiple layers of security to prevent threads and malicious attacks.
10. Open Source: PHP source code and software are freely available on the web.
Anyone can develop all the versions of PHP according to his/her requirement
without paying any cost.
<?php
echo "Hello PHP";
?>
</body>
</html>
Output:
1.6.4 Comments
• Comments give information to people who read the code, but they are not interpreted
by PHP engine.
• Comments in PHP programming language is used to describe code and make simple to
understand other programmer/users and it is ignore by compiler or interpreter.
• PHP supports 'C', 'C++' and Unix shell-style (Perl style) comments.
1.83
Web Technologies - I Introduction to HTML, HTTP and PHP
For example:
<?php
echo 'This is a test'; // This is a one-line C++ style comment
# Shell-style comment
/* This is a multi line comment.
This is a C style comment.
Yet another line of comment */
echo 'This is yet another test';
echo 'One Final Test'; # This is a one-line shell-style comment
?>
• When PHP encounters two slash characters (//) within the code, everything from the
slashes to the end of the line or the end of the section of code, whichever comes first, is
considered a comment. This method of commenting is derived from C++. The result is
the same as the shell comment style.
• PHP supports block comments, whose syntax comes from the C programming
language.
• When PHP encounters a slash followed by an asterisk (/*), everything after that until it
encounters an asterisk followed by a slash (*/) is considered a comment.
• When PHP encounters a hash mark (#) within the code, everything from the hash
mark to the end of the line or the end of the section of PHP code (whichever comes
first) is considered a shell-style comment.
• The shell-style comment is found in Unix shell scripting languages and is useful for
annotating single lines of code or making short notes.
1.6.5 Literals
• A literal is a data value in PHP that appears directly in a program.
• For example:
“Hello”
100
true
null
1.6.6 Identifiers
• An identifier is simply a name. In PHP, identifiers are used to name variables,
functions, constants, and classes.
• The first character of an identifier must be an ASCII letter (a-z, A-Z), the underscore
character (_) or any character between ASCII Ox7F and ASCII OxFF. After the initial
character, combinations of these previous characters and the digits 0-9 are valid.
1.84
Web Technologies - I Introduction to HTML, HTTP and PHP
1. Variable Names: Variables in PHP starts with a dollar sign ($). The variable name
is case sensitive.
Valid Variable Names:
$bill
$bill_amt
$GrossSal
$_underscore
Invalid Variable Names:
$not valid
$7X
Following valid variables are all different:
$Net_sal
$net_sal
$net_sal
$NET_SAL
2. Function Names: Function names are not case sensitive. And so following
function names refer to the same function:
For example: howdy(), Howdy(), HOWDY(), HOWdy()
3. Class Names: Class names follow the standard rules for PHP identifiers and are
not case sensitive.
For example,
person or Person is same
Account or Account is same
1.6.7 Constants [April 18]
• A constant is a name or an identifier for a simple value. A constant value cannot
change during the execution of the PHP script.
• A constant is case-sensitive by default. By convention, constant identifiers are always
uppercase. Only single values i.e. scalars can be constants, like Boolean, integer,
double, string etc.
• In PHP we use the define() function to create a constant. It defines constant at run
time.
Syntax: define("constant_Name", Value)
For example,
define(‘PI’, 3.14);
echo PI;
• In PHP the const keyword also defines constants at compile time. It is a language
construct not a function. It is always case sensitive.
1.85
Web Technologies - I Introduction to HTML, HTTP and PHP
For example,
<?php
const MESSAGE="Hello const by PHP";
echo MESSAGE;
?>
• Words reserved by the language for its core functionality are called as keyword or
reserved word.
• In PHP, keywords are case insensitive. A keyword is a word reserved by the language
for its core functionality - we cannot give a variable, function, class, or constant the
same name as a keyword.
• Some examples of keywords in PHP are given below:
break exception new
case while or
catch endwhile public
class exit( ) static
do function switch
for if throw
endfor else try
extends elseif var
• A data type is defined as "a set of values and the allowable operations on those values".
The data type determines the operations that we can perform on it.
• PHP data types are used to hold different types of data or values. PHP data types
define the type of data a variable can store.
1.86
Web Technologies - I Introduction to HTML, HTTP and PHP
• PHP supports eight primitive types as shown in Fig. 1.13 and given below:
o Four scalar data types: integer, float (floating-point number, aka double), string,
and Boolean.
o Two compound data types: array and object.
o Two special data types: resource and NULL.
Data Types
String
Boolean
1.87
Web Technologies - I Introduction to HTML, HTTP and PHP
1.88
Web Technologies - I Introduction to HTML, HTTP and PHP
1.89
Web Technologies - I Introduction to HTML, HTTP and PHP
For example:
class Person
{
public $name = ‘ ‘;
function name ($newname)
{
$this → name = $newname;
}
}
$p = new Person();
$p->name(“Amar”);
echo “Hello $p->name”;
Output:
Hello Amar
• Use is_object() to test whether a value is an object.
if(is_object($x))
{
// $x is an object
}
7. Resource: [April 16]
• The resource is a special PHP data type that refers to external resource (e.g. file, image
etc.) which is not part of the PHP native language.
• It is basically used for dealing with the outside world. Resources are created and used
by special functions.
• For example, database connection function returns a resource which is used to
identify that connection when we call the query and close functions.
• Their main benefit is that they’re garbage collected when no longer in use. When the
last reference to a resource value goes away, the extension that created the resource is
called to free any memory, close any connection, etc. for that resource.
For example,
$result = database_connect( );
database_query ($result);
$result=”something”; // connection is closed.
• Use the is_resource( ) function to test whether a value is a resource:
if (is_resource($x))
{
// $x is a resource
}
1.90