0% found this document useful (0 votes)
20 views22 pages

UNIT - 3 Ip

Uploaded by

uniqueguy824
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
20 views22 pages

UNIT - 3 Ip

Uploaded by

uniqueguy824
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 22

BCA - IInd Yr

Internet Programming

Unit - III
HTML

Aman Choudhary Student (BCA-II) Seth G. L. Bihani S. D. PG College


HTML stands for Hyper Text Markup Language, which is the most widely used language on Web to
develop web pages. HTML was created by Berners-Lee in late 1991 but "HTML 2.0" was the first standard
HTML specification which was published in 1995.

An HTML file is a text file, so to create an HTML file any text editor can be used. There are various text
editors available such as Notepad, Notepad++, Sublime Text, Vim, etc. After writing the code in a text editor,
the HTML file is saved with the extension .htm or .html.

Features of HTML
1) It is a very easy and simple language. It can be easily understood and modified.

2) It is very easy to make an effective presentation with HTML because it has a lot of formatting tags.

3) It is a markup language, so it provides a flexible way to design web pages along with the text.

4) It facilitates programmers to add a link on the web pages (by html anchor tag), so it enhances the
interest of browsing of the user.

5) It is platform-independent because it can be displayed on any platform like Windows, Linux, and
Macintosh, etc.

6) It facilitates the programmer to add Graphics, Videos, and Sound to the web pages which makes it
more attractive and interactive.

7) HTML is a case-insensitive language, which means we can use tags either in lower-case or uppercase.

HTML Tags
HTML tags are like keywords which define that how web browser will format and display the content. With
the help of tags, a web browser can distinguish between an HTML content and a simple content. These tags are
enclosed within angle braces <Tag Name>.

There are two types of HTML Tags:

Container Tags: Container tag is that tag which includes both opening and closing tag. The start or
opening tag is simply a tag name enclosed in angled brackets whereas the end or closing tag is
identified by including a forward slash (/) before the tag name in angled brackets. For Example:
<B>…………….</B>
<P>……………..</P> Empty Tags: Empty
tag is tag without content or a closing tag.
For Example:
<Br>
<Hr>

Aman Choudhary Student (BCA-II) Seth G. L. Bihani S. D. PG College


HTML Elements
An HTML file is made of elements. These elements are responsible for creating web pages and define content
in that webpage. An element in HTML usually consist of a start tag <tag name>, close tag </tag name> and
content inserted between them.

For Example:

<B> Welcome to HTML </B>

<P> Hello World!!! </P>

HTML Attributes
An attribute is used to define the characteristics of an HTML element and is placed inside the element's
opening tag. All attributes are made up of two parts − a name and a value like name = “value”.

Syntax:

<element attribute_name="value"> content </element>

For Example:

<p align = "left" > This is left aligned </p>

<a href="https://www.yahoo.com"> Visit Yahoo </a>


Structure of HTML Document
HTML is a simple and a powerful language used to define the structure of HTML documents. It allows
formatting text, images and saving it as text only files that all the computers understand. HTML documents
are logically organized into series of elements that are arranged according to the rules of SGML (Standard
Generalized Markup Language). The basic HTML document structure is as follows:

<html>

Aman Choudhary Student (BCA-II) Seth G. L. Bihani S. D. PG College


<head>
Document header related tags
</head>

<body>
Document body related tags
</body>

</html>

HTML document uses the following tags −


Sr.No Tag & Description

<html>
It specifies the document as a webpage that can be seen in the web browser. The
1 entire document is enclosed within <html> and </html> tags. It actually tells the
web browser where the page starts and where it ends. It usually consists of two parts
HEAD and BODY.

<head>
This tag represents the document's header which can keep other HTML tags like
2
<title>, <link> etc.

<title>
3 The <title> tag is used inside the <head> tag to mention the document title.

