Star T Tag Content End Tag: HTML - Elements
Star T Tag Content End Tag: HTML - Elements
Star T Tag Content End Tag: HTML - Elements
This is
<p> paragraph </p>
content.
This is
<h1 </
heading
> h1>
content.
This is
<div </
division
> div>
content.
<br /
>
So here <p>....</p> is an HTML element,
<h1>...</h1> is another HTML element. There are
some HTML elements which don't need to be closed,
such as <img.../>, <hr /> and <br /> elements. These
are known as void elements.
HTML documents consists of a tree of these elements
and they specify how HTML documents should be
built, and what kind of content should be placed in
what part of an HTML document.
<head>
<title>Nested Elements
Example</title>
</head>
<body>
<h1>This is <i>italic</i>
heading</h1>
<p>This is <u>underlined</u>
paragraph</p>
</body>
</html>
HTML - Attributes
<!DOCTYPE html>
<html>
<head>
<title>Align Attribute
Example</title>
</head>
<body>
<p align = "left">This is left
aligned</p>
<p align = "center">This is
center aligned</p>
<p align = "right">This is right
aligned</p>
</body>
</html>
Core Attributes
The four core attributes that can be used on the
majority of HTML elements (although not all) are −
•Id
•Title
•Class
•Style
The Id Attribute
<!DOCTYPE html>
<html>
<head>
<title>The title Attribute
Example</title>
</head>
<body>
<h3 title = "Hello HTML!">Titled
Heading Tag Example</h3>
</body>
</html>
This will produce the following result −
Titled Heading Tag Example
Now try to bring your cursor over "Titled Heading Tag
Example" and you will see that whatever title you used
in your code is coming out as a tooltip of the cursor.
<!DOCTYPE html>
<html>
<head>
<title>The style
Attribute</title>
</head>
<body>
<p style = "font-family:arial;
color:#FF0000;">Some text...</p>
</body>
</html>
This will produce the following result −
Some text...
Internationalization Attributes
<head>
<title>Display Directions</title>
</head>
<body>
This is how IE 5 renders right-
to-left directed text.
</body>
</html>
This will produce the following result −
Object 1
<head>
<title>English Language
Page</title>
</head>
<body>
This page is using English
Language
</body>
</html>
This will produce the following result −
Object 2
The xml:lang Attribute
Generic Attributes
numeric,
bgcol Places a background color
hexidecimal,
or behind an element
RGB values
HTML - Formatting
Bold Text
<!DOCTYPE html>
<html>
<head>
<title>Bold Text Example</title>
</head>
<body>
<p>The following word uses a
<b>bold</b> typeface.</p>
</body>
</html>
This will produce the following result −
Object 3
Italic Text
<!DOCTYPE html>
<html>
<head>
<title>Italic Text
Example</title>
</head>
<body>
<p>The following word uses an
<i>italicized</i> typeface.</p>
</body>
</html>
This will produce the following result −
Object 4
Underlined Text
<!DOCTYPE html>
<html>
<head>
<title>Underlined Text
Example</title>
</head>
<body>
<p>The following word uses an
<u>underlined</u> typeface.</p>
</body>
</html>
This will produce the following result −
Object 5
Strike Text
Example
<!DOCTYPE html>
<html>
<head>
<title>Strike Text
Example</title>
</head>
<body>
<p>The following word uses a
<strike>strikethrough</strike>
typeface.</p>
</body>
</html>
This will produce the following result −
Object 6
Monospaced Font
Example
<!DOCTYPE html>
<html>
<head>
<title>Monospaced Font
Example</title>
</head>
<body>
<p>The following word uses a
<tt>monospaced</tt> typeface.</p>
</body>
</html>
This will produce the following result −
Object 7
Superscript Text
Example
<!DOCTYPE html>
<html>
<head>
<title>Superscript Text
Example</title>
</head>
<body>
<p>The following word uses a
<sup>superscript</sup> typeface.</p>
</body>
</html>
This will produce the following result −
Object 8
Subscript Text
Example
<!DOCTYPE html>
<html>
<head>
<title>Subscript Text
Example</title>
</head>
<body>
<p>The following word uses a
<sub>subscript</sub> typeface.</p>
</body>
</html>
This will produce the following result −
Object 9
Inserted Text
Example
<!DOCTYPE html>
<html>
<head>
<title>Inserted Text
Example</title>
</head>
<body>
<p>I want to drink
<del>cola</del> <ins>wine</ins></p>
</body>
</html>
This will produce the following result −
Object 10
Deleted Text
Example
Live Demo
<!DOCTYPE html>
<html>
<head>
<title>Deleted Text
Example</title>
</head>
<body>
<p>I want to drink
<del>cola</del> <ins>wine</ins></p>
</body>
</html>
This will produce the following result −
Object 11
Larger Text
Example
<!DOCTYPE html>
<html>
<head>
<title>Larger Text
Example</title>
</head>
<body>
<p>The following word uses a
<big>big</big> typeface.</p>
</body>
</html>
This will produce the following result −
Object 12
Smaller Text
Example
<!DOCTYPE html>
<html>
<head>
<title>Smaller Text
Example</title>
</head>
<body>
<p>The following word uses a
<small>small</small> typeface.</p>
</body>
</html>
This will produce the following result −
Object 13
Grouping Content
<!DOCTYPE html>
<html>
<head>
<title>Div Tag Example</title>
</head>
<body>
<div id = "menu" align = "middle"
>
<a href =
"/index.htm">HOME</a> |
<a href =
"/about/contact_us.htm">CONTACT</a> |
<a href =
"/about/index.htm">ABOUT</a>
</div>
</html>
This will produce the following result −
Example
<!DOCTYPE html>
<html>
<head>
<title>Span Tag Example</title>
</head>
<body>
<p>This is the example of <span
style = "color:green">span tag</span>
and the <span style =
"color:red">div tag</span> alongwith
CSS</p>
</body>
</html>
This will produce the following result −
Object 15
Example
Live Demo
<!DOCTYPE html>
<html>
<head>
<title>Emphasized Text
Example</title>
</head>
<body>
<p>The following word uses an
<em>emphasized</em> typeface.</p>
</body>
</html>
This will produce the following result −
Object 14
Marked Text
Example
Live Demo
<!DOCTYPE html>
<html>
<head>
<title>Marked Text
Example</title>
</head>
<body>
<p>The following word has been
<mark>marked</mark> with yellow</p>
</body>
</html>
This will produce the following result −
Object 16
Strong Text
Example
Live Demo
<!DOCTYPE html>
<html>
<head>
<title>Strong Text
Example</title>
</head>
<body>
<p>The following word uses a
<strong>strong</strong> typeface.</p>
</body>
</html>
This will produce the following result −
Object 17
Text Abbreviation
Example
Live Demo
<!DOCTYPE html>
<html>
<head>
<title>Text Abbreviation</title>
</head>
<body>
<p>My best friend's name is
<abbr title =
"Abhishek">Abhy</abbr>.</p>
</body>
</html>
This will produce the following result −
My best friend's name is Abhy
Acronym Element
Example
Live Demo
<!DOCTYPE html>
<html>
<head>
<title>Acronym Example</title>
</head>
<body>
<p>This chapter covers marking up
text in <acronym>XHTML</acronym>.</p>
</body>
</html>
This will produce the following result −
Object 19
Text Direction
Example
Live Demo
<!DOCTYPE html>
<html>
<head>
<title>Text Direction
Example</title>
</head>
<body>
<p>This text will go left to
right.</p>
<p><bdo dir = "rtl">This text
will go right to left.</bdo></p>
</body>
</html>
This will produce the following result −
Object 20
Special Terms
Live Demo
<!DOCTYPE html>
<html>
<head>
<title>Special Terms
Example</title>
</head>
<body>
<p>The following word is a
<dfn>special</dfn> term.</p>
</body>
</html>
This will produce the following result −
Object 21
Quoting Text
Example
Live Demo
<!DOCTYPE html>
<html>
<head>
<title>Blockquote Example</title>
</head>
<body>
<p>The following description of
XHTML is taken from the W3C Web
site:</p>
<blockquote>XHTML 1.0 is the
W3C's first Recommendation for
XHTML,following on
from earlier work on HTML
4.01, HTML 4.0, HTML 3.2 and HTML
2.0.</blockquote>
</body>
</html>
This will produce the following result −
Short Quotations
Example
Live Demo
<!DOCTYPE html>
<html>
<head>
<title>Double Quote
Example</title>
</head>
<body>
<p>Amit is in Spain, <q>I think I
am wrong</q>.</p>
</body>
</html>
This will produce the following result −
Object 23
Text Citations
Example
Live Demo
<!DOCTYPE html>
<html>
<head>
<title>Citations Example</title>
</head>
<body>
<p>This HTML tutorial is derived
from <cite>W3 Standard for
HTML</cite>.</p>
</body>
</html>
This will produce the following result −
Object 24
Computer Code
Live Demo
<!DOCTYPE html>
<html>
<head>
<title>Computer Code
Example</title>
</head>
<body>
<p>Regular text. <code>This is
code.</code> Regular text.</p>
</body>
</html>
This will produce the following result −
Object 25
Keyboard Text
Example
Live Demo
<!DOCTYPE html>
<html>
<head>
<title>Keyboard Text
Example</title>
</head>
<body>
<p>Regular text. <kbd>This is
inside kbd element</kbd> Regular
text.</p>
</body>
</html>
This will produce the following result −
Programming Variables
Example
<!DOCTYPE html>
<html>
<head>
<title>Variable Text
Example</title>
</head>
<body>
<p><code>document.write("<var>user-
name</var>")</code></p>
</body>
</html>
This will produce the following result −
Program Output
Example
<!DOCTYPE html>
<html>
<head>
<title>Program Output
Example</title>
</head>
<body>
<p>Result produced by the program
is <samp>Hello World!</samp></p>
</body>
</html>
This will produce the following result −
Address Text
The <address>...</address> element is used to
contain any address.
Example
Live Demo
<!DOCTYPE html>
<html>
<head>
<title>Address Example</title>
</head>
<body>
<address>388A, Road No 22,
Jubilee Hills - Hyderabad</address>
</body>
</html>
This will produce the following result −
Name
content
2
Specifies the property's value.
scheme
4 http-equiv
Specifying Keywords
Example
<head>
<title>Meta Tags Example</title>
<meta name = "keywords" content =
"HTML, Meta Tags, Metadata" />
</head>
<body>
<p>Hello HTML5!</p>
</body>
</html>
This will produce the following result −
Object 18
Document Description
Example
Live Demo
<!DOCTYPE html>
<html>
<head>
<title>Meta Tags Example</title>
<meta name = "keywords" content =
"HTML, Meta Tags, Metadata" />
<meta name = "description"
content = "Learning about Meta Tags."
/>
</head>
<body>
<p>Hello HTML5!</p>
</body>
</html>
Example
Live Demo
<!DOCTYPE html>
<html>
<head>
<title>Meta Tags Example</title>
<meta name = "keywords" content =
"HTML, Meta Tags, Metadata" />
<meta name = "description"
content = "Learning about Meta Tags."
/>
<meta name = "revised" content =
"Tutorialspoint, 3/7/2014" />
</head>
<body>
<p>Hello HTML5!</p>
</body>
</html>
Document Refreshing
Example
<head>
<title>Meta Tags Example</title>
<meta name = "keywords" content =
"HTML, Meta Tags, Metadata" />
<meta name = "description"
content = "Learning about Meta Tags."
/>
<meta name = "revised" content =
"Tutorialspoint, 3/7/2014" />
<meta http-equiv = "refresh"
content = "5" />
</head>
<body>
<p>Hello HTML5!</p>
</body>
</html>
Page Redirection
Example
<head>
<title>Meta Tags Example</title>
<meta name = "keywords" content =
"HTML, Meta Tags, Metadata" />
<meta name = "description"
content = "Learning about Meta Tags."
/>
<meta name = "revised" content =
"Tutorialspoint, 3/7/2014" />
<meta http-equiv = "refresh"
content = "5; url =
http://www.tutorialspoint.com" />
</head>
<body>
<p>Hello HTML5!</p>
</body>
</html>
Setting Cookies
Example
</head>
<body>
<p>Hello HTML5!</p>
</body>
</html>
If you do not include the expiration date and time, the
cookie is considered a session cookie and will be
deleted when the user exits the browser.
Note − You can check PHP and Cookies tutorial for a
complete detail on Cookies.
Example
Live Demo
<!DOCTYPE html>
<html>
<head>
<title>Meta Tags Example</title>
<meta name = "keywords" content =
"HTML, Meta Tags, Metadata" />
<meta name = "description"
content = "Learning about Meta Tags."
/>
<meta name = "author" content =
"Mahnaz Mohtashim" />
</head>
<body>
<p>Hello HTML5!</p>
</body>
</html>
<head>
<title>Meta Tags Example</title>
<meta name = "keywords" content =
"HTML, Meta Tags, Metadata" />
<meta name = "description"
content = "Learning about Meta Tags."
/>
<meta name = "author" content =
"Mahnaz Mohtashim" />
<meta http-equiv = "Content-Type"
content = "text/html; charset = UTF-8"
/>
</head>
<body>
<p>Hello HTML5!</p>
</body>
</html>
To serve the static page with traditional Chinese
characters, the webpage must contain a <meta> tag
to set Big5 encoding −
Live Demo
<!DOCTYPE html>
<html>
<head>
<title>Meta Tags Example</title>
<meta name = "keywords" content =
"HTML, Meta Tags, Metadata" />
<meta name = "description"
content = "Learning about Meta Tags."
/>
<meta name = "author" content =
"Mahnaz Mohtashim" />
<meta http-equiv = "Content-Type"
content = "text/html; charset = Big5"
/>
</head>
<body>
<p>Hello HTML5!</p>
</body>
</html>
HTML - Comments
Comment is a piece of code which is ignored by any web
browser. It is a good practice to add comments into your
HTML code, especially in complex documents, to indicate
sections of a document, and any other notes to anyone
looking at the code. Comments help you and others
understand your code and increases code readability.
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.
Example
Live Demo
<!DOCTYPE html>
<html>
<head> <!-- Document Header Starts
-->
<title>This is document
title</title>
</head> <!-- Document Header Ends --
>
<body>
<p>Document content goes
here.....</p>
</body>
</html>
This will produce the following result without
displaying the content given as a part of comments −
Object 22
Example
<head>
<title>Valid Comment
Example</title>
</head>
<body>
<!-- This is valid comment -->
<p>Document content goes
here.....</p>
</body>
</html>
This will produce the following result −
Object 26
<head>
<title>Invalid Comment
Example</title>
</head>
<body>
< !-- This is not a valid
comment -->
<p>Document content goes
here.....</p>
</body>
</html>
This will produce the following result −
Object 27
Multiline Comments
Example
Live Demo
<!DOCTYPE html>
<html>
<head>
<title>Multiline Comments</title>
</head>
<body>
<!--
This is a multiline comment
and it can
span through as many as lines
you like.
-->
</html>
This will produce the following result −
Object 28
Conditional Comments
Example
Live Demo
<!DOCTYPE html>
<html>
<head>
<title>Conditional
Comments</title>
<!--[if IE 6]>
Special instructions for IE 6
here
<![endif]-->
</head>
<body>
<p>Document content goes
here.....</p>
</body>
</html>
You will come across a situation where you will need
to apply a different style sheet based on different
versions of Internet Explorer, in such situation
conditional comments will be helpful.
Using Comment Tag
Example
Live Demo
<!DOCTYPE html>
<html>
<head>
<title>Using Comment Tag</title>
</head>
<body>
<p>This is <comment>not</comment>
Internet Explorer.</p>
</body>
</html>
If you are using IE, then it will produce following result
−
Object 29
Object 30
Example
Live Demo
<!DOCTYPE html>
<html>
<head>
<title>Commenting Script
Code</title>
<script>
<!--
document.write("Hello
World!")
//-->
</script>
</head>
<body>
<p>Hello , World!</p>
</body>
</html>
This will produce the following result −
Object 31
Example
Live Demo
<!DOCTYPE html>
<html>
<head>
<title>Commenting Style
Sheets</title>
<style>
<!--
.example {
border:1px solid
#4a7d49;
}
//-->
</style>
</head>
<body>
<div class = "example">Hello ,
World!</div>
</body>
</html>
This will produce the following result −
Object 32
HTML - Images
Images are very important to beautify as well as to
depict many complex concepts in simple way on your
web page. This tutorial will take you through simple
steps to use images in your web pages.
Insert Image
<head>
<title>Using Image in
Webpage</title>
</head>
<body>
<p>Simple Image Insert</p>
<img src =
"/html/images/test.png" alt = "Test
Image" />
</body>
</html>
This will produce the following result −
Object 33
Example
<head>
<title>Using Image in
Webpage</title>
</head>
<body>
<p>Simple Image Insert</p>
<img src =
"/html/images/test.png" alt = "Test
Image" />
</body>
</html>
This will produce the following result −
Object 34
Set Image Width/Height
Example
Live Demo
<!DOCTYPE html>
<html>
<head>
<title>Set Image Width and
Height</title>
</head>
<body>
<p>Setting image width and
height</p>
<img src =
"/html/images/test.png" alt = "Test
Image" width = "150" height = "100"/>
</body>
</html>
This will produce the following result −
Object 35
Example
Live Demo
<!DOCTYPE html>
<html>
<head>
<title>Set Image Border</title>
</head>
<body>
<p>Setting image Border</p>
<img src =
"/html/images/test.png" alt = "Test
Image" border = "3"/>
</body>
</html>
This will produce the following result −
Object 36
Example
Live Demo
<!DOCTYPE html>
<html>
<head>
<title>Set Image
Alignment</title>
</head>
<body>
<p>Setting image Alignment</p>
<img src =
"/html/images/test.png" alt = "Test
Image" border = "3" align = "right"/>
</body>
</html>
This will produce the following result −
HTML - Tables
The HTML tables allow web authors to arrange data
like text, images, links, other tables, etc. into rows and
columns of cells.
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. The
elements under <td> are regular and left aligned by
default
Example
Live Demo
<!DOCTYPE html>
<html>
<head>
<title>HTML Tables</title>
</head>
<body>
<table border = "1">
<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>
This will produce the following result −
Object 37
Table Heading
Example
Live Demo
<!DOCTYPE html>
<html>
<head>
<title>HTML Table Header</title>
</head>
<body>
<table border = "1">
<tr>
<th>Name</th>
<th>Salary</th>
</tr>
<tr>
<td>Ramesh Raman</td>
<td>5000</td>
</tr>
<tr>
<td>Shabbir Hussein</td>
<td>7000</td>
</tr>
</table>
</body>
</html>
This will produce the following result −
Object 38
Example
Live Demo
<!DOCTYPE html>
<html>
<head>
<title>HTML Table
Cellpadding</title>
</head>
<body>
<table border = "1" cellpadding =
"5" cellspacing = "5">
<tr>
<th>Name</th>
<th>Salary</th>
</tr>
<tr>
<td>Ramesh Raman</td>
<td>5000</td>
</tr>
<tr>
<td>Shabbir Hussein</td>
<td>7000</td>
</tr>
</table>
</body>
</html>
This will produce the following result −
Object 39
Colspan and Rowspan Attributes
Example
Live Demo
<!DOCTYPE html>
<html>
<head>
<title>HTML Table
Colspan/Rowspan</title>
</head>
<body>
<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>
This will produce the following result −
Object 40
Tables Backgrounds
Note − The bgcolor, background,
and bordercolor attributes deprecated in
HTML5. Do not use these attributes.
Example
Live Demo
<!DOCTYPE html>
<html>
<head>
<title>HTML Table
Background</title>
</head>
<body>
<table border = "1" bordercolor =
"green" bgcolor = "yellow">
<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>
This will produce the following result −
Object 41
<head>
<title>HTML Table
Background</title>
</head>
<body>
<table border = "1" bordercolor =
"green" background =
"/images/test.png">
<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>
This will produce the following result. Here
background image did not apply to table's header.
Object 42
Example
Live Demo
<!DOCTYPE html>
<html>
<head>
<title>HTML Table
Width/Height</title>
</head>
<body>
<table border = "1" width = "400"
height = "150">
<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>
This will produce the following result −
Object 43
Table Caption
Example
Live Demo
<!DOCTYPE html>
<html>
<head>
<title>HTML Table Caption</title>
</head>
<body>
<table border = "1" width =
"100%">
<caption>This is the
caption</caption>
<tr>
<td>row 1, column
1</td><td>row 1, columnn 2</td>
</tr>
<tr>
<td>row 2, column
1</td><td>row 2, columnn 2</td>
</tr>
</table>
</body>
</html>
This will produce the following result −
Object 44
Example
Live Demo
<!DOCTYPE html>
<html>
<head>
<title>HTML Table</title>
</head>
<body>
<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>
</tbody>
</table>
</body>
</html>
This will produce the following result −
Object 45
Nested Tables
You can use one table inside another table. Not only
tables you can use almost all the tags inside table
data tag <td>.
Example
<head>
<title>HTML Table</title>
</head>
<body>
<table border = "1" width =
"100%">
<tr>
<td>
<table border = "1"
width = "100%">
<tr>
<th>Name</th>
<th>Salary</th>
</tr>
<tr>
<td>Ramesh
Raman</td>
<td>5000</td>
</tr>
<tr>
<td>Shabbir
Hussein</td>
<td>7000</td>
</tr>
</table>
</td>
</tr>
</table>
</body>
</html>
This will produce the following result −
Object 46
HTML - Lists
HTML offers web authors three ways for specifying
lists of information. 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 your items.
•<dl> − A definition list. This arranges your items
in the same way as they are arranged in a
dictionary.
Example
Live Demo
<!DOCTYPE html>
<html>
<head>
<title>HTML Unordered
List</title>
</head>
<body>
<ul>
<li>Beetroot</li>
<li>Ginger</li>
<li>Potato</li>
<li>Radish</li>
</ul>
</body>
</html>
This will produce the following result −
Object 47
Example
<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>
This will produce the following result −
Object 48
Example
<head>
<title>HTML Unordered
List</title>
</head>
<body>
<ul type = "disc">
<li>Beetroot</li>
<li>Ginger</li>
<li>Potato</li>
<li>Radish</li>
</ul>
</body>
</html>
This will produce the following result −
Object 49
Example
<head>
<title>HTML Unordered
List</title>
</head>
<body>
<ul type = "circle">
<li>Beetroot</li>
<li>Ginger</li>
<li>Potato</li>
<li>Radish</li>
</ul>
</body>
</html>
This will produce the following result −
Object 50
HTML Ordered Lists
Example
Live Demo
<!DOCTYPE html>
<html>
<head>
<title>HTML Ordered List</title>
</head>
<body>
<ol>
<li>Beetroot</li>
<li>Ginger</li>
<li>Potato</li>
<li>Radish</li>
</ol>
</body>
</html>
This will produce the following result −
Object 51
Example
<body>
<ol type = "1">
<li>Beetroot</li>
<li>Ginger</li>
<li>Potato</li>
<li>Radish</li>
</ol>
</body>
</html>
This will produce the following result −
Object 52
Example
<head>
<title>HTML Ordered List</title>
</head>
<body>
<ol type = "I">
<li>Beetroot</li>
<li>Ginger</li>
<li>Potato</li>
<li>Radish</li>
</ol>
</body>
</html>
This will produce the following result −
Object 53
Example
<head>
<title>HTML Ordered List</title>
</head>
<body>
<ol type = "i">
<li>Beetroot</li>
<li>Ginger</li>
<li>Potato</li>
<li>Radish</li>
</ol>
</body>
</html>
This will produce the following result −
Object 54
Example
<head>
<title>HTML Ordered List</title>
</head>
<body>
<ol type = "A">
<li>Beetroot</li>
<li>Ginger</li>
<li>Potato</li>
<li>Radish</li>
</ol>
</body>
</html>
This will produce the following result −
Object 55
Example
<head>
<title>HTML Ordered List</title>
</head>
<body>
<ol type = "a">
<li>Beetroot</li>
<li>Ginger</li>
<li>Potato</li>
<li>Radish</li>
</ol>
</body>
</html>
This will produce the following result −
Object 56
<head>
<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>
This will produce the following result −
Object 57
Live Demo
<!DOCTYPE html>
<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>
This will produce the following result −
Object 58
HTML - Text Links
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. Thus
you can create hyperlinks using text or images
available on a webpage.
Note − I recommend you to go through a short tutorial
on Understanding URL
Linking Documents
Example
<head>
<title>Hyperlink Example</title>
</head>
<body>
<p>Click following link</p>
<a href =
"https://www.tutorialspoint.com" target
= "_self">Tutorials Point</a>
</body>
</html>
This will produce the following result, where you can
click on the link generated to reach to the home page
of Tutorials Point (in this example).
Object 59
The target Attribute
_blank
_self
_parent
4 _top
Opens the linked document in the
full body of the window.
targetframe
Example
<head>
<title>Hyperlink Example</title>
<base href =
"https://www.tutorialspoint.com/">
</head>
<body>
<p>Click any of the following
links</p>
<a href = "/html/index.htm"
target = "_blank">Opens in New</a> |
<a href = "/html/index.htm"
target = "_self">Opens in Self</a> |
<a href = "/html/index.htm"
target = "_parent">Opens in Parent</a>
|
<a href = "/html/index.htm"
target = "_top">Opens in Body</a>
</body>
</html>
This will produce the following result, where you can
click on different links to understand the difference
between various options given for target attribute.
Object 60
Example
<head>
<title>Hyperlink Example</title>
<base href =
"https://www.tutorialspoint.com/">
</head>
<body>
<p>Click following link</p>
<a href = "/html/index.htm"
target = "_blank">HTML Tutorial</a>
</body>
</html>
This will produce the following result, where you can
click on the link generated HTML Tutorial to reach to
the HTML tutorial.
Now given URL <a href = "/html/index.htm" is being
considered as <ahref =
"http://www.tutorialspoint.com/html/index.htm"
Object 61
Example
<head>
<title>Hyperlink Example</title>
<base href =
"https://www.tutorialspoint.com/">
</head>
</html>
This will produce the following result. Just check color
of the link before clicking on it, next check its color
when you activate it and when the link has been
visited.
Object 62
Download Links
<head>
<title>Hyperlink Example</title>
</head>
<body>
<a href =
"https://www.tutorialspoint.com/page.pd
f">Download PDF File</a>
</body>
</html>
This will produce following link and will be used to
download a file.
Object 63
File Download Dialog Box
Example
<head>
<title>Image Hyperlink
Example</title>
</head>
<body>
<p>Click following link</p>
<a href =
"https://www.tutorialspoint.com" target
= "_self">
<img src = "/images/logo.png"
alt = "Tutorials Point" border = "0"/>
</a>
</body>
</html>
Default Settings
HTML - Frames
HTML frames are used to divide your browser window into
multiple sections where each section can load a separate
HTML document. A collection of frames in the browser
window is known as a frameset. The window is divided into
frames in a similar way the tables are organized: into rows
and columns.
Disadvantages of Frames
Example
<head>
<title>HTML Frames</title>
</head>
<frameset rows = "10%,80%,10%">
<frame name = "top" src =
"/html/top_frame.htm" />
<frame name = "main" src =
"/html/main_frame.htm" />
<frame name = "bottom" src =
"/html/bottom_frame.htm" />
<noframes>
<body>Your browser does not
support frames.</body>
</noframes>
</frameset>
</html>
This will produce the following result −
Object 64
Example
<head>
<title>HTML Frames</title>
</head>
<noframes>
<body>Your browser does not
support frames.</body>
</noframes>
</frameset>
</html>
This will produce the following result −
Object 65
The <frameset> Tag Attributes
1 cols
rows
3 border
frameborder
framespacing
src
name
3 frameborder
marginwidth
marginheight
6 noresize
scrolling
longdesc
<head>
<title>HTML Target Frames</title>
</head>
<frameset cols = "200, *">
<frame src = "/html/menu.htm"
name = "menu_page" />
<frame src = "/html/main.htm"
name = "main_page" />
<noframes>
<body>Your browser does not
support frames.</body>
</noframes>
</frameset>
</html>
Here, we have created two columns to fill with two
frames. The first frame is 200 pixels wide and will
contain the navigation menu bar implemented
by menu.htm file. The second column fills in
remaining space and will contain the main part of the
page and it is implemented by main.htm file. For all
the three links available in menu bar, we have
mentioned target frame as main_page, so whenever
you click any of the links in menu bar, available link
will open in main page.
Following is the content of menu.htm file
Live Demo
<!DOCTYPE html>
<html>
<a href =
"http://www.microsoft.com" target =
"main_page">Microsoft</a>
<br />
<br />
</html>
Following is the content of main.htm file −
Live Demo
<!DOCTYPE html>
<html>
<body bgcolor = "#b5dcb3">
<h3>This is main page and content
from any link will be displayed
here.</h3>
<p>So now click any link and see
the result.</p>
</body>
</html>
When we load test.htm file, it produces following
result −
Object 66
Now you can try to click links available in the left panel
and see the result. The targetattribute can also take
one of the following values −
Sr
.N Option & Description
o
_self
1
Loads the page into the current frame.
_blank
_parent
_top
targetframe
5
Loads the page into a named targetframe.
HTML - Iframes
ou can define an inline frame with HTML tag <iframe>.
The <iframe> tag is not somehow related to <frameset>
tag, instead, it can appear anywhere in your document. The
<iframe> tag defines a rectangular region within the
document in which the browser can display a separate
document, including scrollbars and borders. An inline
frame is used to embed another document within the
current HTML document.
The src attribute is used to specify the URL of the
document that occupies the inline frame.
Example
<head>
<title>HTML Iframes</title>
</head>
<body>
<p>Document content goes
here...</p>
</html>
This will produce the following result −
Object 67
The <Iframe> Tag Attributes
Note −
The frameborder, marginwidth, longdesc, scr
olling, marginheight attributes deprecated in
HTML5. Do not use these attributes.
Sr
.N Attribute & Description
o
src
2 name
This attribute allows you to give a name to a
frame. It is used to indicate which frame a
document should be loaded into. This is
especially important when you want to create
links in one frame that load pages into an
another frame, in which case the second frame
needs a name to identify itself as the target of
the link.
frameborder
4 marginwidth
marginheight
height
6
This attribute specifies the height of <iframe>.
scrolling
8 longdesc
width
9
This attribute specifies the width of <iframe>.
HTML - Blocks
All the HTML elements can be categorized into two
categories (a) Block Level Elements (b)Inline Elements.
Block Elements
Inline Elements
Example
<head>
<title>HTML div Tag</title>
</head>
<body>
<!-- First group of tags -->
<div style = "color:red">
<h4>This is first group</h4>
<p>Following is a list of
vegetables</p>
<ul>
<li>Beetroot</li>
<li>Ginger</li>
<li>Potato</li>
<li>Radish</li>
</ul>
</div>
<ul>
<li>Apple</li>
<li>Banana</li>
<li>Mango</li>
<li>Strawberry</li>
</ul>
</div>
</body>
</html>
This will produce the following result −
Object 68
Example
<head>
<title>HTML span Tag</title>
</head>
<body>
<p>This is <span style =
"color:red">red</span> and this is
<span style =
"color:green">green</span></p>
</body>
</html>
This will produce the following result −