HTML Hyper Text Markup Language
HTML Hyper Text Markup Language
HTML Hyper Text Markup Language
What is HTML
Hyper Text Markup language or HTML, is the standard language on Web, used to build a website or
web application. HTML is a markup language, as it contains markup tags or tags. HTML is used to
write content or structure of web pages. HTML is not a programming language.
HTML is browser embedded. To Design or build a website, one should starts with HTML first. HTML
includes 140+ tags and attributes to build layout. The latest version of html is HTML5, which included
HTML, CSS and JavaScript. HTML and CSS are static, while JavaScript is dynamic.
HTML Invention
HTML was invented in 1990 by a CERN scientist Tim Berners-Lee. The purpose to invent HTML was
to make it easier for research scientists and professors at different universities around world to gain access
to each other's research works. The project became a bigger success than Tim Berners-Lee had ever
imagined. By inventing HTML, he laid the foundation for the web as we know it today. HTML language
makes it possible to present information (e.g. scientific research) on the Internet.
What you see when you view a page on the Internet is your browser's interpretation of HTML. To see the
HTML code of a page on the Internet, simply click "View" in the top menu of your browser and choose
"Source". Or press ctrl + u, or Cmd + Alt + u
<!DOCTYPE html>
<html lang="en">
<head>
<title>Your Title</title>
<meta charset="UTF-8">
</head>
<body>
//Content of your webpage
</body>
</html>
HTML Comments
HTML Comments are used to write messages or notifications for web developers. Comments are started
with <!-- and ends with -->. These comments are not visible in browsers, but remain in page source code.
A block level element can have both inline and block elements as children or descendent, but inline elements can
have only inline elements as children. (Except anchor tag).
What is Doctype
An HTML page is started by doctype. Doctype defines the type of web document we are using. Doctype
includes the version of HTML and its DTD. Website will not be fully functional without doctype in
Internet Explorer lower versions.Doctype is always declared before HTML opening tag
Example
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8" >
<title>HTML5 Doctype</title>
</head>
<body>
HTML5 Webpage
</body>
</html>
HTML Tags
Every Thing in HTML is written in tags. Mostly commonly used tags are PAIR TAGS. Like HTML,
HEAD, BODY, TITLE, ETC.Pair Tags are written in pairs, means separate opening and closing tag. Both
are written same except the closing or end tags include slash(/) or Forward Slash. Some Non Pair tags are
also there, like <img >, <meta > <input > <link >, <br >, <hr >
HTML Tags
The HTML <HTML> Tag is the only Element containing complete HTML Document.
Each HTML Document should have a HTML Opening and HTML Closing Tag.
Two Direct Child of an HTML Element are;
• Head Tag
• Body Tag
EXAMPLE:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title> Title of the webpage </title>
</head>
<body>
// content of webpage
</body>
</html>
HEAD Tag
HTML Head tag is the first child of HTML Element. It Contains all information related to webpage, css
links, scripts and meta tags.
• Title Tag
• Meta Tags
• Link Tags
• Script Tags
EXAMPLE:
<!DOCTYPE html>
<head>
<title> Title of the webpage </title>
<meta charset="utf-8" >
<meta name="keywords" content="Keywords of your website" >
<meta name="description" content="Search Description of your website" >
<link href="style.css" rel="stylesheet" >
<script >
script Goes Here
<script/>
</head>
BODY Tag
HTML Body Tag is used to define the body of our HTML Document
The Body Tag contains all visible contents of a web page like paragraph, headings, tables, lists, images,
videos etc.
By Default, body is 100% wide and takes a margin of 8px.
EXAMPLE:
<body>
Complete Website Structure will be created inside
</body>
Attributes in HTML
HTML elements can have attributes. Attributes provide additional information about an element.
Attributes are always specified in the start tag. Attributes come in name/value pairs like: name="value".
List of Attributes in html
Attribute Name Description Example
bgcolor Background Color of the document <body bgcolor="aqua">
background Background Image of the document <body background="img/bg.png">
align Align left, right, center <p align="center">
valign Align top, middle, bottom <p valign="middle">
cellspacing change space (margin) between table cells <table cellspacing="10px">
cellpadding inner space ( padding) between table cells <table cellspacing="10px">
size Declare size of font and input <input size="4">
bottom margin Margin from bottom <body bottommargin="20">
top margin Margin from top <body topmargin="10">
class Specifies a class name for an element <div class="content">
id Specifies a unique id for an element <div id="banner">
CSS attribute for tags (Specifies an inline <div style="color:red">
style
style for an element)
Specifies extra information about an element <img src="img/logo.png" alt="Tech
Altum" title="Welcome to Tech Altum
title
(displayed as a tool tip) Tutorial">
type specify type of input control. <input type="text">
lang language used in text <p lang="es">Holla amigo</p>
source of media tags like image, iframe,
src <img src="pic.jpg" alt="">
audio and video
Bgcolor
Used to give background color to body tag and table tag.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>title</title>
</head>
<body bgcolor="#999000">
// content
</body>
</html>
Background
Used to give background image in html4 for body element.
EXAMPLE:
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>title</title>
</head>
<body background="http://www.techaltum.com/images/TechAltumLogo.png">
// content
</body>
</html>
Align
Align Attribute is used to horizontally align text or tables.
size Attribute is used define size to font tag and input tag.
Class
Class attribute is used to define a group of elements having same css properties. Class can have single or
multiple values with whitespace separation.
<style>
.red{ color:red}
.bold{ font-weight:bold}
</style>
<p class="red bold" > Font with class red and bold</p>
<p class="red" > Font with class red only</p>
<p> Font without class red</p>
OUTPUT:
Font with class red and bold
Font with class red
Font without class red
ID
Id attribute is used to call a unique element. On a single webpage, an id cannot be repeated. An html
element can have a single ID attribute and single value of id.
ID Attribute Code
<style>
.red{ color:red}
#blue{ color:blue}
</style>
OUTPUT:
HTML Headings
HTML includes 6 headings. <h1>, <h2>, <h3>, <h4>, <h5> and <h6>. Heading elements are used to write
headings on a webpage, whereas p tag is only for plain text. All Headings are bold and block level
elements.
Heading 1 ( <h1>)
Heading 2 ( <h2>)
Heading 3 ( <h3>)
Heading 4 ( <h4>)
Heading 5 ( <h5>)
Heading 6 ( <h6>)
Headings Code
<h1> Heading 1 </h1>
HTML Images
HTML includes images from its 4th version (HTML-4) ie since 1998. Images enhance the look and feel of
a website. We uses images as a logo, banner, icons, symbols, product etc.
HTML List
There are three types of list in HTML, unordered lists , ordered lists & description list.
Unordered lists and ordered lists work the same way, except that the Unordered is used for non-
sequential lists with list items usually preceded by bullets and the letters is for Ordered List, which are
normally represented by incremental numbers.
The ul tag is used to define unordered list and the ol tag is used to define ordered list. Inside the list, the
li tag is used to define each list item.
1. Unordered List
2. Ordered List
3. Description List
Unordered List
Unordered List are list without counting. By default, unordered list are styled with disk. Till html4, type
attribute was used to change list style. But in HTML5, type attribute of unordered list is deprecated. But
we can remove or change list style using CSS.
• List 1
• List 2
• List 3
• List 4
<ul>
<li>List 1</li>
<li>List 2</li>
<li>List 3</li>
<li>List 4</li>
</ul>
• List 1
• List 2
• List 3
• List 4
<ul type="none">
<li>List 1</li>
<li>List 2</li>
<li>List 3</li>
<li>List 4</li>
</ul>
▪ List 1
▪ List 2
▪ List 3
▪ List 4
<ul type="square">
<li>List 1</li>
<li>List 2</li>
<li>List 3</li>
<li>List 4</li>
</ul>
o List 1
o List 2
o List 3
o List 4
<ul type="circle">
<li>List 1</li>
<li>List 2</li>
<li>List 3</li>
<li>List 4</li>
</ul>
• List 1
• List 2
• List 3
o List 31
o List 32
• List 4
<ul>
<li>List 1</li>
<li>List 2</li>
<li>List 3
<ul>
<li>List 31</li>
<li>List 32</li>
</ul>
</li>
<li>List 4</li>
</ul>
Ordered List
Ordered list use numbers, alphabets and Roman characters. Ordered list are countable. By default,
ordered list are styled with numbers. We can change list style using type attribute or css.
1. List 1
2. List 2
3. List 3
4. List 4
<ol>
<li>List 1</li>
<li>List 2</li>
<li>List 3</li>
<li>List 4</li>
</ol>
I. List 1
II. List 2
III. List 3
IV. List 4
<ol type="I">
<li>List 1</li>
<li>List 2</li>
<li>List 3</li>
<li>List 4</li>
</ol>
i. List 1
ii. List 2
iii. List 3
iv. List 4
<ol type="i">
<li>List 5</li>
<li>List 6</li>
<li>List 7</li>
<li>List 8</li>
</ol>
A. List 1
B. List 2
C. List 3
D. List 4
<ol type="A">
<li>List 1</li>
<li>List 2</li>
<li>List 3</li>
<li>List 4</li>
</ol>
a. List 1
b. List 2
c. List 3
d. List 4
<ol type="a">
<li>List 1</li>
<li>List 2</li>
<li>List 3</li>
<li>List 4</li>
</ol>
10. List 1
11. List 2
12. List 3
13. List 4
<li>List 1</li>
<li>List 2</li>
<li>List 3</li>
<li>List 4</li>
</ol>
X. List 5
Y. List 6
Z. List 7
<li>List 5</li>
<li>List 6</li>
<li>List 7</li>
</ol>
Description List
Description List, formerly known as Definition List is a list with description term and description data.
DATABASE
<dl>
<dt>WEB DESIGNING</dt>
</dl>
<dl>
<dt>DATABASE</dt>
</dl>
HTML Form
<fieldset>
<legend> Enquiry Form</legend>
<form action="" >
<label>Name:<input type="text"></label>
<input type="reset">
<input type="submit">
</form>
</fieldset>
<fieldset disable>
<legend> Enquiry Form</legend>
<form action="" >
<label>Name:<input type="text"></label>
<input type="reset">
<input type="submit">
</form>
</fieldset>
Input Element
The most important form element is the input element.
The input element is used to get 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.
Attributes in input element
Attribute
values Use
Name
text, password, radio, checkbox, file, button,
type type defines type of input control.
submit, and reset
size default value is 20 change size of input control
used to define a sequence followed by user when he
tabindex any numeric value
navigate using Tab key
value any possible value set a default value of input control
maxlength n digits set maximum characters length
disabled "" disabled input control, or fieldset tag
checked "" choose checkbox and radio button
<form>
<label>First Name:</label> <input type="text" value="First Name">
<label>Last Name:</label><input type="text" value="Last Name">
</form>
<form>
<label>First Name:</label><input type="text" maxlength="10">
<label>Last Name:</label><input type="text" maxlength="10">
</form>
<form>
<label>Password:</label><input type="password" >
</form>
Radio Buttons
Radio Buttons are used to choose a single element among a group.
To allow window to choose a single radio, use name attribute with same value on both radio inputs.
<form>
<input type="radio" name="gender" value="male"> Male
<input type="radio" name="gender" value="female">Female
</form>
Checkbox
Checkbox are used to select multiple selections unlike radio button.
<form>
<label <input type="checkbox" name="vehicle" value="bike"> :Bike</label>
<label <input type="checkbox" name="vehicle" value="car"> :Car</label>
</form>
<form>
<label>Current City:</label>
<select>
<option>--Select City--</option>
<option>New Delhi</option>
<option>Kolkata</option>
<option>Mumbai</option>
<option>Chennai</option>
</select>
</form>
<form>
<label>Current City:</label>
<select>
<option>--Select City--</option>
<optgroup label="Metros">
<option>New Delhi</option>
<option>Kolkata</option>
<option>Mumbai</option>
<option>Chennai</option>
</optgroup>
<optgroup label="Others">
<option>Noida</option>
<option>Gurgram</option>
<option>Faridabad</option>
<option>Gaziabad</option>
</optgroup>
</select>
</form>
Textarea
Textarea is used to write multiple line. Like query, address, comments, reviews etc.
Submit Button
Submit Button or input type submit is used to send information from user to web server. Submit button
can be used only once in a form tag.
Reset Button
Reset Button or input type reset is used to reload form data, without refreshing webpage. Reset is also
used once in a form tag.
<form>
<input type="text">
<input type="reset">
</form>
<table>
<tr>
<td>row 1, cell 1</td>
<td>row 1, cell 2</td>
</tr>
<tr>
<td>row 2, cell 1</td>
<td>row 2, cell 2</td>
</tr>
</table>
Table Attribute
Here is a list of attributes of table tag.
Attribute Use
width width of table or table cell
height height of table or table cell
align align text in table
valign vertically align text in table cell
border border width of table in px
bgcolor background color of table
cellspacing gap between table cells
cellpadding gap inside table cells
Width in Table
<table width="300">
<tr>
<td>row 1, cell 1</td>
<td>row 1, cell 2</td>
</tr>
<tr>
<td>row 2, cell 1</td>
<td>row 2, cell 2</td>
</tr>
</table>
Table Border
To display table with border, specify the width of border. Default table border is zero. Table border can have any
numeric values.
Table border 1
<table border="1">
<tr>
<td>row 1, cell 1</td>
<td>row 1, cell 2</td>
</tr>
<tr>
<td>row 2, cell 1</td>
<td>row 2, cell 2</td>
</tr>
</table>
Table border 5
<table border="5">
<tr>
<td>row 1, cell 1</td>
<td>row 1, cell 2</td>
</tr>
<tr>
<td>row 2, cell 1</td>
<td>row 2, cell 2</td>
</tr>
</table>
Cellspacing
cellspacing in table is used to set margin between table cells and table border.
Cellspacing of Table
S No Name
1 abc
2 xyz
S No Name
1 abc
2 xyz
S No Name
1 abc
2 xyz
Cellpadding
Deprecated in HTML5, use css padding.
Cellpadding means padding of text or content inside table cell from the table border in px. Same like css
padding.
S No Name
1 abc
2 xyz
Align Attributes in Table
Align atribute is used inside table tag, tr, or td to align text. Align center for table can also align whole table
to middle.
1. Left
2. Center
3. Right
Bgcolor
bgcolor in table
<table border="1px bgcolor="#FF0000">
<tr>
<td>row 1, cell 1</td>
<td>row 1, cell 2</td>
</tr>
<tr>
<td>row 2, cell 1</td>
<td>row 2, cell 2</td>
</tr>
</table>
Name Age
Kaushal 21
Shubh 20
The frameset element states only HOW MANY columns or rows there will be in the frameset.
The first column is set to 30% of the width of the browser window. The second column is set to 70% of the
width of the browser window. The document "frame_a.htm" is put into the first column, and the document
"frame_b.htm" is put into the second column:
<frameset cols="30%,70%">
<frame src="frame_a.htm" />
<frame src="frame_b.htm" />
</frameset>
Iframe
Iframe is a inline frame used to embedd other document within iframe
<iframe src="http://www.techaltum.com"></iframe>
Marquee Code
Marquee Behaviour
Marquee's behaviour can be changed using behavior attribute. Three possible values for marquee
behavior are:
1. Scroll
2. Slide
3. Alternate
Marquee Scrolldelay
Marquee scrolldelay is delay interval between two frames. Scrolldelay works on Firefox, Internet
Explorer, Edge, Safari. But on Chrome, scrolldelay is same like scrollamount.
Link 1
Link 2
Tech Altum
Go To Top
Mail Me
Call Me
Properties of hyperlink
Relative Link
A relative Link is used to link pages within same domain.
Absolute Link
An Absolute Link is used to link pages from their Absolute Path. for exp
<a href="http://www.domain.com">Link</a> is an Absolute Link as it contains domain name and page.
Target attribute
A target attribute ( target="" ) is used to tell window where to open that particular link.
Various values of target
Static Websites
HTML and CSS can create a static website only. A Static website means a website with fixed contents,
where we cannot interact with the user, we cannot send form inputs to the server, we cannot create image
sliders, and tabs etc.
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Static Webpage</title>
<style>
*{
margin:0px;
padding:0px;
}
.wrap{
width:960px;
height:auto;
border:1px solid red;
}
.header{
height:150px;
background:#333;
}
.nav{
height:50px;
background:#000;
}
.container{
background:#ccc;
}
.left{
width:30%;
height:200px;
float:left;
background:#333;
}
.right{
width:70%;
height:200px;
float:left;
}
.clear{
clear:both; // Clear Both will clear floating from both sides.
}
.footer{
height:80px;
background:#ccc;
}
</style>
<head>
<body>
<div class="wrap">
<div class="header"></div>
<div class="nav"></div>
<div class="container">
<div class="left"></div>
<div class="right"></div>
<div class="clear"></div>
</div>
<div class="footer"></div>
</div>
</div>
</body>
</html>