EndTerm LearningTopic1-HTML Basic
EndTerm LearningTopic1-HTML Basic
HTML Fundamentals
References:
https://www.tutorialspoint.com/html/index.htm
https://www.w3schools.com/html/default.asp
Class Requirements:
Hardware:
Computer (Laptop or PC) Or Smart Phones
/ Tablet
Software:
Notepad, Sublime, Notepad++, atom, or
other HTML Editor (for PC)
For Smartphones or Tablets- search for
HTML Editor or choose anWriter Free, HTML Editor
by Codeplay
What is HTML?
HTML stands for Hypertext Markup Language
Hypertext refers to the way in which Web
pages (HTML documents) are linked together.
Thus, the link available on a webpage is called
Hypertext. As its name suggests, HTML is a
Markup Language which means you use HTML
to simply "mark-up" a text document with tags
that tell a Web browser how to structure it to
display.
HTML Tags
As told earlier, HTML is a markup language
and makes use of various tags to format the
content. HTML tags are keywords (tag names).
These tags are enclosed within angle
braces <Tag Name>. Except few tags, most of
the tags have their corresponding closing tags.
For example, <html> has its closing
tag</html> and <body> tag has its closing tag
</body> tag etc.
Basic HTML Document
In its simplest form, following is an example
of an HTML document:
<!DOCTYPE html>
<html>
<head>
<title>This is document title</title>
</head>
<body>
<h1>This is a heading</h1>
<p>Document content goes here.....</p>
</body>
</html>
Previous example of HTML document uses the following tags:
Tag Description
<!DOCTYPE...> This tag defines the document type and HTML
version.
<html> This tag encloses the complete HTML document
and mainly comprises of document header which is
represented by <head>...</head> and document
body which is represented by <body>...</body>
tags.
<head> This tag represents the document's header which
can keep other HTML tags like <title>, <link> etc.
<!DOCTYPE html>
<html>
<head>
<title>Nested Elements Example</title>
</head>
<body>
<h1>This is <i>italic</i> heading</h1>
<p>This is <u>underlined</u> paragraph</p>
</body>
</html>
HTML – ATTRIBUTES
ATTRIBUTES
An attribute is used to define the characteristics of
an HTML element and is placed inside the element's
opening tag.
All attributes are made up of two parts: a name and a
value:
The name is the property you want to set. For example,
the paragraph <p> element in the example carries an
attribute whose name is align, which you can use to
indicate the alignment of paragraph on the page.
The value is what you want the value of the property to
be set and always put within quotations. The below
example shows three possible values of align attribute:
left, center and right.
Attribute names and attribute values are case-
insensitive. However, the World Wide Web Consortium
(W3C) recommends lowercase attributes/attribute
values in their HTML 4 recommendation.
Example
<!DOCTYPE html>
<html>
<head>
<title>Align Attribute Example</title>
</head>
<body>
<p align="left">This is left aligned</p>
<p align="center">This is center aligned</p>
<p align="right">This is right aligned</p>
</body>
</html>
Core Attributes
The four core attributes that can be used on the
majority of HTML elements (although not all) are:
❖ Id , Title , Class , Style
The Id Attribute
The id attribute of an HTML tag can be used to uniquely
identify any element within an HTML page. There are two
primary reasons that you might want to use an id
attribute on an element:
1. If an element carries an id attribute as a unique
identifier, it is possible to identify just that element and its
content. 2. If you have two elements of the same name
within a Web page (or style sheet), you can use the id
attribute to distinguish between elements that have the
same name.
Example
• <p id="html">This para explains what is HTML</p>
• <p id="css">This para explains what is Cascading Style Sheet</p>
Core Attributes
The title Attribute
The title attribute gives a suggested title for the
element. They syntax for the title attribute is similar
as explained for id attribute:
-often displayed as a tooltip when cursor comes
over the element or while the element is loading.
Example
<!DOCTYPE html>
<html>
<head>
<title>The title Attribute Example</title>
</head>
<body>
<h3 title="Hello HTML!">Titled Heading Tag Example</h3>
</body>
</html>
Core Attributes
The class attribute is used to associate an element with a
style sheet, and specifies the class of element. You will learn
more about the use of the class attribute when you will learn
Cascading Style Sheet (CSS). The value of the attribute may
also be a space-separated list of class names. For example:
class="className1 className2 className3"
The style attribute allows you to specify Cascading Style
Sheet (CSS) rules within the element.
<!DOCTYPE html>
<html>
<head>
<title>The style Attribute</title>
</head>
<body>
<p style="font-family:arial; color:#FF0000;">Some text...</p>
</body>
</html>
This will produce the following result:
Some text...
Internationalization Attributes
There are three internationalization attributes, which are
available for most (although not all) XHTML elements.
dir, lang, xml:lang
Example
<!DOCTYPE html>
<html>
<head>
<title>Superscript Text Example</title>
</head>
<body>
<p>The following word uses a <sup>superscript</sup>
typeface.</p>
</body>
</html>
This will produce the following result:
The following word uses a superscript typeface.
HTML – FORMATTING
Subscript Text
The content of a <sub>...</sub> element is written in
subscript; the font size used is the same as the characters
surrounding it, but is displayed half a character's height
beneath the other characters.
Example
<!DOCTYPE html>
<html>
<head>
<title>Subscript Text Example</title>
</head>
<body>
<p>The following word uses a <sub>subscript</sub>
typeface.</p>
</body>
</html>
This will produce the following result:
The following word uses a subscript typeface.
HTML – FORMATTING
Inserted Text
Anything that appears within <ins>...</ins> element is
displayed as inserted text.
Example
<!DOCTYPE html>
<html>
<head>
<title>Inserted Text Example</title>
</head>
<body>
<p>I want to drink <del>cola</del> <ins>wine</ins></p>
</body>
</html>
HTML – FORMATTING
Deleted Text
Anything that appears within <del>...</del> element, is
displayed as deleted text.
Example
<!DOCTYPE html>
<html>
<head>
<title>Deleted Text Example</title>
</head>
<body>
<p>I want to drink <del>cola</del> <ins>wine</ins></p>
</body>
</html>
HTML – FORMATTING
Larger Text
The content of the <big>...</big> element is displayed
one font size larger than the rest of the text surrounding it
as shown below:
Example
<!DOCTYPE html>
<html>
<head>
<title>Larger Text Example</title>
</head>
<body>
<p>The following word uses a <big>big</big>
typeface.</p>
</body>
</html>
HTML – FORMATTING
Smaller Text
The content of the <small>...</small> element is displayed
one font size smaller than the rest of the text surrounding it
as shown below:
Example
<!DOCTYPE html>
<html>
<head>
<title>Smaller Text Example</title>
</head>
<body>
<p>The following word uses a <small>small</small>
typeface.</p>
</body>
</html>
HTML – FORMATTING
Grouping Content
The <div> and <span> elements allow
you to group together several elements
to create sections or subsections of a
page.
For example, you might want to put all of
the footnotes on a page within a <div>
element to indicate that all of the
elements within that <div> element relate
to the footnotes.
You might then attach a style to this
<div> element so that they appear using
a special set of style rules.
HTML – FORMATTING
Example
<!DOCTYPE html>
<html>
<head>
<title>Div Tag Example</title>
</head>
<body>
<div id="menu" align="middle" >
<a href="/index.htm">HOME</a> |
<a href="/about/contact_us.htm">CONTACT</a> |
<a href="/about/index.htm">ABOUT</a>
</div>
<div id="content" align="left" bgcolor="white">
<h5>Content Articles</h5>
<p>Actual content goes here.....</p>
</div>
</body>
</html>