Module 4
Module 4
Module 4
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>
HERE
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 PAGE STRUCTURE
BASIC TAGS
1. HTML tag
An HTML tag is a piece of markup language used to indicate the beginning and end of
an HTML element in an HTML document.
It starts with <html> and ends with backslash </html>
Everything else in your web page then goes between these 2 tags.
<html>
(all other page elements go here)
</html>
2. HEAD tag
The head element contains information about the web page, as opposed to the web page content itself.
There are many elements that you can put inside the head element, such as:
Syntax : <head> </head>
title (described below)
link, which you can use to add style sheets and favicons to your page
Any document starts with a heading. You can use different sizes for your headings. HTML also
has six levels of headings, which use the elements <h1>, <h2>, <h3>, <h4>, <h5>, and
<h6>. While displaying any heading, browser adds one line before and one line after that
heading.
For example:
<html>
<head>
<title>Title of the document</title>
</head>
</html>
3.Title tag
The <title> tag defines the title of the document. The title must be text-only, and it is shown in the
browser's title bar or in the page's tab.
For example:
<html>
<head>
<title>HTML Elements Reference</title>
</head>
</html>
4.Body Tag
The <body> element contains all the contents of an HTML document, such as headings, paragraphs,
images, hyperlinks, tables, lists, etc.
For example:
<html>
<head>
<title>Title of the document</title>
</head>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
<body>
<p>
This paragraph
contains a lot of lines
in the source code,
but the browser
ignores it.
</p>
</body>
Output:
6. anchor Tag [<a></a>]
The <a> tag defines a hyperlink, which is used to link from one page to another.
The most important attribute of the <a> element is the href attribute, which indicates the link's destination.
Href attribute
The HTML <a> href Attribute is used to specify the URL of the page that the link goes to. When the
href attribute is not present in the <a> an element that it will not be a hyperlink.
This attribute is used to specify a link to any address. This attribute is used along with <a> tag.
Syntax:
Example:
<html>
<body>
<h1>GeeksForGeeks</h1>
<h2>
</h2>
</a>
<br>
target="_blank">
</a>
</body>
</html>
7.image tag [<img></img>]
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.
Note: Also, always specify the width and height of an image. If width and height are not specified, the page
might flicker while the image loads.
Tip: To link an image to another document, simply nest the <img> tag inside an <a> tag (see example
below).
Syntax:
EXAMPLE:
Example To try following example, let's keep our HTML file test.htm and image file test.png in the same
directory − Live Demo
<!DOCTYPE html>
<html>
<head>
</head>
<body>
</body>
</html>
This will produce the following result –
The <br /> tag has a space between the characters br and the forward slash. If you omit this space, older
browsers will have trouble rendering the line break, while if you miss the forward slash character and just
use
Example
9. <DIV> </DIV>
An element which is mostly used to group elements and to act as a template for new controls. The
div HTML tag is an element you will use to divide a significant part of an HTML document from
other parts. For examplle, let’s say you have a list of products on your web page, you will use a div
for each product.
If you have a lot of text, then you need to emphasise some words to let the reader know what is
important. Rather, with italics you can present text that is a little tilted to the right.
Example:
Output:-
11. <STRONG> </STRONG>
Text is emphasised strongly - usually appears in bold, most of the time it looks like bold too. But it
Example:
Syntax:
<table>
<tr>
<td> </td>
</tr>
</table>
Header cells - contains header information (created with the <th> element)
Data cells - contains data (created with the <td> element)
You will use colspan attribute if you want to merge two or more columns into a single
column. Similar way you will use rowspan if you want to merge two or more rows.
3.Tables Backgrounds
You can set table background using one of the following two ways – ● bgcolor attribute −
You can set background color for whole table or just for one cell. ● background attribute −
You can set background image for whole table or just for one cell. You can also set border
color also using bordercolor attribute. Note − The bgcolor, background, and bordercolor
attributes deprecated in HTML5. Do not use these attributes.
Example of html tables:
[Q3.] what is list? Explain different types of list with example:
HTML lists allow web developers to group a set of related items in lists.
An ordered list starts with the <ol> tag. Each list item starts with the <li> tag.
<!DOCTYPE html>
<html>
<body>
<ol>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ol>
</body>
</html>
Output:
1. Coffee
2. Tea
3. Milk
2.Unordered HTML List
An unordered list starts with the <ul> tag. Each list item starts with the <li> tag.
The list items will be marked with bullets (small black circles) by default:
<!DOCTYPE html>
<html>
<body>
<ul>
<li>Coffee</li>
<li>Tea</li>
<li>Milk</li>
</ul>
</body>
</html>
Output:
Coffee
Tea
Milk
3.HTML Description Lists
HTML also supports description lists.
The <dl> tag defines the description list, the <dt> tag defines the term (name), and
the <dd> tag describes each term:
<!DOCTYPE html>
<html>
<body>
<dl>
<dt>Coffee</dt>
<dt>Milk</dt>
</dl>
</body>
</html>
Description List
Coffee
- black hot drink
Milk
- white cold drink