Introduction to HTML Basics
Introduction to HTML Basics
What is HTML?
HTML is the standard markup language for creating Web pages.
HTML Versions
Version Year
HTML 1991
HTML 2.0 1995
HTML 3.2 1997
HTML 4.01 1999
XHTML 2000
HTML5 2014
HTML Tags
There are two types of tags..
o Container Tag / Pair Tag
o Singular Tag / Unpair Tag
Syntax :
HTML Structure
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
</body>
</html>
HTML Attributes
All HTML elements can have attributes
Attributes provide additional information about an element
Attributes are always specified in the start tag
Attributes usually come in name/value pairs like: name="value"
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body [bgcolor=“color-name”] => Set Background color for body
[text=“color-name”] => Set Text / Font Color in body
[link=“color-name”] => Set Link color in body
[alink=“color-name”] => Set Active Link color in body
[vlink=“color-name”] => Set Visited Link color in body
[background=“url”] > => Set a Background Image in body
</body>
</html>
Heading Tag
The <h1> element defines a large heading.
Syntax:
Example:
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
</body>
</html>
Font Size :
Syntax :
BR Tag :
<br> => Break Row
Example:
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
</body>
</html>
In the previous chapter, you learned about the HTML style attribute.
HTML also defines special elements for defining text with a special meaning.
HTML uses elements like <b> and <i> for formatting output, like bold or italic text.
Formatting elements were designed to display special types of text:
<address>
o The <address> tag defines the contact information for the author/owner of a
document or an article.
o The contact information can be an email address, URL, physical address, phone
number, social media handle, etc.
o Example:
<address>
Written by Creative.<br>
Visit us at:<br>
[Link]<br>
Box 564, Disneyland<br>
USA
</address>
o Output:
Written by Creative .
Visit us at:
[Link]
Box 564, Disneyland
USA
<cite>
o The <cite> tag defines the title of a creative work (e.g. a book, a poem, a song, a
movie, a painting etc.).
o The text in the <cite> element usually renders in italic.
o Example:
<p><cite>The Scream</cite> by Edward Munch. Painted in 1893.</p>
o Output:
The Scream by Edward Munch. Painted in 1893.
<dfn>
o The <dfn> tag stands for the "definition element", and it specifies a term that is
going to be defined within the content.
8 INTRODUCTION TO HTML
o Example:
<p><dfn>HTML</dfn> is the standard markup language for creating web
pages.</p>
o Output:
HTML is the standard markup language for creating web pages.
<code>
o The <code> tag is used to define a piece of computer code.
o The content inside is displayed in the browser's default monospace font.
o Example:
<p>The HTML <code>button</code> tag defines a clickable button.</p>
o Output:
The HTML button tag defines a clickable button.
<samp>
o The <samp> tag is used to define sample output from a computer program.
o The content inside is displayed in the browser's default monospace font.
o Example:
<p><samp>File not found.<br>Press F1 to continue</samp></p>
o Output:
File not found.
Press F1 to continue
<kbd>
o The <kbd> tag is used to define keyboard input.
o The content inside is displayed in the browser's default monospace font.
o Example:
<p>Press <kbd>Ctrl</kbd> + <kbd>C</kbd> to copy text (Windows).</p>
<p>Press <kbd>Cmd</kbd> + <kbd>C</kbd> to copy text (Mac OS).</p>
o Output:
Press Ctrl + C to copy text (Windows).
Press Cmd + C to copy text (Mac OS).
9 INTRODUCTION TO HTML
<sub>
o The <sub> tag defines subscript text.
o Subscript text appears half a character below the normal line, and is sometimes
rendered in a smaller font.
o Example:
<p>H <sup>2</sup>O</p>
o Output:
H2O
10 INTRODUCTION TO HTML
<big>
o The <big> tag was used in HTML 4 to define bigger text.
o Example:
<p> This is a normal paragraph. </p>
<big> This is a bigger paragraph. </big>
o Output:
This is a normal paragraph.
This is a bigger paragraph.
<small>
o The <small> tag was used in HTML 4 to define smaller text.
o Example:
<p> This is a normal paragraph. </p>
<big> This is a smaller paragraph. </big>
o Output:
This is a normal paragraph.
This is a smaller paragraph.
<pre>
o The <pre> tag defines preformatted text.
o The text will be displayed exactly as written in the HTML source code.
o Example:
<pre> Text in a pre element
is displayed in a fixed-width
font, and it preserves
both spaces and
line breaks</pre>
o Output:
11 INTRODUCTION TO HTML
<font>
o The <font> tag was used in HTML 4 to specify the font face, font size, and color
of text.
o Syntax:
<font color=”color-name” size=”number (1 to 7)” face=”font-name”
>…Content Here…</font>
o Example:
<font color=”red” size=”4” face=”calibri”> Hellooo…! Good Afternoon
</font>
o Output:
o Output:
<marquee>
o The <marquee> tag is a container tag of HTML is implemented for creating
scrollable text or images within a web page from either left to right or top to
bottom.
o Syntax:
<marquee [behavior=“Scroll | Slide | Alternate”]
[direction=“Left | Right | Up | Down”]
[loop=“1 | 2 | …N”]
[scrollamount=”number”]
[bgcolor=“Color Name”]
[height=“pixels”]
[width=“pixels”] >……</marquee>
o Example:
<marquee behavior="scroll" direction="up" scrollamount="1">Slow
Scrolling</marquee>
<marquee behavior="scroll" direction="right" scrollamount="12">Little
Fast Scrolling</marquee>
<marquee behavior="scroll" direction="left" scrollamount="20">Fast
Scrolling</marquee>
<marquee behavior="scroll" direction="right" scrollamount="50">Very
Fast Scrolling</marquee>
13 INTRODUCTION TO HTML
<a>
o The <a> tag defines a hyperlink, which is used to link from one page to another.
o The most important attribute of the <a> element is the href attribute, which
indicates the link's destination.
o Syntax:
<a [href=“URL”]
[target=“_blank”] >…</a>
o Example:
<a href="[Link] target="_blank">Visit [Link]!</a>
o Output:
Visit [Link]
<img>
o The <img> tag is used to embed an image in an HTML page.
o The <img> tag has two required attributes:
src - Specifies the path to the image
alt - Specifies an alternate text for the image, if the image for some
reason cannot be displayed
o Syntax:
<img [alt=“AlternativeText]
[border=“border-width”]
[height=“pixels”]
[width=“pixels”]
[hspace=”pixels”] => Horizontal Margin
[vspace=“pixels”] > => Vertical Margin
o Example:
<img src=”your image path here” width=”500” border=”5” alt=”Creative
College” >
14 INTRODUCTION TO HTML
o Image Map:
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.
To map an image we have to follow some special steps.
1. Set #mapname to image by <IMG>
2. Use MAP tag <MAP>
3. Specify AREA with LINK using <AREA>
Syntax :
<map name="[mapname]">
<area shape="[rect, circle]" coords="x1,y1,x2,y2" href="URL ">
</map>
Example :
<img src="[Link]" alt="Workplace" usemap="#workmap">
<map name="workmap">
<area shape="rect" coords="34,44,270,350" href="[Link]">
<area shape="rect" coords="290,172,333,250" href="[Link]">
<area shape="circle" coords="337,300,44" href="[Link]">
</map>
15 INTRODUCTION TO HTML
Shape=”rect”
o The coordinates for shape="rect" come in pairs, one for the x-axis and
one for the y-axis.
o So, the coordinates 34,44 is located 34 pixels from the left margin and
44 pixels from the top:
16 INTRODUCTION TO HTML
o The coordinates 270,350 is located 270 pixels from the left margin and
350 pixels from the top:
Shape=”circle” :
o To add a circle area, first locate the coordinates of the center of the
circle:
337,300
o Output :
Coffee
Black hot drink
Milk
White cold drink
o Embed:
o The <embed> tag defines a container for an external resource, such as a web
page, a picture, a media player, or a plug-in application.
o Syntax :
<embed [type="image/jpg | text/html | video/webm"]
src="URL" width="px" height="px">
o Example :
<embed type="image/jpg" src="pic_trulli.jpg" width="300" height="200">
o Output :
o Example :
<embed type="text/html" src="[Link]" width="500" height="200">
<embed type="video/webm" src="video.mp4" width="400" height="300">
22 INTRODUCTION TO HTML
Tables in HTML
o The <table> tag defines an HTML table.
o An HTML table consists of one <table> element and one or more <tr>, <th>, and <td>
elements.
o The <caption> tag defines a Table Caption.
o The <tr> element defines a Table Row.
o The <th> element defines a Table Header.
o The <td> element defines a Table Cell.
<table> :
o Syntax:
<caption> :
o Syntax:
<tr> :
o To add a new row in a table we must use TR tag
o Syntax:
<tr bgcolor="color">………</tr>
23 INTRODUCTION TO HTML
<th> :
o The text in <th> elements are bold and centered.
o Each table header is defined with a <th> tag.
o Syntax:
HTML Code:
<table border="1" width="50%" cellpadding="10" align="center">
<tr>
<th>No.</th>
<th>Full Name</th>
<th>Position</th>
<th>Salary</th>
</tr>
<tr>
<td>1</td>
<td>Bill Gates</td>
<td>Founder of Microsoft</td>
<td>$1000</td>
</tr>
<tr>
<td>2</td>
<td>Steve Jobs</td>
<td>Founder of Apple</td>
<td>$1200</td>
</tr>
<tr>
<td>3</td>
<td>Larry Page</td>
<td>Founder Google</td>
<td>$1100</td>
</tr>
<tr>
<td>4</td>
<td>Mark Zuckerberg</td>
<td>Founder of Facebook</td>
<td>$1300</td>
</tr>
</table>
Frames in HTML
o When we wan to use more then one HTML files in a web page, at that time we have
to use FRAMES.
o Tags used for FRAMES.
o <frameset>
o <frame>
o <frameset>
o To define frameset and numbers of frames in rows or column format. Nobody
TAG will used with Frameset.
o Syntax:
o Example:
<frameset rows=“10,10,10”>
<!-- Three Frames in Three Rows -->
</frameset>
<Frameset cols=“20,80”>
<!-- Two Frames in Two Columns -->
</frameset>
o <frame>
o To define Frame for Frameset, we have to use <Frame> Tag.
o Syntax:
<frameset rows="20,20,20">
<frame src="[Link]">
<frame src="[Link]">
<frame src="[Link]">
</frameset>
26 INTRODUCTION TO HTML
o <iframe>:
o The <iframe> tag specifies an inline frame.
o An inline frame is used to embed another document within the current HTML
document.
o Syntax:
<iframe src="URL" width="pixel/percent" height="pixel">
</iframe>
o Example:
<iframe src="[Link] width="50%" height="700">
</iframe>
27 INTRODUCTION TO HTML
The <form> element is a container for different types of input elements, such as: text
fields, checkboxes, radio buttons, submit buttons, etc.
Form Methods :
o GET :
Get method will DISPLAY all the information of page in to URL.
Note : Some of Browser will note display information on URL by
GET...
o POST :
POST method will HIDE all the information of page in to URL.
<input> Elements
Type Description
<input type="text"> Displays a single-line text input field
<input type="password"> Displays text as a password
<input type="radio"> Displays a radio button (for selecting one of many choices)
<input type="checkbox"> Displays a checkbox (for selecting zero or more of many choices)
<input type="submit"> Displays a submit button (for submitting the form)
<input type="reset"> Reset form controls
<input type="button"> Displays a clickable button
28 INTRODUCTION TO HTML
o Syntax:
<input type=“Control Type”
[Name=“Name of Control”]
[Value=“DefaultValue”]
[MaxLength=“IntLen”]
[Size=“InputBoxLen”]
[ReadOnly][Disabled]
[Align=“Left|Right”]
[Checked=“Checked”] >
<textarea> :
o The <textarea> tag defines a multi-line text input control.
o The <textarea> element is often used in a form, to collect user inputs like
comments or reviews.
o The size of a text area is specified by the <cols> and <rows> attributes (or with
CSS).
o Syntax :
< textarea [Name=“Control Name”]
[Cols=“IntColumns”]
[Rows=“IntRows”]
[Disabled] [ReadOnly]
[Wrap=“Off | Physical”] >
Default Text…
</ textarea >
Example :
< textarea cols="22" rows="4" placeholder="Address"></ textarea >
29 INTRODUCTION TO HTML
<select> :
o The <select> element is used to create a drop-down list.
o The <select> element is most often used in a form, to collect user input.
o Syntax:
< select [Name=“Control Name”]
[Disabled] [Multiple]
[Size=“Input Num of Character”] >
<option>….</option>
</select>
<option> :
o The <select> element is used to create a drop-down list.
o The <select> element is most often used in a form, to collect user input.
o Syntax:
<option [Name=“Control Name”]
[Value=“Initial Value”]
[Selected]>…….</option>
Example :
Design a Student Data Entry Form using form and input elements.
HTML Code :
<form method="post" action="">
<table border="1" cellpadding="10" cellspacing="0">
<caption><font size="5" color="red">Student Detail Form</font></caption>
<tr>
<td>Roll No. :</td>
<td>
<input type="text" name="" size="5" placeholder="Roll no.">
</td>
</tr>
<tr>
<td>Name :</td>
<td>
<input type="text" name="" placeholder="Enter Name">
</td>
</tr>
<tr>
<td>Address :</td>
<td>
<textarea cols="22" rows="4" placeholder="Address"></textarea>
</td>
</tr>
31 INTRODUCTION TO HTML
<tr>
<td>Date of Birth :</td>
<td>
<select>
<option>Day</option>
<option>1</option>
<option>2</option>
<option>3</option>
<option>.</option>
<option>31</option>
</select>
<select>
<option>Month</option>
<option>January</option>
<option>February</option>
<option>March</option>
<option>.</option>
<option>December</option>
</select>
<select>
<option>Year</option>
<option>1990</option>
<option>1991</option>
<option>1992</option>
<option>.</option>
<option>2020</option>
</select>
</td>
</tr>
<tr>
<td>Gender :</td>
<td>
<input type="radio" name="gender" checked="">Male
<input type="radio" name="gender">Female
</td>
</tr>
<tr>
<td>Hobby :</td>
<td>
<input type="checkbox" name="">Cricket<br>
<input type="checkbox" name="">Reading<br>
<input type="checkbox" name="">Travelling<br>
<input type="checkbox" name="">Dancing<br>
<input type="checkbox" name="">Singing
</td>
</tr>
32 INTRODUCTION TO HTML
<tr>
<td>Username :</td>
<td>
<input type="text" name="" placeholder="Enter Username">
</td>
</tr>
<tr>
<td>Password :</td>
<td>
<input type="password" name="" placeholder="Enter Password">
</td>
</tr>
<tr>
<td colspan="2" align="center">
<input type="button" name="" value="Button">
<input type="submit" name="" value="Submit">
<input type="reset" name="" value="Reset">
</td>
</tr>
</table>
</form>
33 INTRODUCTION TO HTML
HTML5 – Overview
o HTML5 is the next major revision of the HTML standard. HTML5 is a standard for
structuring and presenting content on the World Wide Web.
o HTML5 is a cooperation between the World Wide Web Consortium (W3C) and the
Web Hypertext Application Technology Working Group (WHATWG).
o Syntax:
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<header>
Your Content Here...
</header>
<nav>
Your Content Here...
</nav>
<section>
<article>
Your Content Here...
</article>
<article>
Your Content Here...
</article>
<aside>
Your Content Here...
</aside>
</section>
<footer>
Your Content Here...
</footer>
</body>
</html>
34 INTRODUCTION TO HTML
o HTML5 comes with a lot of flexibility and it supports the following features :
Uppercase tag names.
Quotes are optional for attributes.
Attribute values are optional.
Closing empty elements are optional
What is Canvas ?
o The <canvas> tag is used to draw graphics, on the fly, via scripting (usually JavaScript).
o It can be used to draw graphs, make photo compositions or do simple (and not so
simple) animations.
o Here is a simple <canvas> element which has only two specific attributes width and
height.
o Example :
<!DOCTYPE HTML>
<html>
<head>
<title>My Canvas</title>
</head>
<body>
<canvas id="demo" width="100“ height="100"></canvas>
<script>
var canvas = [Link]("demo");
var ctx = [Link]("2d");
[Link] = "#FF0000";
[Link](0, 0, 80, 80);
</script>
</body>
</html>
o Output :
36 INTRODUCTION TO HTML
o Audio:
o The <audio> tag is used to embed sound content in a document, such as music
or other audio streams.
o There are three supported audio formats in HTML: MP3, WAV, and OGG.
o To play an audio file in HTML, use the <audio> element:
o Syntax :
<audio controls>
<source src="Your path here"
o Example :
<audio controls>
<source src="[Link]" type="audio/ogg">
<source src="horse.mp3" type="audio/mpeg">
</audio>
o Output :
o Video:
o The <video> tag is used to embed video content in a document, such as a movie
clip or other video streams.
o The <video> tag contains one or more <source> tags with different video
sources. The browser will choose the first source it supports.
o Syntax :
<video controls autoplay loop muted width height>
<source src="Your path here"
o Example :