Unit 2 (Iwt)
Unit 2 (Iwt)
What is HTML?
HTML stands for Hyper Text Markup Language
HTML is the standard markup language for creating Web pages
HTML describes the structure of a Web page
HTML consists of a series of elements
HTML elements tell the browser how to display the content
HTML elements label pieces of content such as "this is a heading", "this is
a paragraph", "this is a link", etc.
</body>
</html>
Example Explained
The <!DOCTYPE html> declaration defines that this document is an HTML5
document
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
HTML ORIGINS
HTML, which stands for HyperText Markup Language, is the standard markup language
used to create web pages. It was first developed by Tim Berners-Lee in 1990 while
working at CERN (the European Organization for Nuclear Research) in Switzerland.
HTML was created as a means to share scientific documents among researchers at
CERN.
The first publicly available description of HTML was a document called "HTML Tags,"
written by Tim Berners-Lee in 1991. This document outlined the basic structure of HTML
and introduced tags for formatting text, creating links, and structuring documents.
HTML continued to evolve over the years with various versions and updates, each
adding new features and improvements. The World Wide Web Consortium (W3C) is the
organization responsible for overseeing the development of HTML standards.
Since its inception, HTML has become the foundation of the World Wide Web, providing
the structure for web pages and enabling the creation of interconnected documents
accessible via the internet
HTML VERSION
Since the early days of the World Wide Web, there have been many versions of
HTML:
Year Version
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
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">
Note: When a web page loads, it is the browser, at that moment, that gets the
image from a web server and inserts it into the page. Therefore, make sure that
the image actually stays in the same spot in relation to the web page, otherwise
your visitors will get a broken link icon. The broken link icon and the alt text are
shown if the browser cannot find the image.
Example
<img src="img_chania.jpg" alt="Flowers in Chania">
HTML Lists
HTML Lists are used to specify lists of information. All lists may contain one or more list
elements. There are three different types of HTML lists:
1. Ordered List or Numbered List (ol)
2. Unordered List or Bulleted List (ul)
3. Description List or Definition List (dl)
Note: We can create a list inside another list, which will be termed as nested List.
HTML Table
HTML table tag is used to display data in tabular form (row * column). There can be
many columns in a row.
We can create a table to display data in tabular form, using <table> element, with the
help of <tr> , <td>, and <th> elements.
In Each table, table row is defined by <tr> tag, table header is defined by <th>, and
table data is defined by <td> tags.
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 .
<col> It is used with <colgroup> element to specify column properties for each column.
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. .
Example:
1. <body>
2. <form>
3. Enter your name <br>
4. <input type="text" name="username">
5. </form>
6. </body>
HTML Form Tags
Let's see the list of HTML 5 form tags.
Tag Description
Example:
1. <form action="action.html" method="post">
o get: The get value of method attribute is default value while submitting the form. But
this is not secure as it displays data in URL after submitting the form.
Example:
1. <form action="action.html" method="get">
When submitting the data, it will display the entered data in the form of:
1. file:///D:/HTML/action.html?name=JavaTPoint&pass=123
Notes on GET:
Notes on POST:
Appends the form data inside the body of the HTTP request (the
submitted form data is not shown in the URL)
POST has no size limitations, and can be used to send large amounts of
data.
Form submissions with POST cannot be bookmarked
Tip: Always use POST if the form data contains sensitive or personal
information!
Example:
1. <form action="action.html" method="get" target="_self">
o _blank: If we use _blank as an attribute it will load the response in a new page.
Example:
1. <form action="action.html" method="get" target="_blank">
Example:
1. <form action="action.html" method="get" autocomplete="on">
Example:
1. <form action="action.html" method="get" autocomplete="off">
Note: it can be used with <form> element and <input> element both.
Example:
1. <form action="action.html" method="post" enctype="application/x-www-form-urlencoded" >
o multipart/form-data: It does not encode any character. It is used when our form
contains file-upload controls.
Example:
1. <form action="action.html" method="post" enctype="multipart/form-data">
o text/plain (HTML5): In this encoding type only space are encoded into + symbol and
no any other special character encoded.
Example:
1. <form action="action.html" method="post" enctype="text/plain" >
What is XHTML
XHTML stands for EXtensible HyperText Markup Language. It is a cross
between HTML and XML language.
XHTML is almost identical to HTML but it is stricter than HTML. XHTML is
HTML defined as an XML application. It is supported by all major browsers.
Although XHTML is almost the same as HTML but It is more important to
create your code correctly, because XHTML is stricter than HTML in syntax and
case sensitivity. XHTML documents are well-formed and parsed using standard
XML parsers, unlike HTML, which requires a lenient HTML-specific parser.
History
XHTML 1.0 became a World Wide Web Consortium (W3C) Recommendation
on January 26, 2000. XHTML 1.1 became a W3C Recommendation on May 31,
2001. The standard known as XHTML5 is being developed as an XML
adaptation of the HTML5 specification.
XHTML Syntax
XHTML syntax is very similar to HTML syntax and all the valid HTML elements
are also valid in XHTML. But XHTML is case sensitive so you have to pay a bit
extra attention while writing an XHTML document to make your HTML
document compliant to XHTML.
You must remember the following important points while writing a new
XHTML document or converting existing HTML document into XHTML
document:
o All documents must have a DOCTYPE.
o All tags must be in lower case.
o All documents must be properly formed.
o All tags must be closed.
o All attributes must be added properly.
o The name attribute has changed.
o Attributes cannot be shortened.
o All tags must be properly nested.
DOCTYPE Declaration
All XHTML documents must contain a DOCTYPE declaration at the start. There
are three types of DOCTYPE declarations:
o Strict
o Transitional
o Frameset
Here is an example of using DOCTYPE.
1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
Attribute Quotes
All the XHTML attribute's values must be quoted. Otherwise, your XHTML
document is assumed as an invalid document.
See this example:
1. <!-- Invalid in XHTML -->
2. <img src="/images/xhtml.gif" width=250 height=50 />
3. <!-- Valid in XHTML -->
4. <img src="/images/xhtml.gif" width="250" height="50" />
Attribute Minimization
XHTML doesn't allow you to minimize attributes. You have to explicitly state
the attribute and its value.
S.No. HTML XHTML
6. It is not case sensitive as there is no mandatory rule It is case-sensitive, and every tag and
to write the entire mark up in uppercase or lower attribute used inside must be in
case. It can also be a combination of both. lowercase.
8. We can close any tag anytime and anywhere as per It is mandatory to close all the tags in
our needs strict residing order as they were
declared.
9. We can add attributes without any quotes. It is mandatory to add quotes on every
attribute we declare
10. ,html and .htm are the extensions used by HTML .xhtml, .xml and .xht are the file
extensions used by XHTML