Unit 2
Unit 2
UNIT-II
1. INTRODUCTION TO HTML:
HTML code written in between two angular brackets. Those are called as TAGS.
That’s why it is a tag based language.
Tag is a keyword, There are two types of tags are available in HTML.Those are
opening tags and closed tags.
Opening tags are represented as----< -------------------- >
Closing tags are represented as----- < /------------------ >
Features of HTML:
HTML has several features. The most important features are given below:
HTML is used to create tables .
HTML is used to create LISTS.
HTML is used to create Hyperlinks.
HTML is used to create different form elements.
HTML is use to create Frames in HTML.
It help us to create multiple web pages in a single web page.
It is used to add GRAPHICS and easily add IMAGES in a webpage.
Container tags:
The tags which contains both opening and closing tags.
Ex: <html……............</html>
<head>..................</head>
<body>................. </body>
Non-Container tags:
The tags which contains only opening but not closing tags.
Ex: <hr>------Horizontal ruler tag
<br>------ Break tag
Special entities:
The entities are used for some special purposes only,which are enclosed
with “&”(ampersand) symbol.
EX: <... Less than
>... Greater than
 ..... NON breakable space.
STRUCTURE:
HTML document contains two parts , namely HEAD part and BODY part.
Syntax:
<!—comments-->
<html>
<head>...........</head>
<body>...........</body>
</html>
In above structure ,
<html> tags encloses the complete document structure.<head> tag
represents header.<body> tag represents the document body.
<!—comments-- > are used to describe the programs such a purpose name ,date
and author details of the document are placed. Comments ignored by the web browser.
Head part contains the information like document name, address, logos etc. Head
part contains a tag known as <title> tag.It defines the title of the webpage.Body part contains
the information like running matter, and keeps the other HTML tags like <h1>,<p>,<table>
etc.
Ex:
<!—sample program-->
<html>
<head> Rao’s Degree college</head><br>
<body>Best corporate degree college in Nellore district</body>
</html>
Output:
NOTE:
ATTRIBUTE:
Attribute means, provide additional information for a particular tag. The general form of
attribute is as follows:
Attribute = ”value”
Ex: align=”center”
Color=”red”.
• Heading tag
• Paragraph tag
• Break tag
• Non breakable space
• Title tag
Heading Tags:
Any document starts with a heading. You can use
different sizes for your headings. HTML 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.
All heading tags are container tags.
<h1>....................................</h1> Maximum size
<h2>....................................</h2>
<h3>....................................</h3> Default size
<h4>....................................</h4>
<h5>.....................................</h5>
<h6>.....................................</h6> Minimum size
Paragraph tag:
The <p> tag offers a way to structure your text into different
paragraphs. Each paragraph of text should go in between an opening <p> and a
closing </p> tag .
Break tag:
Whenever you use the <br> element, anything following it starts
from the next line. This tag is an example of an empty element, where you do not
need opening and closing tags, as there is nothing to go in between them.
Title tag:
The title tag is required in all HTML documents. And it defines
Title in browser tool bar. It displays a title for the page in search engine results.
Not use more than one title tag in an HTML document.
It is represented as <title>......</title>.It is a container tag and it
contains a opening and closing tags.
Syntax:
<html>
<head>
<title>..............</title>
</head>
<body>.................</body>
</html>
Ex:
<html>
<head>
<title>HTMLtags</title>
<h1 align=”center”> Rao’sDegreeCollege </h1>
<head>
<body>
<h2 align=”center”>It is old institute in Nellore</h2>
<p align=”center”> Established in 1984</p><br>
<p align=”center”> courses are:</p><br>
        B.Sc<br>
        B.Com<br>
        BCA<br>
        B.Sc Ls<br>
        BBA<br>