<body>
This tag contains the actual contents of HTML document that can be seen by the
4 end user. This tag represents the document's body which keeps other HTML tags
like <h1>, <div>, <p> etc.

For Example:

<html>
<head>
<title>Web page title</title>
</head> <body>

Aman Choudhary Student (BCA-II) Seth G. L. Bihani S. D. PG College


<h1>Write Your First Heading</h1>
<p>Write Your First Paragraph.</p>
</body>
</html>

HTML Comments:
Comment is a piece of code which is ignored by any web browser. Comments of any code make code easy to
understand and increase readability of code.

HTML comments are placed in between <!-- ... --> tags. So, any content placed with-in <!-- ... --> tags will
be treated as comment and will be completely ignored by the browser.

Syntax:

<!- - write commented text here - ->

For Example:

<html>
<!- - This is header Section - ->
<head>
<title>Web page title</title>
</head> <body>
<!- - This is body Section - ->
<h1>Write Your First Heading</h1>
<p>Write Your First Paragraph. </p>
</body>
</html>

HTML Headings:
A HTML heading can be defined as a title or a subtitle which user want to display on the webpage. There are
six different HTML headings which are defined with the <h1> to <h6> tags. <h1> is the largest heading tag
and <h6> is the smallest one. So <h1> is used for most important heading and <h6> is used for least important.

Attribute:

ALIGN = LEFT/RIGHT/CENTER

For Example:

<html>
Aman Choudhary Student (BCA-II) Seth G. L. Bihani S. D. PG College
<head>
<title>Heading Example</title>
</head>

<body>
<h1>This is heading 1</h1>
<h2 align = “right”>This is heading 2</h2>
<h3>This is heading 3</h3>
<h4 align = “center”>This is heading 4</h4>
<h5>This is heading 5</h5>
<h6>This is heading 6</h6>
</body>
</html>

HTML Paragraph:
HTML paragraph tag is used to define a paragraph in a webpage. An HTML <p> tag indicates starting of new
paragraph.

Attribute:

ALIGN = LEFT/RIGHT/CENTER/JUSTIFY

For Example:

<html>
<head>
<title>Paragraph Example</title>
</head>

<body>
<h1>First Paragraph</h1>
<p align = “right”> Dreams and hopes are what drive us in life
and there is a world where dreams are sold. </p>
</body>
</html>

Formatting Text
HTML Formatting is a process of formatting text for better look and feel. HTML provides the facility to
format text without using CSS. There are many formatting tags in HTML. These tags are used to make text

Aman Choudhary Student (BCA-II) Seth G. L. Bihani S. D. PG College


bold, italicized, or underlined. The formatting can be applied on some words, single word or even a single
character in a sentence on a webpage.

In HTML the formatting tags are divided into two categories:

o Physical tag: These tags are used to provide the visual appearance to the text. o
Logical tag: These tags are used to add some logical or semantic value to the text.

Following is the list of HTML formatting tags

• Bold Text: The <B> tag is used to make a text bold.

Syntax:
<B> text </B>
Example:
<B> Hello World!!! </B>

Underline Text: The <U> tag is used to underline any text.

Syntax:
<U> text </U>
Example:
<U><B> Hello World!!! </B></U>

• Italic Text: The <I> tag is used to make a text Italicize.

Syntax:
<I> text </I>
Example:
<I> Hello World!!! </I>
Similarly
Element name Description
<strong> This is a logical tag, which tells the browser that the text is important.
<em> This is a logical tag which is used to display content in italic.
<tt> This tag is used to appear a text in teletype.
<strike> This tag is used to draw a strikethrough on a section of text.
<sup> It displays the content slightly above the normal line.
<sub> It displays the content slightly below the normal line.
This tag is used to display the deleted content. Browsers will usually
<del>
strike a line through deleted text.
Aman Choudhary Student (BCA-II) Seth G. L. Bihani S. D. PG College
This tag displays the content which is added. Browsers will usually
<ins>
underline inserted text.
<big> This tag is used to increase the font size by one conventional unit.
<small> This tag is used to decrease the font size by one unit from base font size.

