Understanding HTML Basics and Structure
Understanding HTML Basics and Structure
Chapter Number 4
• Hypertext Markup Language is the standard markup
language for creating web pages and web applications.
• It is a versatile markup language that is used to publish
information as a Web page.
• This markup tells a web browser how to display the text,
images and other forms of multimedia on a webpage.
• It Provides tags that help in creating Web pages.
• HTML elements are represented by tags.
• HTML is not case sensitive language.
• Allows the creation of hyperlinks to connect the Web
pages.
A markup language:
Enables you to create attractive and interactive
websites.
Provides a way to describe the structure of a Web
page.
Specifies the code in the form of tags for defining,
processing, and presenting the
text on Web pages.
Hypertext is text which is not constrained to be
linear
Hypertext is text which contains links to other
texts.
Basic Terminology
The Internet:
Makes the Web pages and websites accessible to the users.
Enables the organizations to share and access information.
Is an interconnected network of computers across the globe.
The World Wide Web (WWW):
Is a collection of resources on varied topics that can be accessed
through the Internet.
Is a collection of Web pages that are scattered but interlinked.
URL – Uniform Resource Locator.
Browser – A software program which is used to show web
[Link] Google chrome,internet explorer mozilla
firefox etc.
……..
• A website (also written as web site) is a collection of web
pages.
• A web page: A document which can be displayed to a user
in a web browser . It is a specific collection of information
provided by a website .
• Static web page:
Prebuilt content is same every time the page is loaded.
It uses the HTML code for developing a website.
• Dynamic web page:
Content is generated quickly and changes regularly .
It uses the server side languages such as PHP,SERVLET,
JSP, and [Link] etc. for developing a website.
History of HTML
• Developed by Tim Berners-Lee
Version Year
HTML 1991
HTML+ 1993
HTML 2.0 1995
HTML 3.2 1997
HTML 4.01 1999
XHTML 2000
HTML5 2012
HTML 5.1 2016
HTML 5.2 2017
HTML 5.3(DRAFT VERSION)
• The HTML Tag
• The HEAD Tag
• The TITLE Tag
• The BODY Tag
• Element
<font color=“green”>
HTML Page Structure
Below is a visualization of an HTML
page structure:
HTML Doc Structure
<HTML
<HEAD>
<TITLE>
</TITLE>
</HEAD>
<BODY>
</BODY>
</HTML>
Creating an HTML Document
[Link]
<html>
<head>
<title>Page Title</title>
</head>
<body>
<h1>My First Heading</h1>
<p>My First Paragraph.</p>
</body>
</html>
Output of program
HTML Color Coding Methods
alink Vlink
link
HTML tags are of two types:
What is a list?
A list is a record of short pieces of information,
such as people’s names, usually written or
printed with a single thing on each line and
ordered in a way that makes a particular thing
easy to find.
Types of List in HTML
There are four list types in HTML
• Ordered List
• Unordered list
• Definition List
• Nested List
Ordered List
• Type:
It specifies the numbering scheme for the list.
The default number scheme is numbers 1,2,3…..
Other possible schemes are:
1 (numbers)for 1,2,3……..
A (uppercase letters)for A,B,C…….
a (lowercase letters)for a,b,c……..
l (uppercase Roman numerals)for l,ll,lll………
i (lowercase Roman numerals)for i,ii,iii……..
• Start:
It specifies the starting number of the list.
Examples
Type attributes:
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”.
Example with start atrribute:
• <ol type=“i” start=“5”>
• <li>HTML</li>
• <li>Java</li>
• <li>JavaScript</li>
• <li>SQL</li>
• </ol>
• Output:
[Link]
[Link]
[Link]
[Link]
Unordered List in HTML
• An unordered list is a list of items in which
each item is marked with a symbol.
• An unordered list is also known as an
“unnumbered list”.
• <ul> tag is used to create an unordered list. It
stands for an unordered list.
• <li> tag is used with each item in the list.
• </ul> tag is used to close an unordered list.
type Attributes of <ul> tag
• 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 ="square“:
In this style, the list items are marked with squares.
• type ="none“:
In this style, the list items are not marked .
Example of default<ul> or type=“disc”:
Type=“circle” example:
Type=“square” example:
Home work
Revision:
Definition List in HTML
Excercise 2
Home Work
Nested List (Lists within lists)
sapce
Character formatting
Character formatting
<small>.........</small>
<html> This is Plain Text.
<head> This is small plain text
<title>small</title>
</head>
<body>
This is Plain Text.<br>
<small>This is small plain
text</small>
</body>
</html>
Big tag<big>:
• big tag is represented by <big> tag.
• This tag is used to display the written text in one
larger than the normal text size.
• HTML uses this tag to increase the size of the
text.
• This tag has same effect as <font size=“+1”>
• Syntax:
<big>.........</big>
<html> This is Plain Text.
<head> This is big plain text
<title>big</title>
</head>
<body>
This is Plain Text.<br>
<big> This is big plain text</big>
</body>
</html>
Strike tag<strike> or <s>:
• Strike tag is represented by <strike> tag.
• This tag is used to display the written text with line
drawn through middle of the text.
• Syntax:
<strike>.........</strike>
Example:
• Output:
This is not a valid paragraph
This is a valid paragraph
marquee tag<big>:
• marquee tag is represented by <marquee> tag.
• This tag is used to scroll a image or text horizontally or
vertically..
• In simple words, we can say that it scrolls the image or text
up, down, left or right automatically.
• This is used to scroll the current news or position of different
companies in stock market.
• By default it scroll from right to left.
• Syntax:
<marquee>………</marquee>
Attributes Marquee tag.
1. Direction:
defines direction for scrolling content. It may be left,
right, up and down.
2. Behavior:
it facilitates user to set the behavior of the marquee
to one of the three different types: scroll, slide and
alternate.
3. Height:
defines height of marquee in pixels or %.
4. width:
defines width of marquee in pixels or %.
<html>
<head>
<title>big</title>
</head>
<body>
<marquee>
This sentence scroll from right to
left.
</marquee>
<marquee direction="down">
This sentence scroll from top to bottom.
</marquee>
</body>
</html>
Example 2
<html>
<head>
<title>big</title>
</head>
<body bgcolor="magenta">
<marquee direction="right">
<img src="[Link]" alt="Home">
</marquee>
</body>
</html>
output
Hr tag<hr>
• The <hr> tag in HTML stands for horizontal
rule .
• <hr> tag is used for creating a horizontal line
• The <hr> tag is an empty tag and it does not
require an end tag.
• A web page can be divided into seperate
sections by using <hr>
• This tag is mostly used for decorative
purposes.
• Syntax: <hr> or <hr/>
<html>
<head>
<title>big</title>
This is First Line
</head>
<body>
This is Second Line
This is Third Line
This is First Line <hr>
This is Second Line
<hr size=“10” width=“100%” color=“red”>
This is Third Line.
</body>
</html>
br tag<br>
• The <br> tag in HTML stands for line break or
break.
• The <br> tag in HTML is used to give the single
line break .
• It is use to break the continue line.
• The <br> tag is an empty tag and it does not
require an end tag.
• If you place the <br> tag in the HTML code, then
it works the same as pressing the enter key in a
word processor.
• Syntax:
<br> or <br/>
Example
Output:
<html>
<head>
Jai
<title>big</title>
Shree
</head>
Ram
<body>
Jai<br>Shree<br>Ram
</body>
</html>
Paragraph tag<p>
• paragraph tag is represented by <p> tag.
• <P> tag is used to define a paragraph in a webpage.
• a browser itself add an extra blank line before and after
a paragraph.
• paragraph always starts on a new line.
• </p> is optional
• Atrributes : align
• Value:
• left,right,center
• Syntax:
<p align=“value”>………</p>
Example: Output:
<html>
Here is a first paragraph of text.
<head>
<title>Paragraph Example Here is a second paragraph of text.
</title>
</head> Here is a third paragraph of text.
<body>
<p>Here is a first paragraph of text.</p>
<p>Here is a second paragraph of text.</p>
<p>Here is a third paragraph of text.</p>
</body>
</html>
Heading tag <Hn>:
• heading tag can be used to defined as a title or a
subtitle which you want to display on the webpage.
• There are six levels of headings,from <h1> to <h6>.
• <h1> defines largest heading and
<h6> defines smallest heading.
• The <h1> heading is the first heading in the
document.
• The <h1> heading is usually a large bolded font.
• Syntax: <h1>...</h1>
to
<h6>...</h6>
atrributes
Align(default is left)
• Values:
• Left,right,center, justify
Syntax:
<h1 align = left|center|right|justify>Heading</h1>
“Html automatically adds extra blank line before and after a
heading”
Example: Output:
<html>
<head> Heading level 1
<title>Paragraph Example Heading level 2
</title> Heading level 3
</head> Heading level 4
<body> Heading level 5
<h1>Heading level 1</h1> Heading level 6
<html>
<head> #include "iostream.h"
<title>Paragraph Example #include "conio.h"
</title> void main()
</head> {
<body> clrscr();
<pre> cout<<"Hello world";
#include ”iostream.h” getch();
#include ” conio.h” }
void main()
{
clrscr();
cout<<“Hello world”<<endl;
getch();
}
</pre>
</body>
</html>
address tag <address>
• The <address> tag defines the contact
information for the author/owner of a
document or an article,signature etc.
• Browsers traditionally render the text found
within the <address> tag as italicized text.
• The <address> element often appears at the
beginning(top) or end(bottom) of a document.
• It cannot contain p,blockquote,form etc.
• Example:
<address> …. </address>
Example: Output:
</head>
<body>
<address> You can contact us at:<br>
[Link]<br> 123 Sawarkar Nagr
St. GVM High School<br>
City:Thane, State:Maharashtra
<br>Pin code:400606.
</address>
</body>
</html>
font tag <font>
• <font> tag is used to define the font style for the text
contained within it.
• It defines the font size, color, and face or the text in an HTML
document.
• This tag has been deprecated in HTML 4.01. It has been
removed in HTML5 and shouldn't be used anymore
• Atrributes of <font> tag:
• Color
• Face
• size
Syntax: <font size="number" color="color"
face="font-family, ..."> ... </font>
Example: Output:
• Syntax:
<em>…………….…</em>
• Example:
<p> This is an <em> important point </em> to consider.</p>
<p>you <em> must <em> handover the money to them.
• output:
This is an important point to consider.
you must handover the money to them
Strong tag<strong>:
• <STRONG> is also a logical tag
• It is used to strongly emphasize text.
• <STRONG> is distinct from <EM>.
• In most browsers, STRONG is identical to boldface.
• Syntax:
<strong>…………….…</strong>
• Example:
• Do <strong> NOT</strong>, be late again!
• output:
• Do NOT, be late again!
Difference between strong and bold
tag
• Strong element is used to provide emphasis
aurally for visually impaired or illitrate people
who surf the web page using screen
[Link] bold element is used to provide
emphasis visually.
variable tag<var>:
• The <var> tag is used to defines a variable in
programming or in a mathematical expression
• The content inside is typically displayed in italic.
• Syntax:
Example: <var>………</var>
<p> Einstein's equation: <var> E </var> = <var> m </var>
<var> c </var> <sup> 2 </sup> </p>
Output:
• Einstein's equation:
E=mc2
code tag<code>:
• The <code> tag is used to define a piece of computer code.
• The CODE tag displays text in the browser's default fixed-
width font(monospace).
Syntax:
<code>………</code>
Example:
<p>
To declare an integer in C++:<br>
<code> int x = 10; </code>
</p>
Output:
To declare an integer in C++:
int x=10;
Image formats:
• JPEG
• GIF
• PNG
• BMP
• JPEG (.jpg, .jpeg)
Joint Photographic Experts Group is a loss-prone (lossy) format in which data is lost to reduce size
of image. Due to compression, some data is lost but that loss is very less. It is a very common
format and are good for digital cameras, nonprofessional prints, E-Mail, Powerpoint etc., making it
ideal for web use.
• GIF (.gif)
GIF or Graphics Interchange Format files are used for web [Link] can be animated and are
limited to only 256 colors, can allow for transparency. GIF files are typically small is size and are
portable.
• PNG (.png)
PNG or Portable Network Graphics files are a lossless image format. It was designed to replace gif
format as gif supported 256 colors unlike PNG which support 16 million colors.
• Bitmap (.bmp)
Bit Map Image file is developed by Microsoft for windows. It is same as TIFF due lossless, no
compression property. Due to BMP being a proprietary format, it is generally recommended to use
TIFF files.
image tag<image>:
• Syntax:
<img src="url" alt="alternatetext">
Other attributes
• border: Specifies the width of the border around
the image.
• height: Specifies the height of the image
• width: Specifies the width of the image
• align: Specifies the alignment of an
image(left,right,top,middle,bottom)
• hspace: Specifies the amount of whitespace on
left and right side of an image.
• vspace: Specifies the amount of whitespace on
top and bottom side of the image.
• The value of the alt attribute should describe
the image:
• If a browser cannot find an image, it will
display the value of the alt attribute
example
Example2
Different Image path:
• <img src="[Link]">:
The "[Link]" file is located in the same folder
as the current page
• <img src=“D:/CS1/HTML/[Link]">:
The "[Link]" file is located in the diferent
folder.
• <img src=“[Link] [Link] ">:
The "[Link]" file is located in internet
location.
Hyperlink (link)in Html
• Hyperlink:It is pointer to another documents
• When we click on a link it jump to another
document.
• When we move the mouse over a link, the
mouse arrow will turn into a little hand.
Anchor tag<a>
• <TR> Tag
• TR stands for TABLE ROW. As the name shows, <TR> tag is used to create a
row in a table.
• A row is started by <TR> tag and is closed by </TR> tag.
• There are one or more <TD> or <TH> tags between <TR> and </TR> tags to
create cells.
Attributes.
• align(Left,center and right)
Example 1:
• <TR>
<TD>1</TD>
<TD>Ahmad</TD>
</TR>
Example 1
Caption tag<caption>
• The CAPTION element is placed immediately
after the TABLE start tag.
• The CAPTION element defines a caption for a
table.i.e. The tag is used to give heading to the
whole table.
• This tag defines caption for title of table.
• The caption text is displayed at the top of the
table.
• <caption>table
Syntax: caption</caption>
Example
<table border=“1”>
<caption>Dogs age</caption>
<tr>
<th>Dog</th>
<th>Age</th>
</tr>
<table>.
• The align attribute of the CAPTION
element specifies the alignment of the table
caption.
• <caption align="left">table caption</caption>
Caption attribute values
Program1
Program2
<TD> Tag
• <TD> Tag:
• <TD> tag is used to create a cell.
• TD stands for TABLE DATA. The number of cells in a row will specify number of columns in a table.
• The data to be shown in a cell is placed between <TD> and </TD> tags.
• A row is started by <TR> tag and is closed by </TR> tag.
• There are one or more <TD> or <TH> tags between <TR> and </TR> tags to create cells.
• By default data the text in cell is aligned left.
• Attribute name
• Rowspan
• Colspan
• Background
• Bgcolor
• align
Example :
• <TR>
<TD> 1 </TD>
<TD> Ahmad </TD>
</TR>
<TH> Tag
<TH> Tag:
• <TH> tag is used to create a header row in a table.
• TH stands for TABLE [Link] <TH> tag makes one header cell.
• The data to be shown in header cell is placed between <TH> and </TH>
tags.
• By default text in the cell is bold and centered.
• Attributes:
• rowspan
• colspan
Example :
• <TR>
<TH> Roll Number </TH>
<TH> Name </TH>
<Th >Marks </TH>
</TR>
rowspan attribute
• Rowspan attribute can merge two more
rows(vertically) in a table.
• If you want to merge 2 or more rows into a single
row, use rowspan.
• Align
• Bgcolor
• Border
• Cellpadding
• Cellspacing
• Height
• Width
ALIGN Attribute
example
Height attributes
• This attributes specifies the height of the table.
• The default is the optiml height determined by
content s of each cell.
• Width attributes:
• This attributes specifies the width of the table.
• Defines the space between the cell wall and the
cell content.
• Syntax:
• <table height=“value” width=“value”>…</table>
Example width
example
Note: