Introduction To HTML
Introduction To HTML
2
DOCTYPE
Informs the browser the HTML version number of your document.
It is the first declaration in the HTML5 document before any other HTML
code is written.
Allows a browser to be more precise in the way it interprets and
renders your pages.
<!DOCTYPE html>
It is the new syntax of HTML5 as well as for all future versions of HTML.
This DOCTYPE is compatible with the older browsers also.
3
HTML Encoding (Character Sets)
<meta charset="UTF-8">
Numb ASCII ANSI 8859 UTF-8 Description
32 space
33 ! ! ! ! exclamation mark
35 # # # # number sign
36 $ $ $ $ dollar sign
37 % % % % percent sign
BASIC STRUCTURE OF HTML DOCUMENT
head Contains
information which
is not directly
displayed in the
browser, but
browsers may use it
in other ways.
paragraph
unordered list
HTML
The HTML element is the root element that marks the beginning of an HTML
document.
It contains the start and end tag in the form of <HTML> and </HTML>
respectively.
It is the largest container element as it contains various other elements.
HEAD
15
• Define keywords for search engines:
The <link> tag is used to define the association between a document and an
external resource.
It is used to link stylesheets. Its type attribute is used to specify the type of
link such as ‘text/css’ which points out to a stylesheet.
17
DESCRIPTION OF BASIC TAGS
SCRIPT
With HTML5, JavaScript is now the standard and default scripting language.
The type attribute tag can be removed from the script tags.
The new script tag is as follows:
<script src=”first.js”></script>
The following example shows the use of the script tag.
<!DOCTYPE html>
<html>
<head>
<meta charset=”UTF-8”>
<title>HTML Webinar</title>
<link rel=”stylesheet” href=”first.css”>
<script src=”first.js”></script>
</head>
</html>
18
DESCRIPTION OF BASIC TAGS
BODY
The BODY element enables you to add content on the Web page specified
under the <BODY> and </BODY> tags.
Content can include text, hyperlinks, and images. You can display the content
using various formatting options such as alignment, color, and background.
Following figure shows the basic HTML elements.
19
CONTAINER AND STANDALONE TAGS
There are two types of HTML elements namely, container and standalone
elements.
A container element includes the start tag, contents, sub-elements, and end
tag.
A standalone element consists of the start tag and attributes followed by the
end tag as /> without any content.
20
INTRODUCTION
Text must be attractive, easy to read, and should be short and crisp.
Background color and image of the Web page can be specified using HTML.
21
HEADINGS 1-2
Heading elements define headings for contents such as text and images.
H1 is the top level heading and is displayed with largest font size
H6 is the lowest-level heading and is displayed with smallest font size
22
HEADINGS 2-2
The Code Snippet demonstrates how to specify the six levels of heading in an
HTML page.
<!DOCTYPE html>
<html>
<head>
<title>Headings</title>
</head>
<body>
<h1>H1 Heading</h1>
<h2>H2 Heading</h2>
<h3>H3 Heading</h3>
<h4>H4 Heading</h4>
<h5>H5 Heading</h5>
<h6>H6 Heading</h6>
</body>
</html>
23
TEXT FORMATTING 1-5
Formatting is
applied using
formatting elements
which are container
elements
Content format
Formatted content
determines the
appearance of the
Formatting makes an HTML page
more readable and
content in the
presentable
browser
24
IMPORTANT TAGS
Tag Description
<html> Defines an HTML document
<body> Defines the document's body
<h1> to <h6> Defines HTML headings
<hr /> Defines a horizontal line
<!--> Defines a comment
<p> Defines a paragraph
<br /> Inserts a single line break
HTML TEXT FORMATTING TAGS
Tag Description
<b> Defines bold text
<big> Defines big text
<i> Defines italic text
<small> Defines small text
<strong> Defines strong text
<sub> Defines subscripted text
<sup> Defines superscripted text
<ins> Defines inserted text
<del> Defines deleted text
TEXT FORMATTING 2-5
Commonly used formatting elements are as follows:
B element displays text in bold and is enclosed between <b> and </b> tags.
I element displays text in italics and is enclosed between <i> and </i> tags.
SMALL element makes the text appear smaller in browser and is enclosed
between <small> and </small> tags.
U element underlines a text and is enclosed between <u> and </u> tags.
27
TEXT FORMATTING 4-5
Some more formatting elements are as follows:
DEL element encloses deleted text and is placed between <del> and </del>
tags.
INS element encloses inserted text and is placed between <ins> and </ins>
tags.
STRONG element emphasizes the text and is placed between <strong> and
</strong> tags.
SUB element displays a text as subscript and is enclosed between <sub> and
</sub> tags.
28
TEXT FORMATTING 5-5
The Code Snippet demonstrates the use of other formatting elements.
<!DOCTYPE html>
<html>
<head>
<title>Updating and Shifting Text</title>
</head>
<body>
<h3>Updating, Emphasizing, and Shifting Text</h3>
This is an example of <del>deleted</del> <ins>inserted
</ins> text.<br/>
The is an example of <strong>Strong</strong> text.<br/>
The is an example of <sub>subscript</sub>text.<br/>
The is an example of <sup>superscript</sup> text.<br/>
</body>
</html>
29
CONTROLLING
FONT SIZE &
COLOR
CHANGING FONT SIZE, COLOR AND FAMILY
To change font size, color and family, you can use
style attribute.
<p style="color:white; font-family:arial;
background-color:olive">
<h1 style="text-align:center">
Styling of text using style attribute
</h1>
CHANGING THE COLOR OF TEXT
• TEXT attribute of the <BODY> tag is used to set the
foreground, or text color of the page.
<BODY TEXT=“color”>
Color name: Specifies the text-color with a <BODY
color name
TEXT=“blue”>
Hex number: Specifies the text-color with a hex <BODY
code
TEXT=“#FF0000”>
<BODY BACKGROUND=“value”>
<body background="drkrainbow.gif"
bgproperties="fixed">
BACKGROUND COLOR
Background properties specify the background color and image for the Web
pages.
TEXT attribute of the <BODY> tag is used to set the foreground, or text color
of the page. .
<body bgcolor=”color_name|hex_number|rgb_number”>
where,
color_name - Specifies the background color with a color name (such as “red”)
hex_number - Specifies the background color with a hex code (such as “#ff0000”)
rgb_number - Specifies the background color with an rgb code (such as
“rgb(255,0,0)”)
35
HTML COMMENTS