Images
HTML <img> tag is used to display image on the web page. HTML img tag is an empty tag that contains
attributes only, closing tags are not used in HTML image element. Following is the simple syntax to use this
tag.
<img src = "Image URL" ... attributes-list>

Attributes of <img> tag

• Src : It is a necessary attribute that describes the source or path of the image. It instructs the
browser where to look for the image on the server.

• Alt : The alt attribute defines an alternate text for the image, if it can't be displayed. The
value of the alt attribute describe the image in words.

• Width : It is an optional attribute which is used to specify the width to display the image.

• Height : It is an optional attribute which is used to specify the height to display the image.

Example

<html>

<head>
<title> Using Image in Webpage </title>
</head>

<body>
<p>Simple Image Insert</p>
<img src = "/html/images/test.png" alt = "Test Image" Height=”150”>
</body>

</html>

HTML <span> tag


HTML <span> tag is used as a generic container of inline elements. It is used for styling purpose to the grouped
inline elements (using class and id attribute or inline style).

Aman Choudhary Student (BCA-II) Seth G. L. Bihani S. D. PG College


The <span> tag can be useful for the following task:

o To change the language of a part of the text.


o To change the color, font, background of a part of text using CSS o To apply
the scripts to the particular part of the text.

Syntax
<span>Write your content here......</span>

Example

<html>
<head>
<title>Span Tag</title>
</head> <body>
<h2>Example of span tag</h2>
<p>I have choosen only
<span style="color: red;">red</span>,
<span style="color: blue;">blue</span>, and
<span style="color: green;">green</span> colors for my painting.
</p>
</body>
</html>

HTML <div> tag


The HTML <div> tag is used to group the large section of HTML elements together. The div tag is generally
used by web developers to group HTML elements together and apply CSS styles to many elements at once.
Example

<div style="border:1px solid pink;padding:20px;font-size:20px">


<p>Welcome to Computer Department, Here you get latest technologies.</p>
<p>This is second paragraph</p> </div>

HTML <pre> tag


The <pre> tag defines preformatted text.

Text in a <pre> element is displayed in a fixed-width font, and the text preserves both spaces and line breaks.
The text will be displayed exactly as written in the HTML source code.

Example
<html>
Aman Choudhary Student (BCA-II) Seth G. L. Bihani S. D. PG College
<head>
<title>HTML pre Tag</title>
</head>

<body>
<pre>
This text is
in a fixed-pitch
font, and it preserves
both spaces and line breaks
</pre>
</body>
</html>

Hyperlink
A webpage can contain various links that take you directly to other pages and even specific parts of a given
page. These links are known as hyperlinks.
Hyperlinks allow visitors to navigate between Web sites by clicking on words, phrases, and images.
The <a> tag defines a hyperlink, which is used to link from one page to another. This tag is called anchor tag
and anything between the opening <a> tag and the closing </a> tag becomes part of the link

The most important attribute of the <a> element is the href attribute, which indicates the link's destination.

Syntax

<a href = "Document URL" ... attributes-list> Link Text </a>

Example
<html>

<head>
<title>Hyperlink Example</title>
</head>

<body>
<p>Click following link</p>

<a href = "https://www.yahoo.com"> YAHOO </a>


</body>
</html>

Aman Choudhary Student (BCA-II) Seth G. L. Bihani S. D. PG College


LIST
HTML lists allow web developers to group a set of related items in lists. All lists must contain one or more
list elements. Lists may contain −
• <ul> − An unordered list. This will list items using plain bullets.
• <ol> − An ordered list. This will use different schemes of numbers to list items.
• <dl> − A definition list. This arranges items in the same way as they are arranged in a dictionary.

HTML Unordered Lists


An unordered list is a collection of related items that have no special order or sequence. This list is created by
using HTML <ul> tag. Each item in the list is marked with a bullet.

