HTML Notes
HTML Notes
INTRODUCTION
We access web sites regularly to download information. We also observe that the
content on the website is presented in different layouts, colors, fonts, size and web
pages are created by writing simple text in HTML or Hyper Text Markup
Language.HTML is one of the several Markup languages such as RTF, PHP,
PEARL, ASP, JAVASCRIPT, ACTIONSCRIPT. Used for designing websites on
the WWW.
3 Technologies used by World Wide Web are :
1) HTML (Hyper Text Markup Language) used to write Web pages.
2) HTTP (Hyper Text Transfer Protocol) to transmit those pages.
3) A web browser client program to receive the data, interpret it and display the
results.
HTTP : Hyper Text Transfer Protocol. Protocol used to transfer web pages.
HTML : Hyper Text Markup Language. The language used to design web pages.
Web Server : It is a computer having server software, which holds Web pages and
‘serves’ them out to computers that request them.
Eg. Microsoft IIS, Apache.
Home Page : The starting, introductory or welcome page for a Web site. It is also
known as index page.
What is HTML ?
HTML stands for Hypertext Markup Language, and it is the most widely used
language to write Web Pages. HTML is a Markup Language. HTML is the
character-based method for describing and expressing the content. The content
may be pictures, text, sound and video clips.
Technically HTML is not a programming language but it has code-words and
syntax like any other language. It consists of tags typed into a text-file by the site
author. The text is then saved as an .html file, and viewed through a browser, like
Internet Explorer or Netscape Navigator. This browser reads the file and translates
the text into a visible form, hopefully rendering the page as the author had
intended. You can use anything from a text-editor such as Notepad to a powerful
graphical editor to create HTML pages.
Features of HTML:
- HTML provides pre defined tags to create the layout of a web page such as
headings, paragraphs, lists, tables, images, etc.
- HTML is a markup language. Markup is what HTML tags do to the text
inside them. The markups are read and interpreted by the browsers which
display the marked elements as per the specifications used for developing
web pages connected through hyperlinks.
- HTML uses HYPERTEXT.
Important Points :
Each HTML document begins with a <HTML> and ends with </HTML> tags.
All HTML files should include at least these basic structure tags :-
a) The HTML Tag
b) The Head Tag
c) The Title Tag
d) The Body Tag
The HTML Tag : This tag is the container for the entire web page. This element
contains other elements, the head and the body elements.
Syntax :<HTML> .......</HTML>
The HEAD Tag : Contains contains metadata information about the web page. It
may also contain other tags that help you to identify your HTML file to the outside
world.
Syntax :<HEAD> .......</HEAD>
The TITLE Tag : This tag is nested within the Head tag. It identifies your page to
the rest of the world. The tag output is displayed on your browser’s title bar but
does not appear as part of the page.
Syntax :<TITLE > .......</TITLE>
The BODY Tag :contains the visual aspects of the web page. This tag is the
compliment of the Head tag and contains all the tags or elements that a browser
actually displays as the body of your HTML document.
Syntax :<BODY> .......</BODY >
Comment Tag :- This tag is used to add comments to various sections of your
script. Browser does not display any text displayed between these tags.
Syntax :<! ....... >
Headings Tag :- Headings help in defining the format and structure of the
document. They provide valuable tool in highlighting important topics & the nature of
the document as a whole. There are six levels of headings in HTML specified by <H1>,
<H2>, <H3>, <H4>, <H5> and <H6> tags.
Syntax :<Hy> ............ </Hy>
where y is size of heading ranging from 1....6.
Paragraph Tag : Paragraph tag can be used to place blocks of text in HTML
document. Syntax :<P > .......</P >
Line break Tag :- <BR> Tag is used to add line breaks in the HTML code. It is
used to add blank lines to a document.
Text alignment :Align attribute can be used with the Headings tag & Paragraph tag
to align the text. Data can be aligned from left, right, center or justify by using any
one of values such as LEFT, RIGHT, CENTER, JUSTIFY.
PHYSICAL TAGS : Defines how the text should be displayed by the browser.
They control the physical characteristics of the text.
<B> ........ </B> Bold I am bold
<I> ........ </I> Italics I am bold
<U> ........ </U> Underline I am bold
<STRIKE> ... </STRIKE>
or <S> ------</S> Strikethrough I am bold
I am bold
<SUP> ........ </SUP> Superscript
<SUB> ........ </SUB> Subscript I am bold
<TT> ........ </TT> Typewriter form Typewriter form
<BIG> ........ </BIG> Bigger font I am Bigger
<SMALL> ........ </SMALL> Smaller font I am smaller
LOGICAL TAGS :Logical tags on the other hand indicate the ‘type’ of content
they enclose.
There are 9 logical tags each requiring a closing tag.
Examples are :-
<STRONG>, <EM>, <ABBR>, <CITE> ,<CODE>, <DFN>, <KBD>, <SAMP>,
<VAR>.
Horizontal Ruled Lines : Horizontal Rules (Lines) are used to separate different
areas of a web page.
<HR> Tag : This tag produces a horizontal line with a width of the browser
window. This is useful for visually separating document sections.
Syntax :<HR>
Attributes of <HR> Tag
a) <HR> empty tag without attribute makes line the full width
of the screen.
b) <HR width = ”n”> For fixed pixel width
c) <HR width = ”n %”> For percentage of screen width
d) <HR size = ”n”> specify thickness of the horizontal line.
e) <HR align = ”value”> Aligns ruler to value, which is left, right or center
f) <HR color =”name”> sets color of a line
g) <HR noshade> turns line’s shading off
TEXT FORMATTING
The FONT Tag :The font tag enables you to set the font size, font color, and font
family of the text placed inside the tag.
Syntax :<FONT> .....</FONT>
2. Preformatted tag <PRE>It contains preformatted plain text. This is useful for
including computer program output or source code without your document.
HTML documents contain certain ‘hot spots’. These hot spots provide anchors that
link to other document files on the Internet.
<A> Tag / Anchor Tag : is used to define both hyperlinks and anchors
Syntax :<a>...</a>
The href Attribute : Defines the link address of a resource on the web
Syntax : <a href="url"> Link text </a>
Link text defines the part to be displayed. It can be text, image
or any other HTML element
Example: <a href="http://www.yahoo.com/"> Visit Yahoo! </a>
<a> element -- defines a link to the website www. yahoo.com
Visit Yahoo -- the link that is displayed in a browser
<IMG> TAG : Used to insert graphics on a web page. The IMG tag has no
closing tag
Syntax :<imgsrc="url" />
URL points to the location where the image is stored. The browser puts the image
where the image tag occurs in the document.
CREATING LISTS
List:- A number of connected items or names which are written or printed one
below the other.
HTML supports 4 types of lists :-
1) Unordered list
2) Ordered list
3) Definition list
4) Nested List
Unordered list: An Unordered list is a list of items which are marked with bullets
(typically black small circles)
<UL> Tag : This tag defines a bulleted list of items. The <LI> (list item) tag is
nested inside the UL tag and defines each item within the list. Inside a list item
you can put a paragraph line break, images, links, other list etc.
Ordered list:
An ordered list is a list of items marked with numbers. An order list starts with
<OL>tag.
<OL>Tag : This tag defines a sequentially numbered list of items. It is used with
the <LI> Tag. Inside a list item, you can put paragraphs, line breaks,
images, links, other lists, etc.
The type attribute is used to change bullet type. It takes one of the five values:
type ="a" -- Lowercase alphabet
type ="A" -- Uppercase Alphabet
type ="i" -- Lowercase Roman Numerals
type ="I" -- Uppercase Roman Numerals
type ="1" -- Regular number (default)
The start attribute sets the starting number of the bullet. Default is 1.
Syntax :<OL type = “ “ > ...... </OL>
Definition list :The definition list is the ideal way to present a glossary, list of
terms (and their definition), in HTML.
<DL> Tag : This tag allows you to create glossaries or list of terms and
definitions. A glossary consists of three tag elements: a tag to define the list (DL),
a tag to define the term (DT) and a tag to define the definitions (DD).
Syntax: <dl>
<dt> ……</dt>
<dd>…..</dd>
</dl>
Nested List : When one type is given inside or embedded inside another type of
list. It is called as Nested list. You can also have a number of paragraphs, each
containing a nested list, in a single list item.
TABLES
Tables are used to make data easier to interpret and to control the layout of a page.
Attributes of <TABLE>Tag :
1) border ==> border = "n" specifies thickness of border in n pixels
Border = "0" means no border for the table & is the default setting
2) border color ==> Specifies the colour of the table border
3) width and height ==>Specifies the width and height respectively of the table
In pixels or as a percent
5) Alignment attributes ==> Content in cells can be aligned using these
attributes
align ==> Used to align a table to either the left, right or center of
page
valign ==> Specifies that the table can be either top or bottom
aligned. The default is center aligned
5) Cellpadding ==> Cellpadding is the buffer space around the contents
of a cell
6) Cellspacing ==> Cellspacing is how far apart each cell is from
another cell
7) colspan ==> sets how many columns a cell spans.
8) rowspan ==> sets how many rows a cell spans.
9) bgcolor ==> assigns background color to an entire table, a row or a
Single cell