chap 1 HTML5
chap 1 HTML5
CS SEM III
WEB PROGRAMMING
UNIT 1
Chap 1 HTML5
-Ms. Pratiksha Harwalkar
Introduction to HTML5
What is HTML?
HTML stands for HyperText Markup Language. HTML
is the basic building block of World Wide Web.
A markup language is a computer language that
uses tags to define elements within a document. It
is human-readable, meaning markup files contain
standard words.
HTML is the main markup language for describing
the structure of web pages.
HTML5 is a next version of HTML. Here, you will get
some brand new features which will make HTML
much easier.
These new introducing features make your website
layout clearer to both website designers and users.
There are some elements like <header>, <footer>,
<nav> and <article> that define the layout of a
website.
Basic Structure of an HTML
A well-structured HTML document will have below
three sections.
1. A html is the root element of an HTML page.
2. A head that identifies a document as HTML and
establishes its title.
3. A body that contains the content for a Web page.
This part holds all displayed text on a page
Fundamental Elements of HTML
An HTML element usually consists of a start tag
and end tag, with the content inserted in between
the tags:
Syntax:
<tagname>Content goes here...</tagname>
OUTPUT:
Document content goes here.....
Organizing Text in HTML
In a Web page, the content is organized into the
different formats, such as layers, paragraphs, lines,
tables, and divisions that we have already learned.
Organizing text refers to the proper placement of all the
HTML tags and their content in a Web page. By default,
a Web browser wraps text in a Web page and displays
the enclosed text in a single block by avoiding the line
and paragraph breaks Now, if the content of a page is
not separated by any line or paragraph breaks, it
becomes very tedious for the readers to understand
the given information.
If text in the Web page is not arranged then the readers
will find difficulty in reading the desired information.
To overcome this problem, you can arrange the text
in different ways, such as paragraphs, lines, and
tables. HTML provides a number of tags to arrange
text into paragraphs and tables.
For instance, you can display the text on the Web
page as paragraphs by using the P tag, or display a
horizontal line in a Web page representing a break in
the text. HTML also allows you to change to format
of a specific text using the SPAN tag.
Links and URL’s in HTML
HTML links are hyperlinks.
It Defines a link to an external resource or document.
Hyperlinks is one of the very core features of HTML, it
enables you to jump from one webpage to another.
The very idea of World Wide Web is built around
Hyper-links. All day to day activities like Browsing,
Surfing, Downloads depends upon links.
Any text can be transformed into a hyperlink by
encapsulating it within anchor tag <a>
The attribute href contains the URL of the web
document, to which the clickable text links.
Note: A link does not have to be text. It can be an
image or any other HTML element.
Types of Links
There are mainly two types of Links:
1. Header Links
2. Anchor Links
1. Hearder Links:
using <link> element within the <head> element.
2. Anchor Links:
using anchor element<a> , within <body> element
Syntax:
<a href="url"> Link_text </a>
Example:
<a href="https://www.google.com/"> Click Here </a>
Code Explaination :
The href attribute specifies the destination address
(https://www.google.com/) of the link.
The Link_text is the visible part (Click Here).
Clicking on the link text will send you to the
specified address.
Example :
<!DOCTYPE html>
<html>
<head>
<title>Hyperlink Example</title>
</head>
<body>
<p>Click following link</p>
<a href = "https://www.google.com"
target = "_self">Click Here</a>
</body>
</html>
This will produce the result, where we can click on
the link generated to reach to the home page of
Google (in this example).
2 _self
Opens the linked document in the same frame.
3 _parent
Opens the linked document in the parent frame. Frames
are deprecated in HTML5.
4 _top
Opens the linked document in the full body of the
window. Frames are deprecated in HTML5.
5 targetframe
Opens the linked document in a named targetframe.
Frames are deprecated in HTML5.
Try following example to understand basic difference in few
options given for target attribute
<!DOCTYPE html>
<html>
<head>
<title>Hyperlink Example</title>
<base href = "https://www.google.com/">
</head>
<body>
<p>Click any of the following links</p>
<a href = "https://www.google.com/" target = "_blank">Opens
in New</a> |
<a href = "https://www.google.com/" target = "_self">Opens in
Self</a> |
<a href = "https://www.google.com/" target = "_parent">Opens in
Parent</a> |
<a href "https://www.google.com/" target = "_top">Opens in
Body</a>
</body>
</html>
OUTPUT :
Click any of the following links
Opens in New | Opens in Self | Opens in Parent | Opens in Body
This will produce the following result, where you can click on
different links to understand the difference between various
options given for target attribute.
Use of Base Path
When we link HTML documents related to the same
website, it is not required to give a complete URL for
every link.
We can get rid of it if you use <base>tag in your
HTML document header. This tag is used to give a
base path for all the links.
So the browser will concatenate given relative path
to this base path and will make a complete URL.
Example:
Following example makes use of <base> tag to specify base URL and
later we can use relative path to all the links instead of giving
complete URL for every link.
<!DOCTYPE html>
<html>
<head>
<title>Hyperlink Example</title>
<base href = "https://wikipedia.org/">
</head>
<body>
<p>Click following link</p>
<a href = "/wiki/Main_Page/" target = "_blank">
Wikipedia </a>
</body>
</html>
OUTPUT :
Click following link
Wikipedia
Code Explaination:
aValue Description
Top-left, bottom- Specifies the coordinates of the top-left and
right bottom-right corner of the rectangle
(x1,y1,x2,y2) (shape="rect")
Table Heading
Table heading can be defined using <th> tag. This tag
will be put to replace <td> tag, which is used to
represent actual data cell.
Normally we will put the top row as table heading as
shown below, otherwise we can use <th> element in
any row. Headings, which are defined in <th> tag are
centered and bold by default.
Example :
<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>
This will produce the following result −
Name Salary
Ramesh Raman 5000
Shabbir Hussein 7000
SYNTAX −
<form action = "Script URL" method = "GET|POST">
<!--form elements like input, textarea etc. -->
</form>
Interactive Form Controls
Following are different types of controls that you can
use in your form:
The <input> Element
The <input> element is the most important form
element.
The <input> element can be displayed in several
ways, depending on the type attribute.
Different types of Input control are as following :
Type Description
<input type="text"> Defines a one-line text input
field (also called as single-line
text input control)
<input type="radio"> Defines a radio button (for
selecting one of many choices)
<input type="submit"> Defines a submit button (for
submitting the form)
Last name:
Submit
The Action Attribute
The action attribute defines the action to be
performed when the form is submitted.
Normally, the form data is sent to a web page on the
server when the user clicks on the submit button.
In the example above, the form data is sent to a page
on the server called "/div.html".
If the action attribute is omitted, the action is set to the
current page.
The Method Attribute
The method attribute specifies the HTTP method
(GET or POST) to be used when submitting the form
data:
<form action="/action_page.php" method="get">
OR
<form action="/action_page.php" method="post">
When to Use GET?
The default method when submitting form data is
GET.
However, when GET is used, the submitted form data
will be visible in the page address field:
e.g
/action_page.php?firstname=Mickey&lastname=Mouse