1 HTML List Images Links Table (Unit 2)
1 HTML List Images Links Table (Unit 2)
TECHNOLOGY
Contents
HTML Introduction
Tags, Elements,
Web Browsers, HTML History
Page Structure,
Links, List,
Images,
Tables
Definitions
• HTML – HyperText Markup Language – The Language of Web Pages on the WWW.
• HTML is a text formatting language.
• Browser – A software program which is used to show web pages.
• “Normal text” surrounded by bracketed tags tell browsers how to display web pages
3
Tag
s • HTML markup tags are usually called HTML tags
• HTML tags are keywords (tag names)
enclosed in brackets
Usually paired
<TITLE>My Web Page</TITLE>
The first tag in a pair is the start tag, the second tag is the end tag
• Start and end tags are also called opening tags and closing tags
• Not case sensitive
• <TITLE> = <title> = <Title>
4
HTML ELEMENTS
An HTML element is defined by a start tag, some content, and an end tag:
<tagname>Content goes here...</tagname>
The HTML element is everything from the start tag to the end tag:
<h1>My First Heading</h1>
<p>My first paragraph.</p>
• A software application used to access information on the World Wide Web is called a
Web Browser.
• When a user requests some information, the web browser fetches the data from a
web
server and then displays the webpage on the user’s screen.
Examples of Web Browser:
• Google Chrome
• Internet Explorer
• Mosaic
• Firefox,
• Netscape Navigator
• Its purpose is to read HTML documents and display them as web pages.
• The browser does not display the HTML tags, but uses the tags to determine how the
content of the HTML page is to be presented/displayed to the user
HTML History
Since the early days of the World Wide Web, there have been many versions of HTML:
Year Version
1989 Tim Berners-Lee invented www
1991 Tim Berners-Lee invented HTML
1993 Dave Raggett drafted HTML+
1995 HTML Working Group defined HTML 2.0
1997 W3C Recommendation: HTML 3.2
1999 W3C Recommendation: HTML 4.01
2000 W3C Recommendation: XHTML 1.0
2008 WHATWG HTML5 First Public Draft
2012 WHATWG HTML5 Living Standard
2014 W3C Recommendation: HTML5
2016 W3C Candidate Recommendation: HTML 5.1
2017 W3C Recommendation: HTML5.1 2nd Edition
2017 W3C Recommendation: HTML5.2
Choosing Text Editor
- There are many different programs that you can use to create web documents.
- HTML Editors enable users to create documents quickly and
easily; instead of entering all of the HTML codes by hand.
- These programs will generate the HTML Source Code for you.
8
Creating a Basic Starting Document
(HTML PAGE STRUCTURE)
<!DOCTYPE html>
Example Explained
<html> <head>
<title>Page Title</title> • <!DOCTYPE html> defines that this document is an HTML document
</head> • <html> is the root element of an HTML page
<body> • <head> contains meta information about the HTML page
<h1>My First Heading</h1>
• <title> specifies a title for the HTML page (which is shown in the
<p>My first paragraph.</p>
</body> browser's title bar or in the page's tab)
</html> • <body> defines the document's body, and is a container for all the
visible contents, such as headings, paragraphs, images, hyperlinks,
tables, lists, etc.
• <h1> defines a large heading
• <p> defines a paragraph
9
HTML Colors: 16 Basic Colors
10
Background Color
To set the document’s background color, edit the <BODY> element by adding the BGCOLOR attribute:
<BODY BGCOLOR=“#0000FF”></BODY>
TEXT Color TEXT attribute is used to control the color of all the normal text.
The default color for text is black.
Ex: document’s page color is blue and the text would be Yellow.
The BODY element also gives the ability of setting an image as the document’s background.
Example:
<html>
<BODY BACKGROUND="diya.png" BGCOLOR="#FFFFFF"></BODY>
</html>
Headings, <Hx> </Hx>
Inside the BODY element, heading elements are defined with <H1> through <H6> generally
used for major divisions of the document.
<h1> defines the most important heading. <h6> defines the least important heading:
<HTML>
<HEAD>
Example <TITLE> Example Page</TITLE>
</HEAD> O/P:
<BODY>
Heading 1
<H1> Heading 1 </H1> Heading 2
<H2> Heading 2 </H2>
<H3> Heading 3 </H3> Heading 3
<H4> Heading 4 </H4>
Heading 4
<H5> Heading 5 </H5>
<H6> Heading 6 </H6> Heading 5
</BODY> Heading 6
13
Paragraphs, <P> </P>
• Paragraphs allow to add text to a document in such a way that it will automatically
adjust the end of line to suite the window size of the browser in which it is being
displayed.
• Each line of text will stretch the entire length of the window.
<HTML><HEAD>
<TITLE> Example Page</TITLE> Heading 1
</HEAD>
Example: Paragraph 1,….
<BODY><H1> Heading 1 </H1>
Heading 2
<P> Paragraph 1, ….</P>
Paragraph 2,….
<H2> Heading 2 </H2>
<P> Paragraph 2, ….</P> Heading 3
<H3> Heading 3 </H3> Paragraph 3,….
<HTML>
Example: <HEAD>
<TITLE> Example Page</TITLE>
Heading 1
</HEAD> Paragraph 1,….
<BODY><H1> Heading 1 </H1> Line 2
<P>Paragraph 1, <BR> Line 3
Line 2 <BR> Line 3 <BR>…. ….
</P>
15
Horizontal Rule, <HR>
The <HR> element causes the browser to display a horizontal line (rule) in a document.
<HR> does not use a closing tag, </HR>.
EX: Attribute Description
<P>Paragraph 1, <BR>
Height of the rule in pixels(Default value 2 pixels)
Line 2 <BR> <HR> SIZE
The text inside a <pre> element is displayed in a fixed-width font (usually Courier), and it
preserves both spaces and line breaks:
<pre>
Example: My book is on the table.
Bring it to me.
</pre>
Styles
This attribute is used to add styles to an element, such as color, font, size, and more.
1) Text Color: The CSS color property defines the text color for an HTML element:
Example
<h1 style="color:blue;">This is a heading</h1>
<p style="color:red;">This is a paragraph.</p>
Example
<h1 style="font-family: verdana;">Welcome to all</h1>
<p style="font-family: courier;">This is WT.</p>
3) Text Size
Example
<h1 style="font-size:300%;">This is a heading</h1>
<p style="font-size:160%;">This is a paragraph.</p>
4) Text Alignment: The CSS text-align property defines the horizontal text
alignment for an HTML element:
Example
<h1 style="text-align:center;">MERE KRISHNA</h1>
<p style="text-align:center;">MERE KRISHNA</p>
<b> - Bold text <b>This text is bold</b>
Text Formatting Example
<strong> - text with strong importance : is important!</strong>
<strong>This text
It is to enhance our
page with Bold, Italics,
<i> - Italic text <i>This text is italic</i>
and other character
formatting options.
<em> - Emphasized text, displayed in italic <em>This text is emphasized</em>
20
Alignment
Some elements have attributes for alignment (ALIGN) e.g. Headings, Paragraphs and
Horizontal Rules.
HTML Comments
HTML comments are not displayed in the browser. They help to document our
HTML
source code.
syntax: <!-- Write your comments here -->
21
HTML Links - Hyperlinks
• A link is specified using HTML tag <a> and </a>.
• The <A> tells where the link should start and the </A> indicates where the link ends.
• Everything between these two will work as a link.
• It allows to click on a link and jump to another document.
• Mouse arrow will turn into a little hand when a mouse is moved over a link.
• A link does not have to be text. A link can be an image or any other HTML element!
Links – Syntax
The HTML <a> tag defines a hyperlink. It has the following syntax:
<a href="url">link text</a>
• href attribute: indicates the link's
destination.
• The link text is the part that will be visible to the reader.
• Clicking on the link text, will jump to the specified URL address.
Example: To create a link to WWW. KIET.EDU :
<a href="https://www.kiet.edu/">Visit KIET</a>
22
HTML Links - The target Attribute
• By default, the linked page will be displayed in the current browser window.
• To change this, we must specify another target for the link.
• The target attribute specifies where to open the linked document.
• _self (Defaul)t : Opens the document in the same window/tab as it was clicked
• _blank: Opens the document in a new window or tab
• _parent: Opens the document in the parent frame
• _top: Opens the document in the full body of the window
Example: Use target="_blank“ to open the document in a new browser window or tab:
Example:
<HTML>
<body>
<a href="d:\main.txt">
<img src="d:\diya.png" alt="HOMEWORK" style="width:42px;height:42px;">
</a>
</BODY>
</HTML>
Internal Links - Create
Bookmarks
• HTML links can be used to create bookmarks, so that readers can jump to specific parts of a web page.
• It is created inside large documents to simplify navigation. Its goal is to get the information quickly.
• Bookmarks can be useful if a web page is very long.
• To create a bookmark - first create the bookmark, then add a link to it.
• When the link is clicked, the page will scroll down or up to the location with the bookmark.
Use the id attribute (id="value") to define bookmarks in a page
Use the href attribute (href=" value") to link to the bookmark
page:
<h2 id=“HL1">HTML-LINK </h2>
<a href=" HL1">Jump to HTML LINK</a>
<A NAME="aa">TOP</A>
HTML Links Colors <style>
a:link
An HTML link is displayed in a different color depending {
on whether it has been visited, is unvisited, or is active. color:
green
By default, a link will appear as follows in all browsers: ;
background-color: transparent;
text-decoration: none;
• An unvisited link is underlined and blue
}
• A visited link is underlined and purple a:visited {
• An active link is underlined and red color: pink;
background-color: transparent;
We can change the link state colors, by using CSS: text-decoration: none;
}
a:hover
{ color:
red;
background-color: transparent;
text-decoration: underline;
}
a:active {
color: yellow;
background-color: transparent;
LISTS
• HTML lists allow us to group a set of related items in lists.
• HTML supplies several list elements. Most list elements are composed of one or more
<LI> (List Item) elements.
Types of List:
1. Unordered list.
2. Ordered list.
3. Definition list.
4. Nested Lists.
27
(1) UL Elements
• An unordered list starts with the <ul> tag. Each list item starts with the <li> tag.
• The list items will be marked with bullets (small black circles) by default:
• We have the choice of 4 bullet types: disc(default), circle, square and none.
• These are controlled in Netscape Navigator by the “TYPE” attribute for the <UL> element.
Setting the TYPE Attribute to one of five numbering styles: Ex: O/P:
TYPE Numbering Styles
<OL TYPE =“i”>
i. List item …
1 Arabic numbers 1,2,3, …… <LI> List item …</LI> ii. List item …
<LI> List item …</LI>
a Lower alpha a, b, c, …… Text ….
</OL>
<P> text ….</P> iii. List item …
A Upper alpha A, B, C, ……
<OL TYPE=“i” START=“3”>
i Lower roman i, ii, iii, ……
<LI> List item …</LI>
I Upper roman I, II, III, …… </OL>
29
3) DL: Definition List
<DL>
HTML
O/P: Hyper Text Markup Language
TEA
A hot beverage! 30
4) Nesting Lists
We can nest lists by inserting a UL, OL, etc., inside a list item (LI).
O/P:
EX: <UL TYPE = “square”>
<LI> List item …</LI>
<LI> List item …
<OL TYPE=“i” START=“3”>
<LI> List item …</LI>
<LI> List item …</LI>
<LI> List item …</LI>
<LI> List item …</LI>
<LI> List item …</LI>
</OL>
</LI>
<LI> List item …</LI>
</UL> 31
Images
Images enhance visual appearance of the web pages by making them more interesting
and colorful.
<IMG> used to insert images in the HTML documents. It is an empty element and
contains attributes only.
<!DOCTYPE html>
<html>
<body>
Example: <img src=“krishna.jpg" alt=“Kanha">
</body>
</html>
• src stands for source: It tells the browser where to find the image
• Alt stands for "alternate text“: It tells the browser that if it can't
find the image, then just display this text. 32
Other attributes of Image
Ex.:
1) <IMG SRC=“flower.gif“ border=4>
2) <IMG SRC=" flower.gif" width="60" height="60">
3) <IMG SRC=“flower.gif" ALT="This is a text that goes with the image">
4) <IMG SRC=" flower.gif “ Hspace="30" Vspace="10" border=20>
5) < IMG SRC =" flower.gif“ align="left"> 33
TABLE
S tables allow us to arrange data into rows and columns.
HTML
The <table> tag defines an HTML table.
The table row elements usually contain table header elements or table data elements.
34
Example: Tables
Table Caption
It allows us to specify a line of text that will appear centered above or bellow the table.
<TABLE BORDER=1 CELLPADDING=2>
<CAPTION ALIGN=“BOTTOM”> My Table </CAPTION>
The Caption element has one attribute ALIGN that can be either TOP (Above the table) or BOTTOM
(below the table).
36
Table Header(TH)
Table Data cells are represented by the TD element.
Cells can also be TH (Table Header) elements where its content appear centered and bold.
Colspan: Specifies how many cell columns of the table this cell should span.
Rowspan: Specifies how many cell rows of the table this cell should span.
<html> <body>
<Table border=1 cellpadding =2>
<tr> <th> Roll No</th> <th>Name</th> </tr>
<tr> <td colspan=2> Row 1 Col 1</td> </tr>
<tr> <td rowspan=2>Row 2 Col 1</td>
<td> Row 2 Col2</td> </tr>
<tr> <td> Row 3 Col2</td> </tr>
</table></html>
38
Thank You