Attribute:
Type : This attribute is used in <ul> tag to specify the type of bullet shown in front of list
items. By default, it is a disc. Following are the possible options – Square, Disc, Circle.

Example:

<html>
<head>
<title> HTML Unordered List </title>
</head>
<body>
<ul type = “square”>
<li>Beetroot</li>
<li>Ginger</li>
<li>Potato</li>
<li>Radish</li>
</ul>
</body>
</html>
HTML Ordered Lists
In ordered lists the list items are displayed in a numbered list instead of bulleted. This list is created by using
<ol> tag. The numbering starts at one and is incremented by one for each successive ordered list element
tagged with <li>.

Attribute:
Type : This attribute is used in <ul> tag to specify the type of number shown in front of list items. By
default, it is a number. Following are the possible options – A, a, i, I, 1.
: This attribute is used to specify the starting point of numbering.
Start

Example:

<html>
<head>
Aman Choudhary Student (BCA-II) Seth G. L. Bihani S. D. PG College
<title> HTML Ordered List </title>
</head>

<body>
<ol type = "i" start = "4">
<li>Beetroot</li>
<li>Ginger</li>
<li>Potato</li>
<li>Radish</li>
</ol>
</body>

</html>

HTML Definition Lists


HTML and XHTML supports a list style which is called definition lists where entries are listed like in a
dictionary or encyclopedia. The definition list is the ideal way to present a glossary, list of terms, or other
name/value list.
Definition List makes use of following three tags.

• <dl> − Defines the start of the list


• <dt> − A term
• <dd> − Term definition
• </dl> − Defines the end of the list

Example:
<html>
<head>
<title> HTML Definition List </title>
</head>

<body>
<dl>
<dt> <b> HTML </b> </dt>
<dd> This stands for Hyper Text Markup Language </dd>
<dt> <b> HTTP </b> </dt>
<dd> This stands for Hyper Text Transfer Protocol </dd>
</dl>
</body>

</html>

Aman Choudhary Student (BCA-II) Seth G. L. Bihani S. D. PG College


TABLES
HTML tables allow web developers to arrange data into rows and columns. The HTML tables are created
using the <table> tag in which the <tr> tag is used to create table rows and <td> tag is used to create data
cells.

Example

<html>

<head>
<title> HTML Tables </title>
</head>

<body>
<table>
<tr>
<td>Row 1, Column 1</td>
<td>Row 1, Column 2</td>
</tr>

<tr>
<td>Row 2, Column 1</td>
<td>Row 2, Column 2</td>
</tr>
</table>

</body>
</html>

Row 1, Column 1 Row1, Column 2


Row 2, Column 1 Row 2, Column 2

Tags for HTML Tables


Tag Name Description

<table> It defines a table.

<tr> It defines a row in a table.

<td> It defines a cell in a table.

<th> It defines a header cell in a table.

<caption> It defines the table caption.

Attributes of Table

Aman Choudhary Student (BCA-II) Seth G. L. Bihani S. D. PG College


• Cellpadding and Cellspacing Attributes
There are two attributes called cellpadding and cellspacing which will use to adjust the white space in
table cells. The cellspacing attribute defines space between table cells, while cellpadding represents
the distance between cell borders and the content within a cell.

• Colspan and Rowspan Attributes colspan attribute is used to merge two or more columns into a
single column. Similar way rowspan is used to merge two or more rows.

• Tables Backgrounds
Table background can be set using one of the following two ways −
bgcolor attribute − You can set background color for whole table or just for one cell.
background attribute − You can set background image for whole table or just for one cell.

• Table Height and Width


Table width and height can be set using width and height attributes. The value of width or height can
specify in terms of pixels or in terms of percentage of available screen area.

