Professional Documents
Culture Documents
HTML and DHTML
HTML and DHTML
• Example
<a href="http://www.w3schools.com/"
target="_blank">Visit W3Schools!</a>
• Following are possible options:
Option Description
_blank Opens the linked document
in a new window or tab.
_self Opens the linked document
in the same frame.
_parent Opens the linked document
in the parent frame.
_top Opens the linked document in
the full body of the window.
Targetframe Opens the linked document in a
named targetframe.
<!DOCTYPE html>
<html>
<body>
<a href="http://www.w3schools.com">
This is a link</a>
</body>
</html>
Output:
This is a link
The following example which links
http://www.tutorialspoint.com at your page:
<!DOCTYPE html> <html> <head>
<title>Hyperlink Example</title> </head>
<body> <p>Click following link</p>
<a href="http://www.tutorialspoint.com"
target="_self">Tutorials Point</a> </body>
</html>
This will produce following result, where you
can click on the link generated Tutorials Point
to reach to the home page of Tutorials Point.
Setting Link Colors
• You can set colors of your links, active links
and visited links using link, alink and vlink
attributes of <body> tag.
Example
<!DOCTYPE html> <html> <head>
<title>Hyperlink Example</title> <base
href="http://www.tutorialspoint.com/">
</head> <body alink="#54A250" link="#040404"
vlink="#F40633"> <p>Click following link</p>
<a href="/html/index.htm" target="_blank"
>HTML Tutorial</a> </body> </html>
• This will produce following result. Just check
color of the link before clicking on it, next
check its color when you activate it and when
the link has been visited.
VALUE DESCRIPTION
NONE Removes all internal rules from the table
• Values in pixels
• Not supported in HTML5.
• Specifies the whitespace/ margin on left and
right side of an image
• <IMG HSPACE = value>
VSPACE
• Values in pixels
• Not supported in HTML5.
• Specifies the whitespace / margin on top and
bottom of an image
• <IMG VSPACE = value>
Image Maps
51
Special Characters & Symbols
Special Entity Special Entity
Character Name Character Name
Ampersand & & Greater-than > >
sign
Asterisk ∗ Less-than sign < <
∗∗
Cent sign ¢ ¢ Non-breaking
space
Copyright © © Quotation mark " "
Fraction one ¼ Registration ® ®
qtr ¼ mark
Fraction one ½ Trademark ™
52
half ½ sign ™
HTML <meta> Tag
Definition and Usage
• Metadata is data (information) about data.
• The <meta> tag provides metadata about the HTML
document. Metadata will not be displayed on the
page, but will be machine parsable.
• Meta elements are typically used to specify page
description, keywords, author of the document, last
modified, and other metadata.
• The metadata can be used by browsers (how to
display content or reload page), search engines
(keywords), or other web services.
HTML <meta> Tag
• <meta> tags always goes inside the <head>
element.
• Metadata is always passed as name/value
pairs.
• meta tags do not impact physical appearance
of the document
• The content attribute must be defined if the
name or the http-equiv attribute is defined. If
none of these are defined, the content
attribute cannot be defined.
• In HTML the <meta> tag has no end tag.
Examples
• Define keywords for search engines:
<meta name="keywords" content="HTML, CSS,
XML, XHTML, JavaScript">
• Define a description of your web page:
<meta name="description" content="Free Web
tutorials on HTML and CSS">
• Define the author of a page:
<meta name="author" content="Hege Refsnes">
• Refresh document every 30 seconds:
<meta http-equiv="refresh" content="30">
Attributes
Attribute Value Description
1.charset character_set Specifies the
character encoding
for the HTML
document
1.content text Gives the value
associated with the
http-equiv or name
attribute
Attributes
Attribute Value Description
http-equiv content-type Provides an HTTP
default-style header for the
refresh information/value
of the content
attribute
name application-name Specifies a name
author for the metadata
description
generator
keywords
Attributes
Attribute Description
<!DOCTYPE html><html><head><title>Password
Input Control</title></head><body><form
>User ID : <input type="text"
name="user_id" /><br>Password: <input
type="password" name="password"
/></form></body></html>
Attributes
Following is the list of attributes for <input> tag for
creating password field.
Attribute Description
type Indicates the type of input control and for
password input control it will be set to
password.
name Used to give a name to the control which
is sent to the server to be recognized and
get the value.
value This can be used to provide an initial value
inside the control.
Attributes
Attribute Description
• Example
Here is a basic example of a multi-line text input
used to take item description:
<!DOCTYPE html><html><head><title>Multiple-
Line Input Control</title></head><body>
<form>Description : <br /><textarea rows="5"
cols="50" name="description">Enter
description
here...</textarea></form></body></html>
Attributes
• Type Description
Submit This creates a button that automatically submits a
form.
reset This creates a button that automatically resets
form controls to their initial values.
button This creates a button that is used to trigger a
client-side script when the user clicks that button.
Image This creates a clickable button but we can use an
image as background of the button.
Example
• Here is example HTML code for a form with
three types of buttons:
• <!DOCTYPE html><html><head><title>File
Upload
Box</title></head><body><form><input
type="submit" name="submit" value="Submit"
/><input type="reset" name="reset"
value="Reset" /><input type="button"
name="ok" value="OK" /><input
type="image" name="imagebutton"
src="/html/images/logo.png"
/></form></body></html>
Hidden Form Controls
• Hidden form controls are used to hide data inside
the page which later on can be pushed to the
server.
• This control hides inside the code and does not
appear on the actual page. For example, following
hidden form is being used to keep current page
number.
• When a user will click next page then the value of
hidden control will be sent to the web server and
there it will decide which page has to be displayed
next based on the passed current page.
Example
• Here is example HTML code to show the usage
of hidden control:
• <!DOCTYPE html><html><head><title>File
Upload
Box</title></head><body><form><p>This is
page 10</p><input type="hidden"
name="pagename" value="10" /><input
type="submit" name="submit" value="Submit"
/><input type="reset" name="reset"
value="Reset" /></form></body></html>
DHTML (Dynamic HTML)
• HTML is based on thinking of a web page like a printed
page: a document that is rendered once and that is
static once rendered.
• The idea behind Dynamic HTML (DHTML), however, is to
make every element of a page interactively controllable,
before, during, and after the page is rendered. This
means we can make things move, appear and
disappear, overlap, change styles, and interact with the
user to our heart’s content.
• Through DHTML, users get a more engaging and
interactive web experience without constant calls to a
web server.
Definition
• DHTML is not a language itself, but is a
combination of:
– HTML 4.0 (or XHTML 1.0)
– JavaScript – the Web’s standard scripting
language
– Cascading Style Sheets (CSS) – styles dictated
outside a document’s content
– Document Object Model (DOM) – a means of
accessing a document’s individual elements
– DHTML = HTML + CSS + JavaScript + DOM
Why comes DHTML
• To make Web pages interactive.
• HTML pages have static nature.
• DHTML provides us with enhanced creative
control so we can manipulate any page
element at any time.
• It is the easiest way to make Web pages
interactive.
• It doesn’t increase server workload and
require special software to support.
Like most web technologies, DHTML comes with
its share of pros and cons.
• Advantages:
– File sizes are small: DHTML files are small compared to other
interactive media like Flash, Shockwave, and Java
– It’s supported by major browser manufacturers
– DHTML is a standard
– No plug-ins, ActiveX controls, or Java is necessary
– There are fewer calls to the server
• Disadvantages: