Unit - 2
Unit - 2
Unit - 2
INTRODUCTION TO HTML: H I S T O RY TO
HTML, HTML G E N E R AT I O N S , HTML
D O C U M E N T S , A N C H O R TA G , H Y P E R L I N K S ,
HEADING, TITLE. LINKS, COLORFUL WEB
PA G E S , C O M M E N T L I N E S . D E S I G N I N G T H E
BODY SECTION: HEADING PRINTING,
ALIGNING THE HEADING, H O R I Z O N TA L
RULE, PA R A G R A P H , IMAGES &
PICTURES.
Introduction to HTML
HTML is a language for describing web pages.
HTML 1.0 was released in 1993 with the intention of sharing information that can be readable
and accessible via web browsers. But not many of the developers were involved in creating
websites. So the language was also not growing.
Then comes HTML 2.0, published in 1995, which contains all the features of HTML 1.0 along
with a few additional features, which remained the standard markup language for designing and
creating websites until January 1997 and refined various core features of HTML.
History to HTML/ HTML generations
Then comes HTML 3.0, where Dave Raggett introduced a fresh paper or draft on HTML. It
included improved new features of HTML, giving more powerful characteristics for webmasters
in designing web pages. But these powerful features of the new HTML slowed down the browser
in applying further improvements.
Then comes HTML 4.01, which is widely used and was a successful version of HTML before
HTML 5.0, which is currently released and used worldwide. HTML 5 can be said for an extended
version of HTML 4.01, which was published in the year 2012.
HTML documents
An HTML document is a file containing hypertext markup language. HTML code is based
on tags, or hidden keywords, which provide instructions for formatting the document.
A tag starts with an angle bracket and the 'less than' sign: '<'. The tag ends with an angle bracket
and the 'greater than' sign '>'. Tags tell the processing program, often the web browser, what to
do with the text.
For example, to make the word 'Hello' bold, you would use the opening bold tag <b> and then
the closing bold tag </b>, like this:
<b>Hello</b>
Structure of an HTML Document
An HTML Document is mainly divided into two parts:
HEAD: This contains the information about the HTML document. For
Example, the Title of the page, version of HTML, Meta Data, etc.
BODY: This contains everything you want to display on the Web Page.
It’s a biggest and main element in complete html language, all the tags ,
elements and attributes enclosed in it or we can say wrap in it , which is
used to structure a web page. <html> tag is parent tag of <head> and
<body> tag , other tags enclosed within <head > and <body>.
Anchor tag/ Hyperlinks
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.
By default, links will appear as follows in all browsers:
•An unvisited link is underlined and blue
•A visited link is underlined and purple
•An active link is underlined and red
Syntax:
<a href = "link"> Link Name </a>
Example:
<html>
<body>
<h2>Welcome to MCC</h2>
<a href="https://www.mcc.edu.in/">Madras Christian College </a>
<h2>This is anchor Tag</h2>
</body>
</html>
Heading
HTML headings are defined with the <h1> to <h6> tags.
<h1> defines the most important heading. <h6> defines the least important heading
<h1>Heading 1</h1>
<h2>Heading 2</h2>
<h3>Heading 3</h3>
<h4>Heading 4</h4>
<h5>Heading 5</h5>
<h6>Heading 6</h6>
HTML Title
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. The <title> tag is required in HTML documents!
The contents of a page title is very important for search engine
optimization (SEO)! The page title is used by search engine
algorithms to decide the order when listing pages in search results.
The <title> element:
•defines a title in the browser toolbar
•provides a title for the page when it is added to favorites
•displays a title for the page in search-engine results
Example
<html>
<head>
<title>HTML Elements Reference</title>
</head>
<body>
<h1>This is a heading</h1>
<p>This is a paragraph.</p>
</body>
</html>
HTML Links
HTML links are hyperlinks.
We can click on a link and jump to another document. When we move the
mouse over a link, the mouse arrow will turn into a little hand.
The HTML <a> tag defines a hyperlink. It has the following syntax:
<a href="url">link text</a>
Example
<a href="default.html">
<img src="smiley.gif" alt="HTML tutorial" style="width:42px;height:42px;">
</a>
Link to an Email Address
Example
<a href="mailto:[email protected]">Send email</a>
Link Titles
The title attribute specifies extra information about an element. The information is most often
shown as a tooltip text when the mouse moves over the element.
Example
<a href="https://www.mcc.edu.in/" title="Go to MCC">Visit our College</a>
Button as a Link
To use an HTML button as a link, you have to add some JavaScript code.
JavaScript allows you to specify what happens at certain events, such as a click of
a button:
Example
Example:
Example
The <body> tag has following attributes which can be used to set different colors − <html>
<body bgcolor="blue">
• bgcolor − sets a color for the background of the page.
<h1>I am a Heading</h1>
• text − sets a color for the body text. </body>
</html>
• alink − sets a color for active links or selected links.
• vlink − sets a color for visited links − that is, for linked text that you have already
clicked on.
Comments
In HTML, a comment is a section of text that is not processed by the web browser. Comments
are enclosed in <!-- --> tags. These tags tell the browser that the text inside them is a comment
and should not be rendered on the front end.
HTML comments are not displayed in the browser, but they can help document your HTML
source code.
Comments are also great for debugging HTML, because you can comment out HTML lines of
code, one at a time, to search for errors.
syntax:
<!--
buttons orange,
-->
<button>Click me</button>
Designing the body section
HTML <body> tag
HTML <body> tag defines the main content of an HTML document which displays on the
browser. It can contain text content, paragraphs, headings, images, tables, links, videos, etc.
The <body> must be the second element after the <head> tag or it should be placed between
</head> and </html> tags. This tag is required for every HTML document and should only use
once in the whole HTML document.
Supporting Browsers
<head>
<title>Body Tag</title>
</head>
<body>
</body>
</html>
Attribute Value Description
alink color It defines the color of the active link in a document. (Not supported in HTML5)
background URL It determines the background image for the document. (Not supported in
HTML5)
bgcolor color It determines the background color of the content. (Not supported in HTML5)
link color It determines the color of the unvisited link. (Not supported in HTML5)
text color It determines the color of the text in the document. (Not supported in HTML5)
vlink color It determines the color of the visited link. (Not supported in HTML5)
Heading Printing
An HTML heading tag is used to define the headings of a page. There are six levels of headings
defined by HTML. These 6 heading elements are h1, h2, h3, h4, h5, and h6; with h1 being the
highest level and h6 being the least.
•<h1> is used for the main heading. (Biggest in size)
•<h2> is used for subheadings, if there are further sections under the subheadings then
the <h3> elements are used.
•<h6> for the small heading (smallest one).
Example
<h1>Heading no. 1</h1>
Syntax
Following is the syntax for the heading alignment in HTML.
<h1 align="left | right | center | justify">
Example
<html>
<body>
<h1 align="center">Aligning my Heading</h1>
</body>
</html>
Horizontal Rule
The <hr> tag in HTML stands for horizontal rule and is used to insert a horizontal rule or a
thematic break in an HTML page to divide or separate document sections. The <hr> tag is an
empty tag, and it does not require an end tag.
Tag Attributes: The table given below describe the <hr> tag attributes. These attributes are not supported in HTML5:
<html>
<head>
<title>Using Image in Webpage</title>
</head>
<body>
<p>Simple Image Insert</p>
<img src = "/html/images/test.png" alt = "Test Image" width=“150” height = “150”
border = “3” align = “right”/>
</body>
</html>