0 - HTML Notes For BCA
0 - HTML Notes For BCA
HTML stands for Hyper Text Markup Language. It is the language of the Web. It is used to
create web pages which can be viewed using a web browser. It consists of set of tags which
describe the content of a web page. HTML documents are also called web pages.
HyperText is the method by which you move around on the web, it is not linear that is you can
go to any place on the Internet whenever you want by clicking on links — there is no set order to
do things in.
Markup specifies what HTML tags do to the text inside them. They mark it as a certain type of
text (italicised text, for example).
HTML consists of a series of short codes typed into a text-file by the site author — these are the
tags. The text is then saved as a html file, and viewed through a browser, like Internet
Explorer or Netscape Navigator. This browser reads the file and translates the text into a visible
form
HTML Tags
HTML tags are keywords (tag names) surrounded by angle brackets like <html>
HTML tags normally come in pairs like <b> and </b>
The first tag in a pair is the start tag, the second tag is the end tag
The end tag is written like the start tag, with a forward slash before the tag name
Start and end tags are also called opening tags and closing tags
An HTML document consists of two main parts i) The Head ii) The body.
Head:- Head is the first part of the HTML document. It consists of Title page and other
parameters that the browser will use
Body:- This part describes the actual content of a web page. It includes the text and the tags. The
textual part gives information contained in a web page and the tag defines the appearance of the
document.
Eg:
<html>
<head>
</head>
</body>
</html>
1. bgcolor:- This tag sets the background color of the document. Here either color
name or hexadecimal value of that color can be specified like
</body>
</body>
</body>
</body>
</body>
5. text:- specifies the color of the normal text in the document. Here also either the
color name or hexadecimal values can be specified
</body>
Heading element: Heading elements are used to create headlines in document. The tags <h1>
to <h6> define different levels of heading of a page. There are six levels of heading <h1> is used
for the largest and <h6> for the smallest. Its general syntax
Paragraph element:- One of the important elements used in HTML is the paragraph element.
Paragraph can be created by using <p> tag which begins a paragraph and ends with </p>. The
text within <p> and </p> can be aligned left, right, center or justify by using the align attribute.
Output
Tag Description
<b> Defines bold text
<big> Defines big text
<em> Defines emphasized text
<i> Defines a part of text in an alternate voice or mood
<small> Defines small text
<strong> Defines strong text
<sub> Defines subscripted text
<sup> Defines superscripted text
<ins> Defines inserted text
<del> Defines deleted text
Example
<!DOCTYPE html>
<html>
<body>
Output
This is subscript and superscript
HTML LISTS
The most common HTML lists are ordered , unordered lists and definition list:
An unordered list starts with the <ul> tag. Each list item starts with the <li> tag. The list items
are marked with bullets (typically small black circles). To render a list with a different bullet
type, add a type attribute to the unordered list element.
Example-1
<ul>
<li>Coffee</li>
<li>Milk</li>
</ul>
Coffee
Milk
Example-2
Cofee
Milk
Example-3
o Coffee
o Milk
An ordered list starts with the <ol> tag. Each list item starts with the <li> tag. list items placed
inside of an ordered list are preceded with numbers instead of bullets.
<ol>
<li>Coffee</li>
<li>Milk</li>
</ol>
1. Coffee
2. Milk
Example-2
<ol type="a">
<li>Coffee</li>
<li>Milk</li>
</ol>
a. Coffee
b. Milk
Example-3
<ol type="A">
<li>Coffee</li>
<li>Milk</li>
</ol>
A. Hindi
B. English
Example-4
<ol type="i">
<li>Coffee</li>
<li>Milk</li>
</ol>
i Hindi
ii English
Example-5
<ol type="I">
<li>Coffee</li>
<li>Milk</li>
</ol>
I Hindi
II English
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 in conjunction with <dt> (defines the item in the list) and
<dd> (describes the item in the list):
<dl>
<dt>Coffee</dt>
<dd>- black hot drink</dd>
<dt>Milk</dt>
<dd>- white cold drink</dd>
</dl>
Coffee
- black hot drink
Milk
- white cold drink
The HTML <div> element is a block level element that can be used as a container for grouping
other HTML elements. The <div> element has no special meaning. Except that, because it is a
block level element, the browser will display a line break before and after it. When used together
with CSS, the <div> element can be used to set style attributes to large blocks of content.
Image links are constructed by embedding an <img> tag inside of an anchor element <a>. Like
HTML text links, image links require opening and closing anchor tags, but instead of placing
text between these opening and closing tags, the developer needs to place an image tag -- with a
valid source attribute value of course.The HTML <a> tag defines a hyperlink. A hyperlink (or
link) is a word, group of words, or image that you can click on to jump to another document.
When you move the cursor over a link in a Web page, the arrow will turn into a little hand. The
most important attribute of the <a> element is the href attribute, which indicates the link’s
destination.
Example
<a href="http://www.w3schools.com/">Visit W3Schools</a>
Tip: The "Link text" doesn't have to be text. It can be an image or any other HTML element.
The example below will open the linked document in a new browser window or a new tab:
Example
<a href="http://www.w3schools.com/" target="_blank">Visit W3Schools!</a>
Tip: Bookmarks are not displayed in any special way. They are invisible to the reader.
Example
HTML Tables
An HTML table is an element comprised of table rows and columns, much like you'd see when
working with an application such as Excel. Tables are container elements, and their sole purpose
is to house other HTML elements and arrange them in a tabular fashion -- row by row, column
by column. A table element consists of three different HTML tags including the <table> tag,
<tr> (table rows), and the <td> (table columns) tags.
Output
Combination Number of students
PMCs 83
A table can contain an infinite number of table rows. Each table row is essentially a table
element itself, with an opening and closing tag (<tr> </tr>). Table columns are also considered
child elements of HTML tables, and like table rows, an HTML table may contain an infinite
number of table data cells (<td> <tr>).
Table rows and columns are container elements that house other HTML elements such as text
links, images, and lists.
Examples on Table
<!DOCTYPE html>
<html>
<body>
<table border="1">
<tr>
<th>Month</th>
<th>Savings</th>
</tr>
<tr>
<td>January</td>
<td>$100</td>
</tr>
<tr>
<td>February</td>
<td>$80</td>
</tr>
</table>
</body>
</html>
Month Savings
January $100
February $80
There are two attribiutes called cellpadding and cellspacing which you will use to adjust the
white space in your table cell. Cellspacing defines the width of the border, while cellpadding
represents the distance between cell borders and the content within. Following is the example:
Name Salary
You will use colspan attribute if you want to merge two or more columns into a single column.
Similar way you will use rowspan if you want to merge two or more rows. Following is the
example:
<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>
Tables Backgrounds
You can set table background using of the following two ways:
Using bgcolor attribute - You can set background color for whole table or just for one
cell.
Using background attribute - You can set background image for whole table or just for
one cell.
You can set a table width and height using width and height attrubutes. You can specify table
width or height in terms of integer value or in terms of percentage of available screen area.
Following is the example:
Tables can be divided into three portions: 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.
The three elements for separating the head, body, and foot of a table are:
Forms in HTML
HTML Forms are required when you want to collect some data from the site visitor. For example
registration information: name, email address, credit card, etc.
A form will take input from the site visitor and then will post your back-end application such as
CGI, ASP Script or PHP script etc. Then your back-end application will do required processing
on that data in whatever way you like.
Form elements are like text fields, textarea fields, drop-down menus, radio buttons, checkboxes,
etc. which are used to take information from the user.
method: Here you will specify method to be used to upload data. It can take various
values but most frequently used are GET and POST.
target: It specifies the target page where the result of the script will be displayed. It takes
values like _blank, _self, _parent etc.
enctype: You can use the enctype attribute to specify how the browser encodes the data
before it sends it to the server.
HTML Forms are used to select different kinds of user input. HTML forms are used to pass data
to a server. An HTML form can contain input elements like text fields, checkboxes, radio-
buttons, submit buttons and more. A form can also contain select lists, textarea, fieldset, legend,
and label elements.
The most important form element is the <input> element. The <input> element is used to select
user information. An <input> element can vary in many ways, depending on the type attribute.
An <input> element can be of type text field, checkbox, password, radio button, submit button,
and more. The most common input types are described below.
Text Fields
<input type="text"> defines a one-line input field that a user can enter text into:
Example
<form>
First name: <input type="text" name="firstname"><br>
Last name: <input type="text" name="lastname">
</form>
First name:
Last name:
Password Field
Password:
Note: The characters in a password field are masked (shown as asterisks or circles).
Radio Buttons
<input type="radio"> defines a radio button. Radio buttons let a user select ONLY ONE of a
limited number of choices:
<form>
<input type="radio" name="sex" value="male">Male<br>
<input type="radio" name="sex" value="female">Female
</form>
Male
Female
Checkboxes
<input type="checkbox"> defines a checkbox. Checkboxes let a user select ZERO or MORE
options of a limited number of choices.
<form>
<input type="checkbox" name="vehicle" value="Bike">I have a bike<br>
<input type="checkbox" name="vehicle" value="Car">I have a car
</form>
I have a bike
I have a car
Submit Button
Username:
If you type some characters in the text field above, and click the "Submit" button, the browser
will send your input to a page called "html_form_action.asp". The page will show you the
received input.
</body>
</html>
Output
This is heading 1
This is heading 2
This is heading 3
This is heading 4
This is heading 5
This is heading 6
<!DOCTYPE html>
<html>
<body>
</body>
</html>
Output
<!DOCTYPE html>
<html>
<body>
<p>
An image:
<p>
A moving image:
<p>
Note that the syntax of inserting a moving image is no different from a non-moving image.
</p>
</body>
</html>
Output
An image:
A moving image:
Note that the syntax of inserting a moving image is no different from a non-moving image.
<!DOCTYPE html>
<html>
<body>
</body>
</html>
Output
An Ordered List:
1. Coffee
2. Tea
3. Milk
An Unordered List:
Coffee
Tea
Milk
A Definition List:
Coffee
- black hot drink
Milk
- white cold drink