What is HTML
What is HTML
Features of HTML:
It is easy to learn and easy to use.
It is platform-independent.
Images, videos, and audio can be added to a web page.
Hypertext can be added to the text.
It is a markup language.
Why learn HTML?
It is a simple markup language. Its implementation is easy.
It is used to create a website.
Helps in developing fundamentals about web programming.
Boost professional career.
Advantages:
HTML is used to build websites.
It is supported by all browsers.
It can be integrated with other languages like CSS, JavaScript, etc.
Disadvantages:
HTML can only create static web pages. For dynamic web pages, other
languages have to be used.
A large amount of code has to be written to create a simple web page.
The security feature is not good.
</body>
</html>
Example Explained
The <html> element is the root element of an HTML page
The <head> element contains meta information about the HTML page
The <title> element specifies a title for the HTML page (which is shown
in the browser's title bar or in the page's tab)
The <body> element defines the document's body, and is a container for
all the visible contents, such as headings, paragraphs, images, hyperlinks,
tables, lists, etc.
The <h1> element defines a large heading
The <p> element defines a paragraph
Text
Headings in HTML
<html>
<head>
<title>Page Title</title>
</head>
<body>
</body>
</html>
<head>
<title>Page Title</title>
</head>
<body>
<b>bold text</b><br>
<i>italics text</i><br>
<strong>This is strong text emphasized</strong><br>
</body>
</html>
Text alignment
<html>
<head>
<title>Page Title</title>
</head>
<body>
</body>
</html>
Another Example
<html>
<head>
<title>Page Title</title>
</head>
<body>
</body>
</html>
HTML - Lists
HTML offers web authors 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.
<html>
<head>
</head>
<body>
<ul>
<li>Beetroot</li>
<li>Ginger</li>
<li>Potato</li>
<li>Radish</li>
</ul>
</body>
</html>
The type Attribute
You can use type attribute for <ul> tag to specify the type of bullet you like.
By default, it is a disc. Following are the possible options −
<ul type = "square">
<ul type = "disc">
<ul type = "circle">
<html>
<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>
<html>
<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>
<html>
<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>
<ol type="1"> 1.
2.
3.
<html>
<body>
<ol type="A">
<li>First </li>
<li>Second</li>
<li>Third</li>
<li>Fourth</li>
<li> and so on</li>
</ol>
The list is starting from 5<br>
<ol start="5">
<li>Ice cream</li>
<li>Mango</li>
<li>Juice</li>
<li>Pop Corn</li>
<li> and so on</li>
</ol>
</body>
</html>
Setting the Font
<html>
<head>
<title>Setting the Text </title> </head>
<body>
<font face="arial" size="10">
Varsha is sweet and <br>
Jayashree is very naughty!!<br>
But Sachin is a serious guy<br>
And Harshad seems to be studious.
</body>
</html>
Color
<html>
<head>
<title>Setting the Text </title>
</head>
<body bgcolor =navy>
<font face="arial" size="5" color="blue">
Great people are simple and <br>
<font face="Times new roman" color="red" size="10">
Simple people are great!!!<br>
<font face="GoudyHandtooled BT" color="green" size="12">
Great people rule the world.
</body>
</html>
HTML Links
When you move the mouse over a link, the mouse arrow will turn into a little
hand.
Note: A link does not have to be text. A link can be an image or any other HTML
element!
The most important attribute of the <a> element is the href attribute, which
indicates the link's destination.
The link text is the part that will be visible to the reader.
Clicking on the link text, will send the reader to the specified URL address.
Example
This example shows how to create a link to zeenews.com:
Example
Use target="_blank" to open the linked document in a new browser window or
tab:
HTML links can be used to create bookmarks, so that readers can jump to
specific parts of a web page.
When the link is clicked, the page will scroll down or up to the location with the
bookmark.
Example
First, use the id attribute to create a bookmark:
Then, add a link to the bookmark ("Jump to Chapter 4"), from within the same
page:
Example
<a href="#C4">Jump to Chapter 4</a>
Images are not technically inserted into a web page; images are linked to web
pages. The <img> tag creates a holding space for the referenced image.
The <img> tag is empty, it contains attributes only, and does not have a closing
tag.
Syntax
<img src="url" alt="alternatetext">
Example
<img src="img_chania.jpg" alt="Flowers in Chania">
Example
<img src="img_chania.jpg" alt="Flowers in Chania">
If a browser cannot find an image, it will display the value of the alt attribute:
Example
<img src="wrongname.gif" alt="Flowers in Chania">
Example
<img src="img_girl.jpg" alt="Girl in a
jacket" width="500" height="600">
Note: Always specify the width and height of an image. If width and height are
not specified, the web page might flicker while the image loads.
Image as a Link
To use an image as a link, put the <img> tag inside the <a> tag:
Example
<a href="default.asp">
<img src="smiley.gif" alt="HTML tutorial" width=”100”
height=”100">
</a>
Image Maps
The HTML <map> tag defines an image map. An image map is an image with
clickable areas. The areas are defined with one or more <area> tags.
<map name="workmap">
<area shape="rect" coords="34,44,270,350" alt="Computer" href="co
mputer.htm">
<area shape="rect" coords="290,172,333,250" alt="Phone" href="pho
ne.htm">
<area shape="circle" coords="337,300,44" alt="Coffee" href="coffe
e.htm">
</map>
The Image
The image is inserted using the <img> tag. The only difference from other images
is that you must add a usemap attribute:
The usemap value starts with a hash tag # followed by the name of the image
map, and is used to create a relationship between the image and the image
map.
The <map> element is used to create an image map, and is linked to the image by
using the required name attribute:
<map name="workmap">
The name attribute must have the same value as the <img>'s usemap attribute .
The Areas
Then, add the clickable areas.
Shape
You must define the shape of the clickable area, and you can choose one of
these values:
You must also define some coordinates to be able to place the clickable area
onto the image.
Shape="rect"
The coordinates for shape="rect" come in pairs, one for the x-axis and one for
the y-axis.
So, the coordinates 34,44 is located 34 pixels from the left margin and 44 pixels
from the top:
The coordinates 270,350 is located 270 pixels from the left margin and 350
pixels from the top:
Example
<area shape="rect" coords="34, 44, 270, 350" href="computer.htm">
This is the area that becomes clickable and will send the user to the page
"computer.htm":
Shape="circle"
To add a circle area, first locate the coordinates of the center of the circle:
337,300
44 pixels
Example
<area shape="circle" coords="337, 300, 44" href="coffee.htm">
This is the area that becomes clickable and will send the user to the page
"coffee.htm":
HTML Form
An HTML form is a section of a document which contains controls such as
text fields, password fields, checkboxes, radio buttons, submit button, menus
etc.
An HTML form facilitates the user to enter data that is to be sent to the
server for processing such as name, email address, password, phone
number, etc.
The HTML <form> element is used to create an HTML form for user input:
<form>
.
form elements
.
</form>
The <form> element is a container for different types of input elements, such
as: text fields, checkboxes, radio buttons, submit buttons, etc.
Type Description
<input type="radio"> Displays a radio button (for selecting one of many choices
Text Fields
The <input type="text"> defines a single-line input field for text input.
Example
A form with input fields for text:
<form>
<label >First name:</label><br>
<input type="text" name="fname"><br>
<label> Last name:</label><br>
<input type="text" name="lname">
</form>
The <label> element is useful for screen-reader users, because the screen-
reader will read out loud the label when the user focuses on the input element.
HTML Textarea
The HTML <textarea> tag is used to define a multi-line text input control.
It can hold unlimited number of characters and the texts are displayed in a
fixed-width font (usually courier).
The size of the HTML textarea is defined by <cols> and <rows> attribute
checkbox
<input type="checkbox">:
The <input> type "checkbox" are displayed as square boxes which can be
checked or unchecked to select the choices from the given options.
1. <form>
2. <label>Enter your Name:</label>
3. <input type="text" name="name">
4. <p>Kindly Select your favourite sports</p>
5. <input type="checkbox" name="sport1" value="cricket">Cricket<br>
6. <input type="checkbox" name="sport2" value="tennis">Tennis<br>
7. <input type="checkbox" name="sport3" value="football">Football<br
>
8. <input type="checkbox" name="sport4" value="baseball">Baseball<b
r>
9. <input type="checkbox" name="sport5" value="badminton">Badminto
n<br><br>
10. <input type="submit" value="submit">
11. </form>
Value submits the value to the server when submit button will be clicked.
Radio Buttons
1. <form>
2. <p>Kindly Select your favorite color</p>
3. <input type="radio" name="color" value="red"> Red <br>
4. <input type="radio" name="color" value="blue"> blue <br>
5. <input type="radio" name="color" value="green">green <br>
6. <input type="radio" name="color" value="pink">pink <br>
7. <input type="submit" value="submit">
8. </form>
Buttons
<input type="submit">:
The <input> element of type "submit" defines a submit button to submit the
form to the server when the "click" event occurs.
</form>
The <input> type "button" defines a simple push button, which can be
programmed to control a functionally on any event such as, click event.
Example:
1. <form>
2. <input type="button" value="Clcik me " onclick="alert('you are learning HTML')
">
3. </form>
Reset Button
<input type="reset">
The <input> type "reset" is also defined as a button but when the user
performs a click event, it by default reset the all inputted values.
Example:
1. <form>
2. <label>User id: </label>
3. <input type="text" name="user-id" value="user">
4. <label>Password: </label>
5. <input type="password" name="pass" value="pass"><br><br>
6. <input type="submit" value="login">
7. <input type="reset" value="Reset">
8. </form>
Sending Form
To send an email using HTML forms, you need to add
the email id to the action attribute of the form. In that,
add email proceeding with mailto:
i.e. mailto:[email protected].
<html>
<body>
<h2>Student Contact Form</h2>
<form action="mailto:[email protected]"
method="post" enctype="text/plain">
Student Name:<br><input type="text"
name="sname"> <br>
Student Subject:<br><input type="text"
name="ssubject"><br>
<input type="submit" value="Send">
</form>
</body>
</html>
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.
Creating Frames
To use frames on a page we use <frameset> tag instead of <body>
tag. The <frameset> tag defines, how to divide the window into
frames. The rows attribute of <frameset> tag defines horizontal
frames and cols attribute defines vertical frames. Each frame is
indicated by <frame> tag and it defines which HTML document shall
open into the frame.
<html>
<head>
<title>HTML Frames</title>
</head>
<noframes>
<body>Your browser does not support
frames.</body>
</noframes>
</frameset>
</html>
<html>
<head>
<title>HTML Frames</title>
</head>
<noframes>
<body>Your browser does not support
frames.</body>
</noframes>
</frameset>
</html>
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>
<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>
Table with column headings
<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>
</table>
</center>
</body>
</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>
Colspan and Rowspan Attributes
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.