<body></html>
Output:
Ex:
<html>
<head>
<h1 align="center"> Font tag</h1>
</head>
<body>
<h2 align="center">
<font face="Calibri" color="red" size="6"> Raos students </font><br>
<font face="Bahnschrift Light" color="blue" size="4">Sixth
semester</font><br>
<font face="Times New Roman" color="magenta" size="6">Fourth
semester</font><br>
<font face="Gautami (Headings CS)" color="green" size="5">
Font tag displays different color, styles and sizes</font>
</h2></body></html>
Output:
Syntax:
<basefont size=“value” color=“color name/hexadecimal coding”
face=“font style”>
Ex: <html>
<head>
<basefont color=“red” size=“1” face=“arial”>
</head>
<body>
<h1>Basefont tag demo</h1>
<h2>Bcom fifth sem</h2>
<h3> web technologies</h3>
</body>
</html>
In HTML we can specify a direct color name or background color to the text. The
general form is: syntax: color=“color name”
To display other than primary colors, use hexadecimal coding. It is a
combination of sixteen digits[0 1 2 3 4 5 6 7 8 9 A B C D E F] . Each hexadecimal can
preceded by #(hash)sign. In HTML hexadecimal coding is represented as “#6digits”.
Syntax:
color=“Hexadecimal coding”
color=“#6digits”
Example: color=“#112233”
color=“#aabbcc”
color=“#ee5577”
In HTML ,we use “bgcolor” attribute, it specifies a background color to the total
document. This attribute is used in body section. Other than font tag. Use a special attribute
called “style”. The style attribute setting the style of an HTML document.The general form
is as follows:
Syntax:
<html element style=”property:value; property:value;.........”>
Ex: <h1 style=”align:center;color:green”>
Ex: <html>
<head>
<h1 align="center">Colors Example</h1></head>
<body bgcolor="yellow">
Output:
Bold tag: This tag is used to make the text in Bold face. It is represented as <b>. It is
a container tag.
<html>
<head>
<h1 align="center"> Satya technologies</h1>
<h2 align="center"> Hyderabad</h2>
</head>
<hr align="center" color="green" size="20%" width="30%">
<body bgcolor="magenta">
<h2 align="center">
<b><u> Courses are:</u></b> Java<br>
               
            Python<br><br>
<i><u> Batches are : </u></i> Merit<br>
               
      Dull<br><br>
