Introduction To Web Technology: Unit 3 HTML
Introduction To Web Technology: Unit 3 HTML
Technology
Unit 3 HTML
Introduction
HTML was developed with the intent of defining the structure of documents like
headings, paragraphs, lists, and so forth to facilitate the sharing of scientific
information between researchers.
Now, HTML is being widely used to format web pages with the help of different
tags available in HTML language.
HTML is a MUST for students and working professionals to become a great
Software Engineer specially when they are working in Web Development
Domain.
Advantages of HTML
• Create Web site - You can create a website or customize an existing web
template if you know HTML well.
• Become a web designer - If you want to start a carrer as a professional web
designer, HTML and CSS designing is a must skill.
• Understand web - If you want to optimize your website, to boost its speed and
performance, it is good to know HTML to yield best results.
• Learn other languages - Once you understands the basic of HTML then other
related technologies like javascript, php, or angular are become easier to
understand.
Applications of HTML
• Web pages development - HTML is used to create pages which are rendered
over the web. Almost every page of web is having html tags in it to render its
details in browser.
• Internet Navigation - HTML provides tags which are used to navigate from one
page to another and is heavily used in internet navigation.
• Responsive UI - HTML pages now-a-days works well on all platform, mobile,
tabs, desktop or laptops owing to responsive design strategy.
• Offline support HTML pages once loaded can be made available offline on the
machine without any need of internet.
• Game development- HTML5 has native support for rich experience and is now
useful in gaming developent arena as well.
Simple HTML Document
<!DOCTYPE html>
<html>
<head>
<title>Page Title</title>
</head>
<body>
<h1>My First Heading</h1>
<p>My first paragraph.</p>
</body>
</html>
Simple HTML Document
Example Explained
The <!DOCTYPE html> declaration defines this document to be HTML5
The <html> element is the root element of an HTML page
The <head> element contains meta information about the document
The <title> element specifies a title for the document
The <body> element contains the visible page content
The <h1> element defines a large heading
The <p> element defines a paragraph
HTML Tags
Since the early days of the web, there have been many versions of HTML:
Version Year
HTML 1991
XHTML 2000
HTML5 2014
HTML Documents
All HTML documents must start with a document type declaration: <!DOCTYPE
html>. The HTML document itself begins with <html> and ends with </html>.
The visible part of the HTML document is between <body> and </body>. Example
<!DOCTYPE html>
<html>
<body>
<h1>My First Heading</h1>
<p>My first paragraph.</p>
</body>
</html>
HTML Headings and Paragraphs
HTML Elements
An HTML element usually consists of a start tag and end tag, with the content inserted in
between:
<tagname>Content goes here...</tagname>
The HTML element is everything from the start tag to the end tag:
<p>My first paragraph.</p>
Empty HTML Elements
HTML elements with no content are called empty elements.
<br> is an empty element without a closing tag (the <br> tag defines a line
break). Empty elements can be "closed" in the opening tag like this: <br />.
HTML5 does not require empty elements to be closed. But if you want stricter
validation, or if you need to make your document readable by XML parsers, you
must close all HTML elements properly.
HTML Attributes
To find out, right-click in the page and select "View Page Source" (in Chrome)
or "View Source" (in IE), or similar in other browsers. This will open a window
containing the HTML source code of the page.
Inspect an HTML Element:
Right-click on an element (or a blank area), and choose "Inspect" or "Inspect Element"
to see what elements are made up of (you will see both the HTML and the CSS). You
can also edit the HTML or CSS on-the-fly in the Elements or Styles panel that opens.
HTML Line Breaks
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:
Tag Description
You can add comments to your HTML source by using the following syntax:
<!-- Write your comments here -->
Notice that there is an exclamation point (!) in the opening tag, but not in the closing
tag.
Comments are not displayed by the browser, but they can help document your
HTML source code.
With comments you can place notifications and reminders in
your HTML
HTML Colour
HTML colors are specified using predefined color names, or RGB, HEX,
HSL, RGBA, HSLA values.
Color Names
In HTML, a color can be specified by using a color name:
Tomato
Orange
DodgerBlue
MediumSeaGreen
Gray
SlateBlue
Violet
LightGray
HTML Colour
Example
<h1 style="background-color:DodgerBlue;">Hello World</h1>
<p style="background-color:Tomato;">Hello</p>
Text Color Example
<h1
style="color:Tomato;">Hello
World</h1>
<p style="color:DodgerBlue;">
Hello World.</p>
<p
style="color:MediumSeaGreen;
"> Hello World</p>
Border Color Example
<h1 style="border:2px solid
Tomato;">Hello World</h1>
<h1 style="border:2px solid
DodgerBlue;">Hello
HTML Table
Collapsed Border :
If you want the borders to collapse into one border, add the border-collapse
property
Cell padding
Cell padding specifies the space between the cell content and its borders.
If you do not specify a padding, the table cells will be displayed without
padding.
To set the padding, use the padding property:
Left align heading:
By default, table headings are bold and centered.
To left-align the table headings, use the text-align property
HTML Table
Adding a Caption
To add a caption to a table, use the <caption> tag
A Special Style for One Table
To define a special style for a special table, add an id attribute to the table
HTML Lists
The <dl> tag defines the description list, the <dt> tag defines the term (name), and the
<dd> tag describes each term
Block-Level Element
A block-level element always starts on a new line and takes up the full width
available (stretches out to the left and right as far as it can).
The <div> element is a block-level element.
Inline Elements
An inline element does not start on a new line and only takes up as much width
as necessary.
This is an inline <span> element inside a paragraph.
<div>
The <div> element is often used as a container for other HTML elements.
The <div> element has no required attributes, but both style and class are
common.
When used together with CSS, the <div> element can be used to style
blocks of content:
Example
<div style="background-color:black;color:white;padding:20px;">
<h2>London</h2>
<p>London is the capital city of England. It is the most populous city in the
United Kingdom, with a metropolitan area of over 13 million inhabitants.</p>
</div>
<span>
Using The class Attribute The class attribute specifies one or more class names for an
HTML element.
The class name can be used by CSS and JavaScript to perform certain tasks for
elements with the specified class name.
HTML Iframe
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.
HTML Form
Image Map is a list of coordinates relating to a specific Image that allows users
to access different web pages by clicking on different areas of an Image.
Elements required in Mapping an Image :
There are three basic html elements which are required for creating a
mapped image.
1. Map : It is used to create a map of the image with clickable areas.
2. Image : It is used for the image source on which mapping is done.
3. Area : It is used within the map for defining clickable areas.
Image Mapping
Server-side image mapping uses images, .map files and CGI scripts. Often
server-side image maps use the Imagemap programme.
The programme processing image maps needs to be on the server, usually in
the cgi-bin/ directory.
The HREF attribute of server side imagemaps is always a hyperlink to the cgi-
bin directory:
<a href="/cgi-bin/imagemap/user_dir/image.map">
<img src="/user_dir/image.gif">
</a>
Server-side image mapping
In fact, the HREF path can sometimes be interpreted as a combination of two paths:
The location of the "imagemap" programme, such as /cgi-bin/imagemap
The location of the (coordinate) map for the image, user_dir/image.map. This
describes the various areas of the image.
A major disadvantage of server-side image maps is that their implementation can
differ between different server systems. This means that the author of the website
using image maps needs to communicate closely with the Web server's administrator
to ensure that the maps work correctly.
Since there are so many advantages to client-side imagemaps, and almost all
current browser versions support them, we shall not explore server-side image maps
further in this unit (although most image map programmes still provide features to
output/edit server-side map files).
Client-side image mapping