FORMS
HTML Forms are required, to collect some data from the site visitor. For example, during user registration
you would like to collect information such as name, email address, credit card, etc.
A form will take input from the site visitor and then will post it to a back-end application such as CGI, ASP
Script or PHP script etc. The back-end application will perform required processing on the passed data based
on defined business logic inside the application.
There are various form elements available like text fields, textarea fields, drop-down menus, radio buttons,
checkboxes, etc.
The HTML <form> tag is used to create an HTML form and it has following syntax −
<form action = "Script URL" method = "GET|POST">

form elements like input, textarea etc.

</form>
Form Attributes
Apart from common attributes, following is a list of the most frequently used form attributes −
Sr. No Attribute & Description

Aman Choudhary Student (BCA-II) Seth G. L. Bihani S. D. PG College


1
action
Backend script ready to process your passed data.

2
method
Method to be used to upload data. The most frequently used are GET and POST methods.

3
target
Specify the target window or frame where the result of the script will be displayed. It takes
values like _blank, _self, _parent etc.

HTML Form Controls


There are different types of form controls for collecting data using HTML form −

• Text Input Controls


• Checkboxes Controls
• Radio Box Controls
• Select Box Controls
• File Select boxes
• Hidden Controls
• Clickable Buttons
• Submit and Reset Button

Text Input Controls


There are three types of text input used on forms −

(1) Single-line text input controls


This control is used for items that require only one line of user input, such as search boxes or names.
They are created using HTML <input> tag.

Example
Here is a basic example of a single-line text input used to take first name and last name −
<html>

<head>
<title>Text Input Control</title>
</head>

<body>
<form >
First name: <input type = "text" name = "first_name" > <br>
Last name: <input type = "text" name = "last_name" >
Aman Choudhary Student (BCA-II) Seth G. L. Bihani S. D. PG College
</form>
</body>

</html>

Attributes
Following is the list of attributes for <input> tag for creating text field.
Sr. No Attribute & Description

1
type
Indicates the type of input control and for text input control it will be set to text.

2
name
Used to give a name to the control which is sent to the server to be recognized and get the value.

3
value
This can be used to provide an initial value inside the control.

4
size
Allows to specify the width of the text-input control in terms of characters.

5
maxlength
Allows to specify the maximum number of characters a user can enter into the text box.

(2) Password input controls


This is also a single-line text input but it masks the character as soon as a user enters it. They are also
created using HTML <input>tag but type attribute is set to password.

Example
Here is a basic example of a single-line password input used to take user password −
<html>

<head>
<title>Password Input Control</title>
</head>

<body>
<form >
User ID : <input type = "text" name = "user_id" > <br>
Aman Choudhary Student (BCA-II) Seth G. L. Bihani S. D. PG College
Password: <input type = "password" name = "password" >
</form>
</body>

</html>

Attributes
Following is the list of attributes for <input> tag for creating password field.
Sr. No Attribute & Description

1
type
Indicates the type of input control and for password input control it will be set to password.

2
name
Used to give a name to the control which is sent to the server to be recognized and get the value.

3
value
This can be used to provide an initial value inside the control.

4
size
Allows to specify the width of the text-input control in terms of characters.

5
maxlength
Allows to specify the maximum number of characters a user can enter into the text box.

(3) Multiple-Line Text Input Controls


This is used when the user is required to give details that may be longer than a single sentence. Multi-
line input controls are created using HTML <textarea> tag.

Example
Here is a basic example of a multi-line text input used to take item description −
<html>

<head>
<title>Multiple-Line Input Control</title>
</head>

<body>
<form>
Aman Choudhary Student (BCA-II) Seth G. L. Bihani S. D. PG College
Description : <br />
<textarea rows = "5" cols = "50" name = "description">
Enter description here...
</textarea>
</form> </body>
</html>

Attributes
Following is the list of attributes for <textarea> tag.
Sr. No Attribute & Description

1
name
Used to give a name to the control which is sent to the server to be recognized and get the value.

2
rows
Indicates the number of rows of text area box.