Water formula is: H<sub>2</sub>O<br><br>
Math formula is: X<sup>3</sup>+2XY+Y<sup>3</sup><br><br>
Type writer otput is:<tt> Text formatting tags</tt>
</h2>
<body>
</html>
Output:
Ordered list:
An ordered list is a list of elements, which is having a particular
sequence. In Html we can create a ordered list by using a tag known as <ol>. It is a
container tag , along with this tag use a sub item list tag known as <li>( list item tag).
Syntax:
<ol>
<li>------- </li>
<li>--------</li>
<li>---------</li>
</ol>
By default <ol > tag displays digits only. But the user wants other than
digits i.e, alphabets ,roman numbers . We use a special attribute called , “type”.
Syntax:
<ol TYPE=“ A/a/I/i”>
<li> --------------</li>
<li>--------------- </li>
<li>-------------- </li>
</ol>
Unordered list:
An Unordered list is a list of elements, which is having without
any sequence. In Html we can create a unordered list by using a tag known as <ul>.
It is a container tag , along with this tag use a sub item list tag known as <li>( list item
tag).
Syntax:
<ul>
<li>------- </li>
<li>--------</li>
<li>---------</li>
</ul>
By default <ul > tag displays disc symbols only. But the user wants
other than disc symbols i.e, square, circle ,use a special attribute called , “type”.
Syntax:
<ul TYPE=“square/circle”>
<li> --------------</li>
<li>---------------</li>
<li>-------------- </li>
</ol>
Nested List: A list contains another list is known as Nested list. By using this feature
we can present a list and sublist on the web page.
Syntax: <ol>
<li>............</li>
<li>...........</li>
<li>
<ul>
<li>.....</li>
<li>......</li>
..............
...................
</ul>
</li>
....................................
.....................................
</ol>
Ex:
<html>
<head>
<h1 align="center" style="background-color:pink"><font color="red">HTML
Lists</font></h1> </head> <hr>
<body bgcolor="yellow">
<font color="green">
<h1>
<b><u>Inventor:</u></b> Charles Babbage<br>
<i><u>parts:</u></i><ul type="square">
<li>Input Device</li>
<li>CPU
<ol type="A">
<li>ALU</li>
<li>CU</li>
<li>MU</li>
</ol>
</li>
<li>Output Device</li>
</ul> </font></h1></body></html>
Output:
Insert tag: This tag is used to display the text with underline. It is represented
as <ins>. It is a container tag.
<ins>...........</ins>------------underlined
Emphasize tag: This tag is used to display the in italic face. It is represented
as <em>. It is a container tag.
<em>.........</em>------------Italic
Strong tag: This tag is used to make the text in strong face. It s represented as
<strong> . It is a container tag.
<strong>............</strong>------Bold.
Bold tag: This tag is used to make the text in Bold face. It is represented as <b>. It is
a container tag.
Bold tag--à <b>--------------</b>.
Italic tag: This tag is used to make the text in Italic face. It is represented as <i>. It is
a container tag.
Italic tag--à <i>---------------</i>
Underline tag: This tag is used to set underline to the text. It is represented as <u>. it
is a container tag.
Underline tagà <u>-------------</u>
Subscript tag: This tag is used to set the text as subscript.(base/suffix).It is
represented as <sub>. It is a container tag.
Subscript tag-à <sub>----------</sub>
Superscript tag: this tag is used to set the text as superscript.(power/prefix). It is
represented as <sup>. It is a container tag.
Superscript tag-à <sup>----------</sup>
Big tag: This tag is used to make the text in bold face. It is represented as <big>. It is
a container tag.
Big tag <big>...............</big>
Strike tag: This tag is used to display the text with a line through it. It is represented
as <s>. it is a container tag.
Strike tag-><s>.................</s>
Ex:
<html>
<head>
<h1 align="center">character tags</h1>
</head>
<hr>
<body>
Height and width: This attribute defines the height and width of a image in pixels.
The general form is:
<img src=”url” height=”value in pixels” width=”value in pixels”>
Alt: This attribute defines the alternate text to the image. The general form is;
<img src=”url” alt=”alternate text”>
Border: This attribute defines the border of the image. We can specify border
thickness in terms of pixels using this attribute. The general form is:
<img src=”url” border=”value in pixels”>
Float: By using this attribute the image moves from one side to another side I,e., left
to right or right to left. The general form is:
<img src=”url” style=”float:left/right”>
Syntax:
<img src=“url” height=“value in pixels” width=“value in pixels” border=“value in
pixels” style=“float:left/right”>
Example:
<html>
<head> </head>
<body style=“background-image:url(‘flower1.jpg’)”>
<h1 align=“center”>
<font color=”blue”>
Image example
</font>
</h1>
<img src=“flower2.jpg” height=“100” width=“50”
border=“value” style=“float:right”>
</body>
</html>
Output:
® HTML<br>
¥ HTML<br>
¢ HTML<br>
& HTML
</h1>
</body>
</html>
Output:
syntax:
<hr color=“ color name” align=“left/center/right” size=“value in percentage”
width=“ value in percentage”>
Example:
<html>
<head>
<h1 align="center">Rao's degree college</h1></head>
<hr color="red" size="30%" width="30%" align="center">
<body>
<h1 align="right"> web technology</h1>
<hr color="#cc66ff" size="30%" width="30%" align="right">
<h1 align="right"> Horizontal ruler tag</h1>
<hr color="#dd77bb" size="30%" width="30%" align="left">
<h1 align="left">It contains number of attributes </h1>
</body></html>
Output:
Syntax:
<a href=“url”>
....................
....................
</a>
In above syntax the attribute “href” means “HYPERREFERENCE”. It
specifies the address of the webpage. The value ‘url’ means Uniform Resource
Locator.
Types of hyperlinks:
<html>
<head>
<h1 align="center">Internal Hyperlinks</h1>
</head>
<hr align="center" size="20%" width="30%" color="green">
<body>
<h3 align="center">
<a href="#courses">Courses</a><br>
<a href="#batches">Batches</a><br>
<br><br>
<a name="courses"></a>
<b><u> courses offered</u></b>
<ol type="A">
<li>cloud computing</li>
<li>python</li>
</ol>
<br><br>
<a name="batches"></a>
<i><u> batches are</u></i>
<ul type="square">
<li>batchA</li>
<li>batchB</li>
</ul>
</h3>
</body>
</html>
Output:
Save as Externallink.html
<html>
<head>
<h1 align="center">External Hyperlinks</h1>
</head>
<hr align="center" size="20%" width="30%" color="red">
<body bgcolor="yellow">
<h1 align="center">
<a href="course.html">courses</a><br>
<a href="batch.html">batches</a><br>
</h1>
</body>
</html>
Save as course.html
<html>
<head>
<h1 align="center">External Hyperlinks</h1>
</head>
<hr align="center" size="20%" width="30%" color="red">
<body bgcolor="pink">
<h1 align="center">
<b><u> Courses Offered</u></b><br>
<ol type="A">
<li>Java</li>
<li>Python</li>
<li> Dot net</li>
<li>Ajax</li>
<li>RMI</li>
</ol>
</h1>
</body>
</html>
Save as batch.html
<html>
<head>
<h1 align="center">External Hyperlinks</h1>
</head>
<hr align="center" size="20%" width="30%" color="red">
<body bgcolor="violet">
<h1 align="center">
<i><u> Batches are</u></i><br>
<ul type="circle">
<li>BatchA</li>
<li>BatchB</li>
<li>BatchC</li>
<li>BatchD</li>
<li>BatchE</li>
</ul>
</h1>
</body>
</html>
Output:
-----XXXXX……..ﯤ. ﯤ. ﯤ. ﯤ. ﯤ. ﯤ. ﯤ. -------------------ﯤ. ﯤ. ﯤ. ……ﯤXXX……