HTML
HTML
<html>...</html>
</body>
</html>
Tags
The text between <html> and </html>
describes the web page
The text between <body> and </body> is the
visible page content
The text between <h1> and </h1> is displayed
as a heading
The text between <p> and </p> is displayed as
a paragraph
Creating and Publishing a Web
PAGE
Create an HTML document
Place the document in the world-accessible
directory (often public HTML or WWW) on a
system running an HTTP server.
Access the webpage through
http://hostname/~username/filename
Eg. http://www.apl.jhu.edu/~lmb/test.htm
Validate the document
HTML DOCUMENT
TEMPLATE
MAIN HTML ELEMENTS
DOCTYPE
HTML
HEAD
- TITLE element required
-Optional elements
-BASE
-META
-BGSOUND
-SCRIPT,NOSCRIPT
-STLYE
BODY element
- HTML Attributes and attribute values
-BACKGROUND
-BGCOLOR
-TEXT
-LINK,VLINK,ALINK
Elements inside BODY element
bgcolor: This is the background color of the entire HTML
document, and may be specified either by the color name
directly or by the six-digit hex code.
alink: The color of the links.
vlink: The color of the visited links.
topmargin: The margin from the top of the browser window.
leftmargin: The margin from the left of the browser window.
BLOCK LEVEL ELEMENTS
HEADINGS
Types Of Headings:
<H1>….</H1>
<H2>….</H2>
<H3>….</H3>
<H4>….</H4>
<H5>….</H5>
<H6>….</H6>
Headings are from H1 to H6
Attributes are: LEFT(default), RIGHT,CENTER
P- The BASIC PARAGRAPH
Paragraphs are defined with the <p> tag.
<html>
<body>
<p>This is a paragraph.</p>
<p>This is a paragraph.</p>
<p>This is a paragraph.</p>
</body>
</html>
Formatting Tags
Font(face,size,color)
<font size=2 face="Helvetica" color=red>This
illustrates the attributes of the font tag.</font>
<center>
The <center> tag causes all the text within the tag to be
centered.
<center>This is centered text.</center>
<b>-Bold
<i>-Italic
<u>Underline
<html> This is a paragraph.
<body> This is a paragraph.
<p>This is a This is a paragraph.
paragraph.</p>
<p>This is a
paragraph.</p>
<p>This is a
paragraph.</p>
</body>
</html>
HTML LISTS
The most common HTML An unordered list:
lists are ordered and List item
unordered lists: List item
Ordered list
List item
Unordered list
An ordered list:
1.The first list item
2.The second list item
3.The third list item
HTML Unordered Lists
An unordered list starts with the <ul> tag. Each list item starts with the <li> tag.
The list items are marked with bullets (typically small black circles).
<ul>
<li>Coffee</li>
<li>Milk</li>
</ul>
OUTPUT:
Coffee
Milk
Attributes: type(disc,square,circle)
HTML Ordered Lists
An ordered list starts with the <ol> tag. Each list item starts
with the <li> tag.
The list items are marked with numbers.
<ol>
<li>Coffee</li>
<li>Milk</li>
</ol>
OUTPUT:
1.Coffee
2.Milk
HTML Definition Lists
A definition list is a list of items, with a description of each item.
The <dl> tag defines a definition list.
The <dl> tag is used in conjunction with <dt> (defines the item in the list) and
<dd> (describes the item in the list)
<dl>
<dt>Coffee</dt>
<dd>- black hot drink</dd>
<dt>Milk</dt>
<dd>- white cold drink</dd>
</dl>
Coffee
- black hot drink
Milk
- white cold drink
TEXT LEVEL ELEMENTS
Physical character styles
B,I,TT,U,SUB,SUP,SMALL,BIG,STRIKE,S,BLINK,F
ont
Logical Character styles
EM,STRONG,CODE,SAMP,KBD,DFN,VAR,CITE
Hypertext
A
HREF,NAME,TARGET
Image Tag
IMAGES
IMG
SRC,ALT,ALIGN,WIDTH,HEIGHT,HSPACE,VSPAC
E,BORDER,USEMAP,ISMAP
MISC. TEXT LEVEL ELEMENTS
BR- Explicit line break
PHYSICAL CHARACTER
STLYES EXAMPLE
OUTPUT
LOGICAL CHARACTER
EXample
OUTPUT
HYPERLINK
A hyperlink (or link) is a word, group of words, or image that you can
click on to jump to a new document or a new section within the current
document.
When you move the cursor over a link in a Web page, the arrow will turn
into a little hand.
Links are specified in HTML using the <a> tag.
The <a> tag can be used in two ways:
To create a link to another document, by using the href attribute
To create a bookmark inside a document, by using the name attribute
Types of Links
Internal
External: placing HTML links to another Web site on your Web page
that would be an example of external HTML links
<a href="http://www.sitename.com"><b>Text for HTML links goes
here.</b></a> Anything extra you want to write goes here.
The code for a same page link has two parts; the link and the
hook.
The link is that part that tells the browser where to go when
the user clicks on it.
The hook is what the link looks for and how it knows where
on the page to go.
Hook is
<A NAME="top">Title Of The Page</A>
code for the link looks like:
<A HREF="#top">Back To The Top</A>
Links
IMAGES
In HTML, images are defined with the <img>
tag.
The <img> tag is empty, which means that it
contains attributes only, and has no closing tag.
To display an image on a page, you need to use
the src attribute. Src stands for "source". The
value of the src attribute is the URL of the
image you want to display.
Syntax
<img src="url" alt="some_text"/>
The URL points to the location where the image is stored. An
image named "boat.gif", located in the "images" directory on
"www.w3schools.com" has the URL:
http://www.w3schools.com/images/boat.gif.
The browser displays the image where the <img> tag occurs in
the document. If you put an image tag between two
paragraphs, the browser shows the first paragraph, then the
image, and then the second paragraph.
HTML IMAGES- ALT
ATRRIBUTE
The required alt attribute specifies an alternate
text for an image, if the image cannot be
displayed.
The value of the alt attribute is an author-defined
text:
<img src="boat.gif" alt="Big Boat" />
The alt attribute provides alternative information
for an image if a user for some reason cannot
view it
HTML Images - Set Height and Width
of an Image
The height and width attributes are used to specify the height
and width of an image.
The attribute values are specified in pixels by default:
<img src="pulpit.jpg" alt="Pulpit rock" width="304"
height="228" />
HSPACE
VSPACE
BORDER
The related HSPACE and VSPACE attributes create a horizontal space and a
vertical space, respectively, between the graphic and the surrounding text, with the
value specified in pixels.
Image tag
<IMG SRC = "/gifs/wdj134.gif“
WIDTH = 134 HEIGHT = 28
BORDER = 0 ALT = "Back to the Web
Developer's Journal Main Page"
ALIGN = "right" HSPACE = "6" VSPACE =
"6">
HTML IMAGES-MAP TAG
The <map> tag is used to define a client-side image-
map. An image-map is an image with clickable areas.
The name attribute is required in the map element.
This attribute is associated with the <img>'s usemap
attribute and creates a relationship between the
image and the map.
The map element contains a number of area
elements, that defines the clickable areas in the
image map.
Map tag example
<html>
<body>
<p>Click on the sun or on one of the planets to watch it closer:</p>
</body>
</html>
OUTPUT
Click on the sun or on one of the
planets to watch it closer:
HTML -TABLES
Tables are defined with the <table> tag.
A table is divided into rows (with the <tr> tag), and
each row is divided into data cells (with the <td> tag).
td stands for "table data," and holds the content of a
data cell.
A <td> tag can contain text, links, images, lists,
forms, other tables, etc.
TABLE ATTRIBUTES
TABLE ROW
TABLE CELLS- TH AND TD