3
cols
Indicates the number of columns of text area box

Checkbox Control
Checkboxes are used when more than one option is required to be selected. They are also created using HTML
<input> tag but type attribute is set to checkbox.

Example
Here is an example HTML code for a form with two checkboxes −
<html>

<head>
<title>Checkbox Control</title>
</head>

<body>
<form>
<input type = "checkbox" name = "maths" value = "on"> Maths
<input type = "checkbox" name = "physics" value = "on"> Physics
</form>
</body>

</html>

Aman Choudhary Student (BCA-II) Seth G. L. Bihani S. D. PG College


Attributes
Following is the list of attributes for <checkbox> tag.
Sr. No Attribute & Description

1
Type
Indicates the type of input control and for checkbox input control it will be set to checkbox.

2
name
Used to give a name to the control which is sent to the server to be recognized and get the value.

3
value
The value that will be used if the checkbox is selected.

4
checked
Set to checked if you want to select it by default.

Radio Button Control


Radio buttons are used when out of many options; just one option is required to be selected. They are also
created using HTML <input> tag but type attribute is set to radio.

Example
Here is example HTML code for a form with two radio buttons −
<html>

<head>
<title>Radio Box Control</title>
</head>

<body>
<form>
<input type = "radio" name = "subject" value = "maths"> Maths
<input type = "radio" name = "subject" value = "physics"> Physics
</form>
</body>
</html>

Attributes
Following is the list of attributes for radio button.
Sr. No Attribute & Description

Aman Choudhary Student (BCA-II) Seth G. L. Bihani S. D. PG College


1
type
Indicates the type of input control and for checkbox input control it will be set to radio.
2
name
Used to give a name to the control which is sent to the server to be recognized and get the value.

3
value
The value that will be used if the radio box is selected.

4
checked
Set to checked if you want to select it by default.

Select Box Control


A select box, also called drop down box which provides option to list down various options in the form of
drop down list, from where a user can select one or more options.

Example
Here is example HTML code for a form with one drop down box
<html>

<head>
<title>Select Box Control</title>
</head>

<body>
<form>
<select name = "dropdown">
<option value = "Maths" selected>Maths</option>
<option value = "Physics">Physics</option>
</select>
</form>
</body>
</html>

Attributes
Following is the list of important attributes of <select> tag −
Sr. No Attribute & Description

Aman Choudhary Student (BCA-II) Seth G. L. Bihani S. D. PG College


1
name
Used to give a name to the control which is sent to the server to be recognized and get the value.
2
size
This can be used to present a scrolling list box.

3
multiple
If set to "multiple" then allows a user to select multiple items from the menu.

Following is the list of important attributes of <option> tag −


Sr. No Attribute & Description

1
value
The value that will be used if an option in the select box box is selected.

2
selected
Specifies that this option should be the initially selected value when the page loads.

3
label
An alternative way of labeling options

Button Controls
There are various ways in HTML to create clickable buttons. You can also create a clickable button using
<input>tag by setting its type attribute to button. The type attribute can take the following values −
Sr. No Type & Description

1
submit
This creates a button that automatically submits a form.

Aman Choudhary Student (BCA-II) Seth G. L. Bihani S. D. PG College


2
reset
This creates a button that automatically resets form controls to their initial values.

3
button
This creates a button that is used to trigger a client-side script when the user clicks that button.

4
image
This creates a clickable button but we can use an image as background of the button.

Example
Here is example HTML code for a form with three types of buttons −
<html>

<head>
<title>File Upload Box</title>
</head>

<body>
<form>
<input type = "submit" name = "submit" value = "Submit" >
<input type = "reset" name = "reset" value = "Reset" >
<input type = "button" name = "ok" value = "OK" >
<input type = "image" name = "imagebutton" src = "/html/images/logo.png" >
</form>
</body>
</html>

Aman Choudhary Student (BCA-II) Seth G. L. Bihani S. D. PG College

You might also like