HTML Css Module Makaut
HTML Css Module Makaut
Chapter- 2
Part-1
HTML Basics HTML:
Introduction, Basic Structure of HTML,
Head Section and Elements of Head
Section, Formatting Tags: Bold, Italic,
Underline, Strikethrough, Div, Pre Tag
Anchor links and Named Anchors Image
Tag, Paragraphs, Comments, Tables:
Attributes –(Border, Cellpadding, Cell
spacing , height , width), TR, TH, TD, Basics of Web Design
Rowspan, Colspan Lists : Ordered List ,
Unordered List , Definition List,
Forms,Form Elements, Input types, Input
Attributes, Text Input Text Area,
Dropdown, Radio buttons , Check boxes,
Submit and Reset Buttons Frames:
Frameset, nested Frames.
HTML
HTML stands for Hyper Text Markup Language. It is a formatting language used to define
the appearance and contents of a web page. It allows us to organize text, graphics, audio,
and video on a web [Link] Points:
The word Hypertext refers to the text which acts as a link.
The word markup refers to the symbols that are used to define structure of the text. The
markup symbols tells the browser how to display the text and are often called tags.
The word Language refers to the syntax that is similar to any other [Link] was
created by Tim Berners-Lee at CERN.
HTML Versions
The following table shows the various versions of HTML:
Version Year
HTML 1.0 1991
HTML 2.0 1995
HTML 3.2 1997
HTML 4.0 1999
XHTML 2000
HTML5 2012
STRUCTURE OF HTML DOCUMENT
The main component of HTML document is HTML tag. HTML document is written by
using HTML tag. Tag comes in pair and it is written in between (start tag) and (End tag
The first tag of HTML document is <HTML> and the last tag is </HTML>. 7 indicates the
end of that tag. There are mainly four parts of HTML document and they are:
1. HTML tag
2. Head tag
3. body tag
4. Graphics tag
Key Points:
Tags are indicated with pair of angle brackets.
They start with a less than < character and end with a greater than > character. The tag
name is specified between the angle brackets.
Most of the tags usually occur in pair: the start tag and the closing tag.
The start tag is simply the tag name is enclosed in angle bracket whereas the closing tag is
specified including a forward slash /.
Some tags are the empty i.e. they don’t have the closing tag. Tags are not case sensitive.
The starting and closing tag name must be the same. For example <b> hello </i> is invalid
as both are different.
If you don’t specify the angle brackets <> for a tag, the browser will treat the tag name as a
simple text.
The tag can also have attributes to provide additional information about the tag to the
browser.
Basic tags
The following table shows the Basic HTML tags that define the basic web page:
Tag Description
<html> </html> Specifies the document as a web page.
<head> </head> Specifies the descriptive information about the web documents.
<title> </title> Specifies the title of the web page.
<body> </body> Specifies the body of a web document.
HTML TAG
<html>...........</html>
It is the root element of HTML document and all other elements or contained in it. The
following example will clear the concept-
<html>
</html>
HEAD TAG
In this page tile or title heading resides. Head tag starts with <head> tag and ends with
</head>. See the following example-
<html>
<head>
</html>
The <head> tag is a container for metadata (data about data) and is placed between the
<html> tag as shown above. Metadata is not displayed.
BODY TAG
The <body> tag contains the main subject matter of the web page. It must be the second
element after the <head> tag or it should be placed between <head> and </html> tag. This
is required for every HTML document and should only use once in the whole HTML
document see the following syntax-
EXAMPLE:
<html>
<head>
<title> Introduction to IT systems </title>
</head>
<body> welcome to IT systems introduced in new syllabus of 1st year second sem in
Diploma Engineering.
</body>
</html>
Some useful tags are listed in the following table-
Tag Description
<b> </b> Specifies the text as bold. Eg. this is bold text
<em> </em> It is a phrase text. It specifies the emphasized text. Eg. Emphasized
text
<strong> </strong> It is a phrase tag. It specifies an important text. Eg. this is strong text
<i> </i> The content of italic tag is displayed in italic. Eg. Italic text
<sub> </sub> Specifies the subscripted text. Eg. X1
<sup> </sup> Defines the superscripted text. Eg. X2
<ins> </ins> Specifies the inserted text. Eg. The price of pen is now 2015.
<del> </del> Specifies the deleted text. Eg. The price of pen is now 2015.
<mark> </mark> Specifies the marked text. Eg. It is raining
Table Tags
Following table describe the commonaly used table tags:
Tag Description
<table> </table> Specifies a table.
<tr> </tr> Specifies a row in the table.
<th> </th> Specifies header cell in the table.
<td> </td> Specifies the data in an cell of the table.
<caption> </caption> Specifies the table caption.
<colgroup> </colgroup> Specifies a group of columns in a table for formatting.
List tags
Following table describe the commonaly used list tags:
Tag Description
<ul> </ul> Specifies an unordered list.
<ol> </ol> Specifies an ordered list.
<li> </li> Specifies a list item.
<dl> </dl> Specifies a description list.
<dt> </dt> Specifies the term in a description list.
<dd> </dd> Specifies description of term in a description list.
Frames
Frames help us to divide the browser’s window into multiple rectangular regions. Each
region contains separate html web page and each of them work independently.
A set of frames in the entire browser is known as frameset. It tells the browser how to
divide browser window into frames and the web pages that each has to load.
The following table describes the various tags used for creating frames:
Tag Description
<frameset> It is replacement of the <body> tag. It doesn’t contain the tags that are
</frameset> normally used in <body> element; instead it contains the <frame>
element used to add each frame.
<base> It is used to set the default target frame in any page that contains links
</base> whose contents are displayed in another frame.
<br> line break The contents of your page<br>The contents of your page
horizonta l rule
<hr> <hr width="50%" size="3" />
horizonta l rule
<hr> <hr width="50%" size="3" noshade />
<hr> horizonta l rule <hr width="75%" color="#ff0000" size="4"
(Internet />
Explorer)
<hr> horizonta l rule <hr width="25%" color="#6699ff" size="6"
(Internet />
Explorer)
<html>
<head>
<meta>
hypertext markup <title>Title of your web page</title>
<html> language </head>
<body>HTML web page contents
</body>
</html>
<i> italic <i>Example</i>
<img src="[Link]" width="41" height="41"
<img> image border="0" alt="text describing the image" />
Example 1:
<form method=post action="/cgi-
input field bin/[Link]">
<input> <input type="text" size="10"
maxlength="30">
<input type="Submit" value="Submit">
</form>
Example 2:
<form method=post action="/cgi-
bin/[Link]">
<input type="text" style="color: #ffffff;
<input>
input field font-family: Verdana; font-weight: bold; font- size:
(Internet
12px; background-color: #72a4d2;" size="10"
Explorer)
maxlength="30">
<input type="Submit" value="Submit">
</form>
Example 3:
Example 5:
<form method=post action="/cgi- bin/[Link]">
<center>
Select an option:
<select>
<option >option 1</option>
<option selected>option 2</option>
input field <option>option 3</option>
<input> <option>option 4</option>
<option>option 5</option>
<option>option 6</option>
</select><br>
<input type="Submit"
value="Submit"></center>
</form>
<input> input field Example 6:
<form method=post action="/cgi- bin/[Link]">
Select an option:<br>
<input type="radio" name="option"> Option 1
<input type="radio" name="option" checked> Option
2
<input type="radio" name="option"> Option 3
<br>
<br>
Select an option:<br>
<input type="checkbox" name="selection">
Selection 1
<input type="checkbox" name="selection" checked>
Selection 2
<input type="checkbox" name="selection">
Selection 3
<input type="Submit" value="Submit">
</form>
Example 1:
<menu>
<li type="disc">List item 1</li>
<li type="circle">List item 2</li>
<li type="square">List item 3</li>
</MENU>
<li> list item Example 2:
<ol type="i">
<li>List item 1</li>
<li>List item 2</li>
<li>List item 3</li>
<li>List item 4</li>
</ol>
<head>
<link> link <link rel="stylesheet" type="text/css" href="[Link]"
/>
</head>
<marquee
> scrolling text <marquee bgcolor="#cccccc" loop="-1"
(Internet scrollamount="2" width="100%">Example
Explorer) Marquee</marquee>
<menu>
<li type="disc">List item 1</li>
<menu> menu <li type="circle">List item 2</li>
<li type="square">List item 3</li>
</menu>
<meta name="Description" content="Description of
<meta> meta your site">
<meta name="keywords" content="keywords
describing your site">
<meta HTTP-EQUIV="Refresh"
<meta> meta CONTENT="4;URL=[Link]
om/">
<ol type="I">
<li>List item 1</li>
<li>List item 2</li>
<li>List item 3</li>
<li>List item 4</li>
</ol>
Capital Roman Numerals Special Start
HTML Attributes
The <a> tag defines a hyperlink. The href attribute specifies the URL of the page the link
goes to:
<html><body>
<p>HTML links are defined with the a tag. The link address is specified in the href attribute:</p>
</body></html>
The <img> tag is used to embed an image in an HTML page. The src attribute specifies the
path to the image to be displayed:
There are two ways to specify the URL in the src attribute:
Example: src="[Link]
2. Relative URL - Links to an image that is hosted within the website. Here, the URL does
not include the domain name. If the URL begins without a slash, it will be relative to the
current page. Example: src="img_girl.jpg". If the URL begins with a slash, it will be relative
to the domain. Example: src="/images/img_girl.jpg".
The width and height Attributes
The <img> tag should also contain the width and height attributes, which specify the width
and height of the image (in pixels):
The required alt attribute for the <img> tag specifies an alternate text for an image, if the
image for some reason cannot be displayed. This can be due to a slow connection, or an error
in the src attribute, or if the user uses a screen reader.
<p>If we try to display an image that does not exist, the value of the alt attribute will be displayed
instead. </p>
</body></html>
The style attribute is used to add styles to an element, such as color, font, size, and more.
<html>
<body>
<h2>The style Attribute</h2>
<p>The style attribute is used to add styles to an element, such as color:</p>
<p style="color:red;">This is a red paragraph.</p>
</body>
</html>
The lang Attribute
You should always include the lang attribute inside the <html> tag, to declare the language
of the Web page. This is meant to assist search engines and browsers.
<!DOCTYPE html>
<html lang="en"><body>...</body>
</html>
Country codes can also be added to the language code in the lang attribute. So, the first two
characters define the language of the HTML page, and the last two characters define the
country.
The following example specifies English as the language and United States as the country:
<!DOCTYPE html>
<html lang="en-US"><body>...</body>
</html>
The value of the title attribute will be displayed as a tooltip when you mouse over the
element:
<html>
<p title="I'm a tooltip">Mouse over this paragraph, to display the title attribute as a tooltip.</p>
</body>
</html>
HTML Attribute Reference
The table below lists all HTML attributes and what elements they can be used within:
<option>, <select>,
<textarea>
Specifies that the target will be downloaded
download <a>, <area>
when a user clicks on the hyperlink
<button>, <fieldset>,
Specifies the name of the form the element
form <input>, <label>,
belongs to
<meter>,
<object>, <output>,
<select>, <textarea>
<canvas>, <embed>,
height <iframe>, <img>, Specifies the height of the element
<input>,
<object>, <video>
<track>, <option>,
label Specifies the title of the text track
<optgroup>
<input>, <meter>,
max Specifies the maximum value
<progress>
<button>, <fieldset>,
name <form>, <iframe>, Specifies the name of the element
<input>,
<map>, <meta>,
<object>, <output>,
<param>,
<select>, <textarea>
Specifies that the form should not be
no validate <form>
validated when submitted
<audio>, <embed>,
onabort <img>, <object>, Script to be run on abort
<video>
onblur All visible elements. Script to be run when the element loses focus
on dragend All visible elements. Script to be run at the end of a drag operation
on drag start All visible elements. Script to be run at the start of a drag operation
<audio>, <body>,
on error <embed>, <img>, Script to be run when an error occurs
<object>,
<script>, <style>,
<video>
on focus All visible elements. Script to be run when the element gets focus
onkeydown All visible elements. Script to be run when a user is pressing a key
onkeypress All visible elements. Script to be run when a user presses a key
onkeyup All visible elements. Script to be run when a user releases a key
<body>, <iframe>,
Script to be run when the element is finished
onload <img>, <input>,
loading
<link>,
<script>, <style>
on loaded data <audio>, <video> Script to be run when media data is loaded
The HTML standard does not require quotes around attribute values.
However, The quotes in HTML, and demands quotes for stricter document types like XHTML.
Sometimes you have to use quotes. This example will not display the title attribute correctly,
because it contains a space:
Double quotes around attribute values are the most common in HTML, but single quotes can also
be used.
In some situations, when the attribute value itself contains double quotes, it is necessary to use
single quotes:
Forms
Forms are used to input the values. These values are sent to the server for processing. Forms uses
input elements such as text fields, check boxes, radio buttons, lists, submit buttons etc. to enter
the data into it.
The following table describes the commonly used tags while creating a form:
Tag Description
<form> </form> It is used to create HTML form.
<input> </input> Specifies the input field.
<textarea> </textarea> Specifies a text area control that allows to enter multi-line text.
<label> </label> Specifies the label for an input element.