Comprehensive HTML4 Tutorial Guide
Comprehensive HTML4 Tutorial Guide
HTML4 NOTES
HTML tutorial or HTML 5 tutorial provides basic and advanced concepts of html. Our HTML
tutorial is developed for beginners and professionals. The major points of HTML are given
below:
<!DOCTYPE>
<html>
<body>
<h1>Write Your First Heading</h1>
<p>Write Your First Paragraph.</p>
</body>
</html>
HTML tags contain three main parts: opening tag, content and closing tag. But some HTML
tags are unclosed tags.
When a web browser reads an HTML document, browser reads it from top to bottom and left
to right. HTML tags are used to create HTML documents and render their properties. Each
HTML tags have different properties.
NOTE: HTML Tags are always written in lowercase letters. The basic HTML tags are given
below:
<b> Bold Tag </b>
<i> Italic Tag </i>
<u> Underline Tag</u>
Some HTML tags are not closed, for example br and hr.
<br> Tag: br stands for break line, it breaks the line of the code.
<hr> Tag: hr stands for Horizontal Rule. This tag is used to put a line across the webpage.
<p>, <h1>, <h2>, <h3>, <h4>, <h5>, <h6>, <strong>, <em>, <abbr>, <acronym>,
<address>, <bdo>, <blockquote>, <cite>, <q>, <code>, <ins>, <del>, <dfn>, <kbd>,
<pre>, <samp>, <var> and <br>
HTML Image and Object Tags:- <img>, <area>, <map>, <param> and <object>
HTML List Tags: - <ul>, <ol>, <li>, <dl>, <dt> and <dd>
3
HTML4 NOTES Created by: - Venu
HTML Table Tags: - table, tr, td, th, tbody, thead, tfoot, col, colgroup and caption
HTML Form Tags: - form, input, textarea, select, option, optgroup, button, label, fieldset
and legend
HTML Formatting
HTML Formatting is a process of formatting text for better look and feel. There are many
formatting tags in HTML. These tags are used to make text bold, italicized, or underlined.
There are almost 12 options available that how text appears in HTML and XHTML.
1) Bold Text
Syntax: - <p> <b>Write Your First Paragraph in bold text.</b></p>
2) Italic Text
If you write anything within <i>............</i> element, is shown in italic letters.
Syntax: - <p> <i>Write Your First Paragraph in italic text.</i></p>
If you want to mark or highlight a text, you should write the content within
<mark>.........</mark>.
Syntax:- <h2> I want to put a <mark> Mark</mark> on your face</h2>
Output:- I want to put a Mark on your face
4) Underlined Text: -
Syntax:- <p> <u>Write Your First Paragraph in underlined text.</u></p>
3
HTML4 NOTES Created by: - Venu
5) Strike Text
Syntax: - <p> <strike>Write Your First Paragraph with strikethrough</strike>.</p>
6) Monospaced Font
If you want that each letter has the same width then you should write the content within
<tt>.............</tt> element.
Note: We know that most of the fonts are known as variable-width fonts because different
letters have different width. (for example: 'w' is wider than 'i'). Monospaced Font provides
similar space among every letter.
Syntax: - <p>Hello <tt>Write Your First Paragraph in monospaced font.</tt></p>
Output: - Hello Write Your First Paragraph in monospaced font.
7) Superscript Text
8) Subscript Text
9) Deleted Text
If you want to put your font size larger than the rest of the text then put the content within
<big>.........</big>. It increase one font size larger than the previous one.
<p>Hello <big>Write the paragraph in larger font.</big></p>
If you want to put your font size smaller than the rest of the text then put the content
within <small>.........</small>tag. It reduces one font size than the previous one.
<p>Hello <small>Write the paragraph in smaller font.</small></p>
HTML HEADING
A HTML heading or HTML h tag can be defined as a title or a subtitle which you want to
display on the webpage. When you place the text within the heading tags
<h1>.........</h1>, it is displayed on the browser in the bold format and size of the text
depends on the number of heading.
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.
3
HTML4 NOTES Created by: - Venu
<h2>Heading no. 2</h2>
Heading no. 2
<h3>Heading no. 3</h3>
Heading no. 3
<h4>Heading no. 4</h4>
Heading no. 4
<h5>Heading no. 5</h5>
Heading no. 5
NOTE: - Heading elements (h1....h6) should be used for headings only. They should not be
used just to make text bold or big.
HTML PARAGRAPH
HTML paragraph or HTML p tag is used to define a paragraph in a webpage. Let's take a
simple example to see how it work. It is a notable point that a browser itself add an empty
line before and after a paragraph.
<p>This is first paragraph.</p>
<p>This is second paragraph.</p>
<p>This is third paragraph.</p>
If you put a lot of spaces inside the HTML p tag, browser removes extra spaces and extra
line while displaying the page. The browser counts number of spaces and lines as a single
one.
<p>
I am
going to provide
you a tutorial on HTML
and hope that it will
be very beneficial for you.
</p>
<p>
Look, I put here a lot
of spaces but I know, Browser will ignore it.
</p>
<p>
You cannot determine the display of HTML</p>
<p>because resized windows may create different result.
</p>
I am going to provide you a tutorial on HTML and hope that it will be very beneficial for you.
Look, I put here a lot of spaces but I know, Browser will ignore it.
NOTE: - As you can see, all the extra lines and unnecessary spaces are removed by the
browser.
3
HTML4 NOTES Created by: - Venu
HTML ANCHOR
The HTML anchor tag defines a hyperlink that links one page to another page. The "href"
attribute is the most important attribute of the HTML a tag.
The href attribute is used to define the address of the file to be linked. In other words, it
points out the destination page.
<a href="second.html">Click for Second Page</a>
HTML IMAGE
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.
<h2>HTML Image Example</h2>
<img src="good_morning.jpg" alt="Good Morning Friends"/>
The src and alt are important attributes of HTML img tag. All attributes of HTML image tag
are given below.
1) 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.
2) 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. The alt attribute is considered good for SEO
prospective.
3) width
It is an optional attribute which is used to specify the width to display the image. It is not
recommended now. You should apply CSS in place of width attribute.
4) height
It specifies the height of the image. The HTML height attribute also supports iframe, image
and object elements. It is not recommended now. You should apply CSS in place of height
attribute.
HTML TABLE
HTML table tag is used to display data in tabular form (row * column). There can be many
columns in a row.
HTML tables are used to manage the layout of the page e.g. header section, navigation bar,
body content, footer section etc. But it is recommended to use div tag over table to manage
the layout of the page.
HTML TAGS
Tag Description
Note: - In the above html table, there are 5 rows and 3 columns = 5 * 3 = 15 values.
3
HTML4 NOTES Created by: - Venu
You can use border attribute of table tag in HTML to specify border. But it is not
recommended now.
<table border="1">
<tr><th>First_Name</th><th>Last_Name</th><th>Marks</th></tr>
<tr><td>Sonoo</td><td>Jaiswal</td><td>60</td></tr>
<tr><td>James</td><td>William</td><td>80</td></tr>
<tr><td>Swati</td><td>Sironi</td><td>82</td></tr>
<tr><td>Chetna</td><td>Singh</td><td>72</td></tr>
</table>
First_Name Last_Name Marks
Dr.Vishnu vardhanl 60
Upendra Rao 80
Dr.Bharati Vishnuvardhan 82
Fake Peoples 72
<style>
table, th, td {
border: 1px solid black;
}
</style>
You can collapse all the borders in one border by border-collapse property.
3
HTML4 NOTES Created by: - Venu
<style>
table, th, td {
border: 2px solid black;
border-collapse: collapse;
}
</style>
<html>
<head>
<style>
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
</style>
</head>
<body>
<table>
<tr><th>First_Name</th><th>Last_Name</th><th>Marks</th></tr>
<tr><td>a</td><td>b</td><td>60</td></tr>
<tr><td>c</td><td>d</td><td>80</td></tr>
<tr><td>ei</td><td>f</td><td>82</td></tr>
<tr><td>g</td><td>h</td><td>72</td></tr>
</table>
3
HTML4 NOTES Created by: - Venu
You can specify padding for table header and table data by two ways:
The cellpadding attribute of HTML table tag is obsolete now. It is recommended to use CSS.
So let's see the code of CSS.
<style>
table, th, td {
border: 1px solid pink;
border-collapse: collapse;
}
th, td {
padding: 10px;
}
</style>
<!DOCTYPE>
<html>
<head>
<style>
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
th, td {
padding: 10px;
}
</style>
</head>
<body>
3
HTML4 NOTES Created by: - Venu
<table>
<tr><th>First_Name</th><th>Last_Name</th><th>Marks</th></tr>
<tr><td>A</td><td>B</td><td>60</td></tr>
<tr><td>S</td><td>D</td><td>80</td></tr>
<tr><td>E</td><td>Fi</td><td>82</td></tr>
<tr><td>X</td><td>WW</td><td>72</td></tr>
</table>
</body>
</html>
A B 60
S D 80
E Fi 82
X WW 72
ii> to change border 1px 3px and cellpadding is decrease 10px 4px
If you want to make a cell span more than one column, you can use the colspan attribute.
CSS code:
<style>
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
th, td {
padding: 5px;
}
</style>
Html Code
<!DOCTYPE>
<html>
<head>
<style>
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
th, td {
padding: 5px;
text-align: left;
}
</style>
3
HTML4 NOTES Created by: - Venu
</head>
<body>
<table style="width:100%">
<tr>
<th>Name</th>
<th colspan="2"><center>Mobile No.</center></th>
</tr>
<tr>
<td>Venu</td>
<td>9880115507</td>
<td>8660344018</td>
</tr>
</table>
</body>
</html>
If you want to make a cell span more than one row, you can use the rowspan attribute.
CSS code:
<style>
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
th, td {
3
HTML4 NOTES Created by: - Venu
padding: 10px;
}
</style>
Html code:
<!DOCTYPE>
<html>
<head>
<style>
table, th, td {
border-collapse: collapse;
th, td {
padding: 10px;
</style>
</head>
<body>
<table>
<tr><th>Name</th><td>Venu</td></tr>
<tr><td>8660344018</td></tr>
</table>
</body>
</html>
HTML caption is displayed above the table. It must be used after table tag only.
<!DOCTYPE>
<html>
<head>
<style>
table, th, td {
border-collapse: collapse;
th, td {
padding: 10px;
}
3
HTML4 NOTES Created by: - Venu
</style>
</head>
<body>
<table>
<caption> Records</caption>
<tr><th>First_Name</th><th>Last_Name</th><th>Marks</th></tr>
<tr><td>Vimal</td><td>k</td><td>70</td></tr>
<tr><td>Milk</td><td>cold</td><td>60</td></tr>
<tr><td>hot</td><td>milk</td><td>42</td></tr>
<tr><td>appy</td><td>juice</td><td>62</td></tr>
</table>
</body>
</html>
3
HTML4 NOTES Created by: - Venu
CSS code:
<style>
table, th, td {
border: 1px solid black;
border-collapse: collapse;
}
th, td {
padding: 10px;
}
table#alter tr:nth-child(even) {
background-color: #eee;
}
table#alter tr:nth-child(odd) {
background-color: #fff;
}
table#alter th {
color: white;
background-color: gray;
}
</style>
<!DOCTYPE>
<html>
<head>
<style>
table, th, td {
border-collapse: collapse;
th, td {
padding: 10px;
table#alter tr:nth-child(even) {
background-color: #eee;
table#alter tr:nth-child(odd) {
background-color: #fff;
table#alter th {
color: white;
background-color: gray;
</style>
</head>
<body>
<table id="alter">
<tr><th>First_Name</th><th>Last_Name</th><th>Marks</th></tr>
<tr><td>fake</td><td>people</td><td>60</td></tr>
3
HTML4 NOTES Created by: - Venu
<tr><td>real</td><td>peoples</td><td>80</td></tr>
<tr><td>peoples</td><td>reel</td><td>82</td></tr>
<tr><td>time</td><td>being</td><td>72</td></tr>
</table>
</body>
</html>
HTML Lists
HTML Lists are used to specify lists of information. All lists may contain one or more list
elements. There are three different types of HTML lists:
In the ordered HTML lists, all the list items are marked with numbers. It is known as
numbered list also. The ordered list starts with <ol> tag and the list items start with <li>
tag.
3
HTML4 NOTES Created by: - Venu
<ol>
<li>Aries</li>
<li>Bingo</li>
<li>Leo</li>
<li>Oracle</li>
</ol>
1. Aries
2. Bingo
3. Leo
4. Oracle
HTML Ordered List or Numbered List displays elements in numbered format. The HTML ol
tag is used for ordered list. There can be different types of numbered list:
To represent different ordered lists, there are 5 types of attributes in <ol> tag.
Type Description
Type This is the default type. In this type, the list items are numbered with
"1" numbers.
Type "I" In this type, the list items are numbered with upper case roman numbers.
Type "i" In this type, the list items are numbered with lower case roman numbers.
Type In this type, the list items are numbered with upper case letters.
"A"
Type In this type, the list items are numbered with lower case letters.
"a"
3
HTML4 NOTES Created by: - Venu
<ol>
<li>HTML</li>
<li>Java</li>
<li>JavaScript</li>
<li>SQL</li>
</ol>
1. HTML
2. Java
3. JavaScript
4. SQL
ol type="I"
Let's see the example to display list in roman number uppercase.
<ol type="I">
<li>HTML</li>
<li>Java</li>
<li>JavaScript</li>
<li>SQL</li>
</ol>
I. HTML
II. Java
III. JavaScript
IV. SQL
ol type="i"
3
HTML4 NOTES Created by: - Venu
<ol type="i">
<li>HTML</li>
<li>Java</li>
<li>JavaScript</li>
<li>SQL</li>
</ol>
i. HTML
ii. Java
iii. JavaScript
iv. SQL
ol type="A"
Let's see the example to display list in alphabet uppercase.
<ol type="A">
<li>HTML</li>
<li>Java</li>
<li>JavaScript</li>
<li>SQL</li>
</ol>
A. HTML
B. Java
C. JavaScript
D. SQL
ol type="a"
Let's see the example to display list in alphabet lowercase.
<ol type="a">
3
HTML4 NOTES Created by: - Venu
<li>HTML</li>
<li>Java</li>
<li>JavaScript</li>
<li>SQL</li>
</ol>
a. HTML
b. Java
c. JavaScript
d. SQL
start attribute
The start attribute is used with ol tag to specify from where to start the list items.
<ol type="1" start="5"> : It will show numeric values starting with "5".
<ol type="A" start="5"> : It will show capital alphabets starting with "E".
<ol type="a" start="5"> : It will show lower case alphabets starting with "e".
<ol type="I" start="5"> : It will show Roman upper case value starting with "V".
<ol type="i" start="5"> : It will show Roman lower case value starting with "v".
<ol type="i" start="5">
<li>HTML</li>
<li>Java</li>
<li>JavaScript</li>
<li>SQL</li>
</ol>
v. HTML
vi. Java
vii. JavaScript
viii. SQL
3
HTML4 NOTES Created by: - Venu
<ul>
<li>Aries</li>
<li>Bingo</li>
<li>Leo</li>
<li>Oracle</li>
</ul>
o Aries
o Bingo
o Leo
o Oracle
o disc
o circle
o square
o none
To represent different ordered lists, there are 4 types of attributes in <ul> tag.
Type Description
Type "disc" This is the default style. In this style, the list items are marked with
bullets.
Type "circle" In this style, the list items are marked with circles.
Type In this style, the list items are marked with squares.
3
HTML4 NOTES Created by: - Venu
"square"
Type "none" In this style, the list items are not marked .
ul type="circle"
<ul type="circle">
<li>HTML</li>
<li>Java</li>
<li>JavaScript</li>
<li>SQL</li>
</ul>
ul type="square"
<ul type="square">
<li>HTML</li>
<li>Java</li>
<li>JavaScript</li>
3
HTML4 NOTES Created by: - Venu
<li>SQL</li>
</ul>
ul type="none"
<ul type="none">
<li>HTML</li>
<li>Java</li>
<li>JavaScript</li>
<li>SQL</li>
</ul>
<dl>
<dt>HTML</dt>
<dd>is a markup language</dd>
<dt>Java</dt>
<dd>is a programming language and platform</dd>
3
HTML4 NOTES Created by: - Venu
<dt>JavaScript</dt>
<dd>is a scripting language</dd>
<dt>SQL</dt>
<dd>is a query language</dd>
</dl>
HTML
is a markup language
Java
is a programming language and platform
JavaScript
is a scripting language
SQL
is a query language
HTML Forms
An HTML form is a section of document that contains interactive controls that
enable a user to submit information to a web server.
<!DOCTYPE html>
<html lang="en">
<head>
<title>Example of HTML From Controls</title>
</head>
<body>
3
HTML4 NOTES Created by: - Venu
<form>
<fieldset>
<legend>Sign In</legend>
<label for="user-name">Username:</label>
<input type="text" name="username" id="user-name">
<label for="user-pwd">Password:</label>
<input type="password" name="user-password" id="user-pwd">
</fieldset>
<fieldset>
<legend>Gender</legend>
<input type="radio" name="sex" id="male">
<label for="male">Male</label>
<input type="radio" name="sex" id="female">
<label for="female">Female</label>
</fieldset>
<fieldset>
<legend>Hobbies</legend>
<input type="checkbox" name="sports" id="soccer">
<label for="soccer">Soccer</label>
<input type="checkbox" name="sports" id="cricket">
<label for="cricket">Cricket</label>
<input type="checkbox" name="sports" id="cricket">
<label for="baseball">Baseball</label>
</fieldset>
<fieldset>
<legend>Address</legend>
<textarea rows="3" cols="30"></textarea>
</fieldset>
<fieldset>
3
HTML4 NOTES Created by: - Venu
<legend>Upload file</legend>
<label for="file-select">Upload:</label>
<input type="file" name="upload" id="file-select">
</fieldset>
<fieldset>
<legend>Select Your City</legend>
<label for="city">City:</label>
<select name="city" id="city">
<option value="sydney">Sydney</option>
<option value="melbourne">Melbourne</option>
<option value="cromwell">Cromwell</option>
</select>
</fieldset>
<fieldset>
<legend>Action</legend>
<input type="submit" value="Submit">
<input type="reset" value="Reset">
</fieldset>
</form>
</body>
</html>
The following section describes different types of controls that you can use in your form.
Input Element
This is the most commonly used element within HTML forms.
It allows you to specify various types of user input fields, depending on the type attribute. An
input element can be of type text field, checkbox, password field, radio button, submit
button,reset button, etc. and several new input types introduced in HTML5.
The most used input types are described below.
Text Fields
Text fields are one line areas that allow the user to input text.
3
HTML4 NOTES Created by: - Venu
Password Field
Password fields are similar to text fields. The only difference is; characters in a password
field are masked i.e. shown as asterisks or dots. This is to prevent others from reading the
password on the screen. This is also a single-line text input controls created using
an <input> element whose type attribute has a value of password.
Here's an example of a single-line password input used to take user password:
<!DOCTYPE html>
<html lang="en">
<head>
<title>Example of HTML From Password Field</title>
</head>
<body>
<form>
3
HTML4 NOTES Created by: - Venu
<label for="user-pwd">Password:</label>
<input type="password" name="user-password" id="user-pwd">
</form>
</body>
</html>
Radio Buttons
Radio buttons are used to let the user select exactly one option from a pre-defined set of
options. It is created using an <input> element whose type attribute has a value of radio.
<!DOCTYPE html>
<html lang="en">
<head>
<title>Example of HTML From Radio Button</title>
</head>
<body>
<form>
<input type="radio" name="sex" id="male">
<label for="male">Male</label>
<input type="radio" name="sex" id="female">
<label for="female">Female</label>
</form>
</body>
</html>
Checkboxes
Checkboxes allows the user to select one or more option from a pre-defined set of options.
It is created using an <input> element whose type attribute has a value of checkbox.
<!DOCTYPE html>
3
HTML4 NOTES Created by: - Venu
<html lang="en">
<head>
<title>Example of HTML From Checkbox</title>
</head>
<body>
<form>
<input type="checkbox" name="sports" id="soccer">
<label for="soccer">Soccer</label>
<input type="checkbox" name="sports" id="cricket">
<label for="cricket">Cricket</label>
<input type="checkbox" name="sports" id="cricket">
<label for="baseball">Baseball</label>
</form>
</body>
</html>
</form>
</body>
</html>
Textarea
Textarea is a multiple-line text input control that allows a user to enter more than one line of
text. Multi-line text input controls are created using an <textarea> element.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Example of HTML Textarea</title>
</head>
<body>
<form>
<label for="address">Address:</label>
<textarea rows="3" cols="30" name="address" id="address"></textarea>
</form>
</body>
</html>
Select Boxes
A select box is a dropdown list of options that allows user to select one or more option from
a pull-down list of options. Select box is created using the <select> element
and <option>element. The option elements within the <select> element define each list item.
<!DOCTYPE html>
<html lang="en">
<head>
<title>Example of HTML From Select Box</title>
3
HTML4 NOTES Created by: - Venu
</head>
<body>
<form>
<label for="city">City:</label>
<select name="city" id="city">
<option value="sydney">Sydney</option>
<option value="melbourne">Melbourne</option>
<option value="cromwell">Cromwell</option>
</select>
</form>
</body>
</html>
</html>
Attribute Description
action URL of the program that processes the information submitted via form.
method The HTTP method that the browser uses to submit the form. Possible values are get and post.
target A name or keyword indicating the target page where the result of the script will be displayed.
The reserved keywords are _blank, _self, _parent and _to