Gr7 HTML Notes 2022-23
Gr7 HTML Notes 2022-23
Gr7 HTML Notes 2022-23
SNO TOPICS
TERM1
1
Definition and Benefits of HTML
2 HTML 5 tags
3 CSS
● Internal styling-
○ Text Properties
○ Font Properties
○ Properties of HR
Term2
5 CSS - Internal styling
● Creating ID
● <div>,<span>
6 Inserting Images
8 Tables
10 Forms
11 Frames
12 HTML Layout
HTML
HTML stands for Hyper Text Markup Language where each word has its own
significance.
Hyper signifies that the user can view World Web pages.
Text is anything written in English language or alphanumeric characters. Markup
means you can mark up the text you have written as special indicators through
special tags.
Language signifies that HTML is a computer language
Thus, HTML is a set of instructions given to a Web browser to describe the structure
of a Web page. It is a user-friendly language for presenting documents on the Web. It
contains commands that are used to compose the page and specify the text, graphics,
headings, etc. That would appear on the Web browser. It also contains commands for
linking pages to other pages and to other Internet resources. HTML documents can be
created with any word processor or text editor such as Notepad.
Benefits of HTML
HTML provides you with the following benefits:
● HTML is easy to learn and execute. It executes commands in very less time.
● We can create a structured document using different tags in HTML.
● HTML is an interpreter-based language as its commands are executed
instruction by instruction.
● It is a platform independent language which means it can be executed on any
operating system.
● It allows the use of different tools to make the document look more attractive.
● It provides paragraph alignment features. So you can align your text towards
left, right or centre.
● You can also insert an image, a table and an animated text or graphics on the
Web page using HTML.
● HTML allows linking of different Web pages.
● It also provides forms and frames for better user interaction.
HTML Elements
There are various HTML elements that can be listed to construct a Web page.
An HTML tag consists of a left angular bracket or a less than symbol (<) followed by
the name of the tag and closed by a right angular bracket or a greater than symbol.
Various essential document structure elements are <html> ... </html>, <head> ...
</head> and <body> ... </body>.
1. Container Elements
2. Empty Elements.
1. Container Elements:
The element that has both the tags, i.e., the starting or opening tag as well as
the ending or closing tag is known as a Container Element. So, the container
elements include both ON tag (Starting Tag) and OFF tag (Ending Tag). The OFF tag is
the same as the ON tag except for the / used after < sign.
For example, to define a text as a first level heading, you use H1 tags as shown
below:
The elements that have the starting tag only and have no end tag (or closing
tag) are called Empty Elements. For example,
BR- Used to provide blank line
HR- Used to insert horizontal lines.
<body>
<h1> Computer Fundamentals </h1>
RAVI ARORA <br>
RIA BANSAL
</body>
</html>
The different properties that can be used with hr tag are explained below in the CSS
section.
1. HTML Element
HTML documents must begin with the <html> tag. It is a container element
that identifies the document as an HTML document. This tag indicates that the
content of a file is in HTML. This element is not visible when displayed on the
browser. It is the root element of the html document and the rest of the elements are
located between start and end HTML tags.
2. HEAD Element
The <head> tag contains information about the document, indicating its title,
scripts used, style definitions and document descriptions. All the browsers do not
require this tag but most browsers find any available additional information about
the document within the <head> tag. The head element contains general
information, also called Meta-information (Meta means information about
something) about a document or a Web page. According to the HTML standard, only
a few tags such as <link>, <meta>, <title>, <style> and <script> are used under the
<head> element.
Meta element only has the start tag and no end tag. It has attributes like
charset to specify the character encoding used. “utf-8” is the very commonly used
character set.
<meta charset="utf-8">
It tells the browser what type of letters the page is written in. If your web site
is in a language other than English be careful to use the correct charset. If your page
is in plain old vanilla English just copy and paste <meta charset="UTF-8"> just above
the title, and with all luck you'll never have to think about it again.
3. TITLE Element
The <title> element contains the document title. This title is displayed on the
topmost bar of the browser. This element is used in the <head> tag. Ideally the title
should be less than 64 characters in length.
4. BODY Element
The <body> tag encloses all the tags, attributes and information that you want the
visitor's browser to display. It forms the body of an HTML page.
<!DOCTYPE html>
<html lang=”en”>
<head>
<title> My first page in Html </title>
</head>
<body> I am learning HTML
</body>
</html>
This is the basic structure of every HTML web page. We can change the text of
the title section and content of the body as per our requirement.
It must only appear once, at the top of the page (before any HTML tags).
The declaration is not case sensitive.
The word <!DOCTYPE html> means "this page is written in HTML5" as opposed
to, say HTML 4.
lang attribute has the value “en” which means the html document is in English
.
3. Saving a Web Page
< h1> is the highest level and the largest of all headings and <h6> is the lowest
and the smallest level. The six heading tags are:
<!DOCTYPE html>
<html>
<head>
<title> Headings in HTML </title>
</head>
<body>
<h1> First Level Heading </h1>
<h2> Second Level Heading </h2>
<h3> Third Level Heading </h3>
<h4> Fourth Level Heading </h4>
<h5> Fifth Level Heading</h5>
<h6> Sixth Level Heading </h6>
</body>
</html>
2. P Element
A web browser ignores all the blank spaces, but whenever a browser notices
the paragraph tag, it inserts a blank line and starts a new paragraph. The<p> tag is
the HTML tag for inserting a paragraph break at the given place in the text. Different
properties can be applied to a <p> element with CSS (explained below).
You can also make the text bold and/or italicised using <b> and <i> tags
as discussed below:
1. B Element: It indicates that the enclosed text should be displayed in bold face.
The following code displays the text “ ANNA HAZARE” in boldface:
<html>
…..
<body>
<b> ANNA HAZARE </b>
</body>
</html>
2. strong Element – The text appears the same as it will be with <b> element. The
difference is when a search engine analyses a page, text in <strong> tags is
considered important, text in <b> tags is not.
Syntax is :
<strong>This text is strong</strong>
Eg. To change the color of the full document to red we have to use the style
attribute in the body tag as
Here style is the attribute, color is the property that specifies what we are
controlling or changing. As we want to change the color of the text so we use the
color property. It is followed by colon and then the value. We can use multiple styles
together by separating them with semicolons(;).
E.g. In addition to changing the color we want the text to be centre aligned,
we can use the property text-align and set the value to centre.
<!DOCTYPE html>
<html lang="en">
<head>
<title>HTML Test</title>
<meta charset="UTF-8">
</head>
<body>
<h1 style="color:red; text-align:center;"> This is a heading </h1>
<p style = "color: green; text-align: justify;" > This is the first paragraph
</p>
</body>
</html>
Place the style element in the head section of the HTML code document.
Also called Internal styling method.
example:
<head>
<style>
h1 {text-align: center; color: green; }
p {color: red; background-color: yellow; text-align: justify; }
</style>
</head>
The complete program will be including the style sheet in the Html program as
follows:
<!DOCTYPE html>
<html>
<head>
<title>HTML Test</title>
<meta charset="UTF-8">
<style>
h1 {color:green; text-align: center; }
p {color: red; background-color: yellow ; text-align: right;}
</style>
</head>
<body>
<h1> This is a heading </h1>
<p> This is the first paragraph </p>
</body>
</html>
When this method is used, the style rules apply to the whole HTML document.
This allows individual style rules to be applied to multiple HTML elements. In the
above example, the text-align and color property will be applied to all <h1>
elements. In addition, the color, background-color and text-align properties will be
applied to all <p> elements within this HTML document. Color property defines the
text color for an HTML element, Background property defines the background color
for that HTML element and text-align property aligns the text in that particular
direction.
If we want to apply the same style to multiple elements then we can use comma and
separate them. Write the below code, run in your browser and see the result.
<!DOCTYPE html>
<html>
<head>
<title>HTML Test</title>
<meta charset="UTF-8">
<style>
h3 {text-align: left;}
p, h1, h2 {text-align: center;}
</style>
</head>
<body>
<h1>The h1 text-align set to center.</h1>
<h2>The h2 text-align set to center.</h2>
<h3>The h3 text-align set to left.</h3>
<p>The p text-align set to center.</p>
</body>
</html>
If we want a style to be applied for all the elements then we use an asterisk (*) which
matches all elements. In the following example, the color property will be set to red for all
elements.
<!DOCTYPE html>
<html lang="en">
<head>
<title>HTML Sample</title>
<meta charset="UTF-8">
<style>
* {color: red;}
</style>
</head>
<body>
<h1>The h1 tag color set to red.</h1>
<p>The p tag color set to red.</p>
</body>
</html>
CSS Text Properties
We can format our HTML web page using many different tags as described below -
Text properties :
The <u> element is deprecated in HTML 5 but we can underline a text for extra
emphasis using CSS.
We can use the Text-decoration property whose values can be set to underline,
overline, line-through, etc.
We can set different properties for horizontal line using CSS as explained in below
example-
<!DOCTYPE html>
<html>
<head>
<title>HTML HR tag</title>
<style>
<body >
<h1 style="color:red; text-align:center;"> This is heading </h1>
<hr>
<p>This text will be followed by a horizontal line </p>
</body>
</html>
If we want to align the line to left then set margin-left to 0 or margin:center to 0 for
center align. Width and height properties can be used to set the desired width and height
and border-colour for making a coloured line.
Fonts are specific to the platform. If you are using a different OS then you will have a
different look and feel of any web page. HTML <FONT> tag is deprecated in HTML version
4.0 onwards and now all fonts are set by using CSS.
A simple syntax of setting font for the body of web page is
body { font-family: "Arial";}
or
<body style="font-family:Arial;">
But there are few more attributes which can be used. The complete syntax is –
Element {font: style variant weight size/line-height family;}
Where style can use one of the following keywords: normal, italic, or oblique
Weight can have the values normal, bold, bolder, lighter or one of the following
weight-numbers: 100, 200, 300, 400, 500, 600, 700, 800, or 900
Size can be specified by using length (15px), percentage (21.3%) or one of the following
keywords: xx-small, x-small, small, medium, large, x-large, xx-large, larger, or smaller
Family can occur one or more times. If it occurs more than once then the values must be
separated by commas. It is specified by using a family-name (Arial, Courier, Calibri, Verdana,
etc.). Above is a sample of family occurring two times. The text will be displayed in the first
font-family, if it is not present then in the second one and so on.
The style, variant, weight and line-height properties are optional. Any of these
properties that are not specified will automatically be set to their initial or default value.
The size and family properties are required.
Chapter 4: Creating Lists in HTML5
Lists are one of the ways to provide information in a structured and easy-to-read
format. They help the Internet users to easily spot the information and focus attention on
the important information. By using HTML, you can arrange items in the form of a list in
several ways.
The different ways are:
1. Bulleted or Unordered List
2. Numbered or Ordered List
3. Definition List
4. Nested List
1. Unordered List
A list of items that are marked with bullets is called an unordered list. The list starts
with the <ul> tag and each item in the list starts with the <li> tag.
There is an attribute type which is used to define the type of the bullet used. The value of
this attribute can be set to disc(default), circle or square. Try the below program with <ul
type="circle"> or <ul type="square"> for changing the bullet type
The following code illustrates the use of <ul> and <li> tags:
<!DOCTYPE html>
<html>
<head>
<title> Unordered List </title>
</head>
<body>
<h1> Useful Animal Products</h1>
<ul>
<li> Milk </li>
<li> Eggs and Meat </li>
<li> Leather </li>
<li> Wool and Silk </li>
<li> Honey, Wax and Lac </li>
</ul>
</body>
</html>
2. Ordered List
The list that is marked with numbers is called an ordered list. The list starts with the
<OL> tag and each item in the list starts with the <LI> tag. In the Ordered list, type attribute
can have the values as A/a/I/i , default is 1.
The following code illustrates the ordered lists:
<!DOCTYPE html>
<html>
<head>
<title>Ordered List</title>
</head>
<body>
<h1> Parts of a Computer</h1>
<ol type="A">
<li> Hardware </li>
<li> Software </li>
</ol>
</body>
</html>
3. Definition List
A definition list is a list of items and description of those items indented in the
next tab positions. It starts with the <dl> tag. Each definition starts with the <dd> tag.
<!DOCTYPE html>
<html>
<head>
<title>Definition List</title>
</head>
<body>
<dl>
<dt> UNIT I: PLANT LIFE </dt>
<dd> Chapter 1: Parts of Plants </dd>
<dd> Chapter 2: Uses of Plants</dd>
<dt> UNIT II: ANIMAL LIFE </dt>
<dd> Chapter 3: Parts of Animal Body </dd>
<dd> Chapter 4: Uses of Animals </dd>
</dl>
</body>
</html>
4. Nested List
<!DOCTYPE html>
<html>
<head>
<title>Nested List</title>
</head>
<body>
<h2>A Nested List</h2>
<ul>
<li>Coffee</li>
<li>Tea
<ul>
<li>Black tea</li>
<li>Green tea
<ul>
<li>China</li>
<li>Africa</li>
</ul>
</li>
</ul>
</li>
<li>Milk</li>
</ul>
</body>
</html>
Output:
Chapter 5: CSS - Internal styling
With CSS it is possible to define a specific style of our own and then use it with the
ID attribute of an element. E.g. if we want to use different font styles for different p
elements then we can do so using CSS ID. The # symbol is immediately preceded by a name,
then we specify the style for this id. This style will only be applied to an element that also
has a matching id attribute value as following –
<!DOCTYPE html>
<html lang="en">
<head>
<title>HTML Sample</title>
<meta charset="UTF-8">
<style>
#tst1 {font: italic small-caps bold 20px/1.5 Verdana, Arial, Calibri;}
#tst2 {font-size: large; font-family: Arial black;}
#tst3 {text-decoration: underline;}
</style>
</head>
<body>
<p id="tst1">All values are specified.</p>
<p id="tst2">Only size and a generic font are specified.</p>
<p id="tst3">This text will be underlined.</p>
</body>
</html>
An ID uniquely identifies a style, so it is not valid for multiple styles to have the same
ID name.
The <div> element defines a division or a section in a HTML document. The <div>
element is a block-level element, so a line break is placed before and after it. The <div>
element is often used as a container for other HTML elements to style them with CSS.
Example - A section in a document that will have a light blue background color:
The <span> element is an inline element which means that it will not start on a new
line. It is used to wrap small portions of text, images, etc. <span> element is used to stylize
texts. span element is in-line and usually used for a small chunk of text inside a line (such as
inside a paragraph)
Example -
<p> My mother has <span style="color:green; text-decoration:underline; "> green
</span> eyes.</p>
Chapter 6: Inserting Images
Images enhance the quality of a web page. You can include an image in the web
page to provide information or to make the page attractive. Images make the document
more interesting and useful. The World- Wide Web browser supports a number of graphic
formats. The most commonly used graphic formats are gif and jpg formats.
To insert an image in your web page, you have to use the <img> tag. To display an
image on a page, you need to use the src attribute. src stands for "Source". The value of the
src attribute is the address of the image you want to display on your page. The syntax of
defining an image is:
<img src ="address"> . The IMG element has a start tag but does not have an end tag.
The following code illustrates the use of <IMG> tag:
<html>
<head>
<title>Inserting Image</title>
</head>
<body>
My picture
<img src = "D:\Dhanpreet\Pictures\bird.jpg">
</body>
</html>
For example, the following statement is used to display alternate text for the image i.e
Horse if the browser is not able to display the horse image.
<img src ="horse.jpg" alt ="Horse" >
Here we have used relative address means that horse.jpg is stored in the same folder as the
html document.
If the images are stored in a sub-folder named images inside the folder where the html
webpage is saved then the address is written as - src="images/ horse.jpg"
Actually, we can access images from any web address in the world and display them on our
web page provided we know the complete URL of the image. Example - include the below
<img> tag in the body element and see the output –
<img src="https://www.w3schools.com/images/w3schools_green.jpg" alt="W3Schools.c
om">
If you want to change the size of an image, you can use the style attribute to specify the
width and height of an image with values in pixels as illustrated in the following statement:
<img src ="horse.jpg" alt ="Horse" style="width:100px; height:100px;">
HEIGHT and WIDTH specify the height and width of the image to be displayed on the page.
It is not mandatory to give height and width of an image but it is better to specify it as the
page might (not always) flicker while the image loads if these values are not specified.
The align attribute of <img> is not supported in HTML5. We have to use CSS instead.
To center an image, set left and right margin to auto and make it into a block element
<!DOCTYPE html>
<html>
<head>
<title>Working with Images</title>
<style>
#hori-center {
display: block;
margin-left: auto;
margin-right: auto;
}
</style>
</head>
<body>
<img src="https://www.w3schools.com/images/w3schools_green.jpg"
alt="W3Schools.com" id="hori-center">
<img src ="horse.jpg" alt ="Horse" style="width:100px; height:100px;">
<img src ="scenery.jpg" alt ="scenery" style="float:right">
</body>
</html>
First image will be in the center, second in the left and third in the right side.
The web pages are linked to other pages with the help of hyperlinks. A
hyperlink is a highlighted word or image that takes a user from one web page or
document to another web page or document. It stores the address of that particular
web page or document and the linked document opens when we click on the
hyperlink.
Not to miss
There are different kinds of links, like – Internal link, External link,
Incoming link.
A link between two webpages, where both webpages belong to one
website, is called an internal link.
External link is a hyperlink that is a link from your webpage to
someone else's web page on a different website.
Incoming link is a link from someone else's web page to your
website. It's the opposite of an external link.
Anchor tag <a> is used to create a hyperlink. This HTML tag creates a reference link to
a resource (web page or document) or to a specific place within a web page. It is a
container element having start <a> and end </a> tags. The href attribute of anchor tag
specifies the address/location of the web page or document that it is linking to and its value
is the URL of that particular web page. URL can be absolute or relative. Absolute meaning
the complete address or URL of the website e.g. http://www.ndtv.com or relative address
like test.html which is stored in the same folder as the html webpage.
When you move the mouse over a link, the mouse arrow will turn into a little hand.
The syntax for the anchor tag is shown below.
<a href = "url"> link text </a>
Let's understand how to link web pages with the following example.
<!DOCTYPE html>
<html>
<head>
<title>LINKING Example</title>
</head>
<body >
<a href="http://www.yahoo.com/" title="Yahoo home page"> Click here to
open Yahoo home page </a> <br>
<a href="scenery.jpg"> Click here to open a picture </a><br>
<a href="sample.htm"> Click here to open another web page </a><br>
</body>
</html>
The content between the anchor tags will be displayed on the browser. On clicking it will
take to the webpage that is specified. The value of the title attribute is shown as a tooltip
text when the mouse moves over the text/image.
If our scenery.jpg is inside a folder named images then we write
href="images/scenery.jpg"
Linking Images
Image <img> tag can be used within <a> ... </a> tag to display an image as a link. This
is shown in the following example
<!DOCTYPE html>
<html>
<head>
<title>LINKING Image</title>
</head>
<body >
<a href=http://deensacademy.com/tag/ title="Go to Deens
academy Website"> <img src ="scenery.jpg" alt ="school">
</a><br>
</body>
</html>
You can also add an e-mail address on a web page. The E-mail address can be
enclosed inside the <a> tag. The e-mail address can be made as hyperlink called mailto link.
On clicking this link, a new form will appear in your browser window for sending an e-mail.
For example, on giving the following statement, ‘Contact Spectramind’ will appear on the
page as a link to the e-mail address, spectramind@vsnl.com.
<a href = “mailto: spectramind@vsnl.com”> Contact Spectramind </a>
Now, if a user clicks this link, it launches one Email Client (like Lotus Notes,
Outlook Express etc. ) installed on the user's computer and in that a new e-mail form will
appear.
Chapter 8: Tables
HTML table allows you to arrange data into rows and columns on a webpage. They
are commonly used to display tabular data like product listings, customer's details, financial
reports, and so on. We can create a table using the <table> element. Inside
the <table> element, we can use the <tr> elements to create rows, and <td> elements to
create columns inside a row. <td> elements can contain all sorts of HTML elements like text,
images, lists, other tables, etc. We can also define a cell as a header for a group of table
cells using the <th> element. The browser renders a table header in bold and a slightly
larger font by default to distinguish the header row from the others.
<!DOCTYPE html>
<html>
<head>
<title>Creating Tables in HTML</title>
</head>
<body>
<h2>HTML Table </h2>
<table>
<tr>
<th>No.</th>
<th>Name</th>
<th>Age</th>
</tr>
<tr>
<td>1</td>
<td>Albert</td>
<td>16</td>
</tr>
<tr>
<td>2</td>
<td>Andrew</td>
<td>34</td>
</tr>
<tr>
<td>3</td>
<td>Charles </td>
<td>11</td>
</tr>
</table>
</body>
</html>
Tables do not have any borders by default. We can use the CSS border property to
add borders to the tables. Also, table cells are sized just large enough to fit the contents by
default. To add more space around the content in the table cells we can use the
CSS padding property. (The CSS padding property is used to generate space around an
element's content, inside any defined borders.)
Cell spacing is the space between each cell. By default the space is set to 2 pixels. To change
the space between table cells, use the CSS border-spacing property on the table element.
The following style adds a 1-pixel solid black colour border to the table and 10-pixels of
padding to its cells.
<style>
table, th, td {
border: 1px solid black;
border-spacing: 15px;
}
th, td {
padding: 10px;
}
</style>
You can change the thickness of the border by increasing the value of 1px to 5px,
style of the border can be changed by replacing solid to dotted or dashed and colour can be
changed by specifying the colour instead of black.
Eg. table, th, td { border: 5px dotted red; }
By default, borders around the table and their cells are separated from each other.
But you can collapse them into one by using the border-collapse property on
the <table> element.
By default text written in <td> element is left aligned and text written in <th>
element is center aligned. To change the default alignment you can use the
CSS text-align property.
By default the table is displayed on the left side of the web page. To align it on the
right side use float: right or to align it in the center of the web page, use margin CSS
property to auto as shown below:
<style>
table {
border-collapse: collapse; margin: auto;}
th {
text-align: left; }
td {
text-align: center; }
</style>
The width of the table can be adjusted using width property
table {width: 300px; }
<table>
<tr>
<th>Name:</th>
<td>John Smith</td>
</tr>
<tr>
<th rowspan="2">Phone:</th>
<td>5550192</td>
</tr>
<tr> <td>5550152</td> </tr > </table>
<!DOCTYPE html>
<html>
<head>
<title>Adding a Caption to the HTML Table</title>
<style>
table {
width: 300px;
border-spacing: 10px;}
table, th, td {
border: 1px solid black; }
th, td {
padding: 15px; }
#c01 {
background-color: lightgreen; }
#c02 {
background-color: lightblue; }
#c03 {
background-color: lightpink; }
</style>
</head>
<body>
<h2>Table with Caption at the Top</h2>
<table style="background-color: red;">
<caption>Users Info</caption>
<tr id="c01">
<th>No.</th>
<th>Name</th>
<th>Age</th>
</tr>
<tr id="c02">
<td>1</td>
<td>Peter Parker</td>
<td>16</td>
</tr>
<tr id="c03">
<td>2</td>
<td>Clark Kent</td>
<td>34</td>
</tr>
</table>
<br><br>
<h2>Table with Caption at the Bottom</h2>
<table id="c01" style="border-collapse: collapse;">
<caption style="caption-side: bottom;">Users Info</caption>
<tr>
<th>No.</th>
<th>Name</th>
<th>Age</th>
</tr>
<tr>
<td>1</td>
<td>Peter Parker</td>
<td>16</td>
</tr>
<tr>
<td>2</td>
<td>Clark Kent</td>
<td>34</td>
</tr>
</table>
</body>
</html>
Chapter 9: External styling method
The following shows how a HTML document can link to a style sheet named
"website.css".
<head>
<link href="website.css" rel="stylesheet">
…..
</head>
The link tag includes href attribute and the value of it will specify the name of the
external stylesheet i.e css file. In this example, our css is named as website.css and it is
saved in the same folder as our html document. If the css file is not located in the same
folder as our html document, then the complete path needs to be specified. It is a better
practice to save the css file in the same folder as your html document.
The following code shows the contents of a style sheet file named "website.css". It is
mandatory to save this file with the extension .css . In this example, the text-align and color
property will be applied to all <h1> elements within all HTML documents that link to this
style sheet and the color, background-color and text-align properties will be applied to
all <p> elements within all HTML documents that link to this style sheet.
If we have a website having 50 webpages and the same style has to be applied to all
the webpages then creating an external stylesheet and including the link tag in all the
webpages is the easier and faster method.
The HTML <form> element defines a form that is used to collect user input.
<form>
.
.
form elements
.
.
</form>
An HTML form contains form elements.
Form elements are different types of input elements, like text fields, checkboxes,
radio buttons, submit buttons, and more.
The <input> element can be displayed in several ways, depending on the type
attribute.
Type Description
<input type="reset"> Defines a reset button (for setting all form elements to
initial / default values)
Example
<!DOCTYPE html>
<html>
<head>
<title> Form - Text Input
</title>
</head>
<body>
<h2>Text Input</h2>
<form>
First name: <input type="text" name="firstname"> <br>
Last name: <input type="text" name="lastname"> <br>
User Id: <input type="text" name="userid"> <br>
Password: <input type="password" name="pwd"> <br>
<input type="radio" name="gender" value="male" checked> Male<br>
<input type="radio" name="gender" value="female"> Female<br>
<input type="submit" value="Submit">
</form>
</body>
</html>
The default width of a text input field is 20 characters. Each input field must have a
name attribute to be submitted. If the name attribute is omitted, the data of that input field
will not be sent at all.
<!DOCTYPE html>
<html>
<head>
<title> Working with Form </title>
</head>
<body>
<h2>Grouping Form Data with Fieldset</h2>
<form>
<fieldset>
<legend>Personal information:</legend>
First name:<br>
<input type="text" name="firstname" value="Mickey">
<br>
Last name:<br>
<input type="text" name="lastname" value="Mouse">
<br><br>
<input type="submit" value="Submit">
</fieldset>
</form>
</body>
</html>
The <textarea> element defines a multi-line input field, which is used to accept
multiple line text from a user.
<textarea name="message" style="width:200px; height:600px;">The boy was playing
in the garden.</textarea>
Example
<select name="cars" size = "3" multiple>
<option value="volvo">Volvo</option>
<option value="honda">Honda</option>
<option value="fiat">Fiat</option>
<option value="audi">Audi</option>
</select>
Use the multiple attribute to allow the user to select more than one value.
Use the size attribute to specify the number of visible values, rest can be seen by
scrolling
Clicking Submit button will send the data from the form to the server.
The reset button brings the form back to it's initial, default values for the user to retype
them.
<!DOCTYPE html>
<html>
<head>
<title>My Form</title>
</head>
<body>
<h3> Enter Your Personal Information </h3>
<form>
First name :
<input type="text" name="firstname" required > <br><br>
Last name :
<input type="text" name="lastname"><br><br>
Password :
<input type="password" name="password"><br> <br>
<p>
<fieldset style="width:200px;">
<legend>Gender</legend>
<input type="radio" name="gender" value="male"> Male
<input type="radio" name="gender" value="female”>Female
</fieldset>
</p>
<p>
<fieldset style="width:220px;">
<legend>Hobbies</legend>
<input type="checkbox" name="hobby" value="sports">
Sports
<input type="checkbox" name="hobby" value="music">
Music
<input type="checkbox" name="hobby" value="reading">
Reading
</fieldset>
</p> <br>
Country :
<select>
<option>China</option>
<option>India</option>
<option>United States</option>
<option>Indonesia</option>
<option>Brazil</option>
</select><br> <br><br>
Address : <textarea name="address" id="address" style="width:170px; height:100px;">
</textarea>
<br><br><br><br>
Frames have been removed entirely in HTML 5 i.e they are obsolete. They are referred
here just for you to know how frames were used and how they worked until we used HTML
5.
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 a 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.
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. Each frame is indicated by <frame> tag and
it defines which HTML document shall open into the frame.
Disadvantages of Frames
There are few drawbacks in using frames, so it's never recommended to use frames in
your webpages –
1. Some smaller devices cannot cope with frames often because their screen is not big
enough to be divided up.
2. Sometimes your page will be displayed differently on different computers due to different
screen resolution.
3. The browser's back button might not work as the user hopes.
4. There are still few browsers that do not support frame technology.
There is another element known as HTML Inline Frame element <iframe> which is
permitted in HTML 5.
The iframe element does not replace the body of a page as done by <frameset> element
instead it is used to embed another HTML page/document within the current one. The
syntax is –
<iframe src="URL"></iframe>
Example below –
<!DOCTYPE html>
<html>
<head>
<title> Iframe Example</title>
</head>
<body>
<h1>Using iframe element</h1>
<p>Document content goes here...</p>
<iframe src="list.html" style="height:500px; width:500px;"></iframe>
<p>Document content continues...</p>
</body>
</html>
Chapter 12: HTML Layout
HTML Layouts
HTML layouts provide a way to arrange web pages in well-mannered and well-structured
form or we can say that HTML layout specifies a way in which the web pages can be
arranged. Web-page layout works with arrangement of visual elements of an HTML
document.
HTML <header>
The <header> element is used to create header section of web pages. The header contains
the introductory content, heading element, logo or icon for the webpage, and authorship
information.
Example:
</header>
HTML <nav>
The <nav> elements is a container for the main block of navigation links. It can contain links
for the same page or for other pages.
Example:
<nav style="background-color:#bcdeef;">
<ul>
<li><a href="#">link1</a></li>
<li><a href="#">link2</a></li>
<li><a href="#">link3</a></li>
<li><a href="#">link4</a></li>
</ul>
</nav>
HTML <section>
HTML <section> elements represent a separate section of a web page which contains
related element grouped together. It can contain: text, images, tables, videos, etc.
Example:
<section style="background-color:#ff7f50; width: 100%; border: 1px solid black;">
<h2>Introduction to HTML</h2>
<p>HTML is a markup language which is used for creating attractive web pages with the
help of styling, and which looks in a nice format on a web browser..</p>
</section>
HTML <footer>
HTML <footer> element defines the footer for that document or web page. It mostly
contains information about author, copyright, other links, etc.
Example:
<h3>Footer Example</h3>
</footer>