Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 23

BASIC WEB DEVELOPMENT

SET-1
1. A)

E -Commerce(ELECTRONIC COMMERCE)
Electronic commerce, commonly known as e-commerce or eCommerce, or e-business
consists of the buying and selling of products or services over electronic systems such as
the Internet and other computer networks. The amount of trade conducted electronically
has grown extraordinarily with widespread Internet usage. The use of commerce is
conducted in this way, spurring and drawing on innovations in electronic funds transfer,
supply chain management, Internet marketing, online transaction processing, electronic
data interchange (EDI), inventory management systems, and automated data collection
systems. Modern electronic commerce typically uses the World Wide Web at least at
some point in the transaction's lifecycle, although it can encompass a wider range of
technologies such as e-mail as well.

A large percentage of electronic commerce is conducted entirely electronically for virtual


items such as access to premium content on a website, but most electronic commerce
involves the transportation of physical items in some way. Online retailers are sometimes
known as e-tailers and online retail is sometimes known as e-tail. Almost all big retailers
have electronic commerce presence on the World Wide Web.

Electronic commerce that is conducted between businesses is referred to as business-to-


business or B2B. B2B can be open to all interested parties (e.g. commodity exchange) or
limited to specific, pre-qualified participants (private electronic market). Electronic
commerce that is conducted between businesses and consumers, on the other hand, is
referred to as business-to-consumer or B2C. This is the type of electronic commerce
conducted by companies such as Amazon.com. Online shopping is a form of electronic
commerce where the buyer is directly online to the seller's computer usually via the
internet. There is no intermediary service. The sale and purchase transaction is completed
electronically and interactively in real-time such as Amazon.com for new books. If an
intermediary is present, then the sale and purchase transaction is called electronic
commerce such as eBay.com.

Electronic commerce is generally considered to be the sales aspect of e-business. It also


consists of the exchange of data to facilitate the financing and payment aspects of the
business transactions.

E-COMMERCE EXAMPLES

Examples of e-commerce transactions are:


• An individual purchases a book on the Internet.
• A government employee reserves a hotel room over the Internet.
• A business calls a toll free number and orders a computer using the
seller's interactive telephone system.
• A business buys office supplies on-line or through an electronic auction.
• A retailer orders merchandise using an EDI network or a supplier's
extranet.
• A manufacturing plant orders electronic components from another plant
within the company using the company's intranet.
• An individual withdraws funds from an automatic teller machine (ATM).

1. B)

JAVA
Java is a programming language originally developed by James Gosling at Sun
Microsystems (which is now a subsidiary of Oracle Corporation) and released in 1995 as
a core component of Sun Microsystems' Java platform. The language derives much of its
syntax from C and C++ but has a simpler object model and fewer low-level facilities.
Java applications are typically compiled to bytecode (class file) that can run on any Java
Virtual Machine (JVM) regardless of computer architecture. Java is a general-purpose,
concurrent, class-based, object-oriented language that is specifically designed to have as
few implementation dependencies as possible. It is intended to let application developers
"write once, run anywhere". Java is currently one of the most popular programming
languages in use, and is widely used from application software to web applications.[9]
[10]

The original and reference implementation Java compilers, virtual machines, and class
libraries were developed by Sun from 1995. As of May 2007, in compliance with the
specifications of the Java Community Process, Sun relicensed most of its Java
technologies under the GNU General Public License. Others have also developed
alternative implementations of these Sun technologies, such as the GNU Compiler for
Java, GNU Classpath, and Dalvik.

Java Platform

One characteristic of Java is portability, which means that computer programs written in
the Java language must run similarly on any supported hardware/operating-system
platform. This is achieved by compiling the Java language code to an intermediate
representation called Java bytecode, instead of directly to platform-specific machine
code. Java bytecode instructions are analogous to machine code, but are intended to be
interpreted by a virtual machine (VM) written specifically for the host hardware. End-
users commonly use a Java Runtime Environment (JRE) installed on their own machine
for standalone Java applications, or in a Web browser for Java applets.
Standardized libraries provide a generic way to access host-specific features such as
graphics, threading, and networking.

A major benefit of using bytecode is porting. However, the overhead of interpretation


means that interpreted programs almost always run more slowly than programs compiled
to native executables would. Just-in-Time compilers were introduced from an early stage
that compile bytecodes to machine code during runtime. Over the years, this JVM built-in
feature has been optimized to a point where the JVM's performance competes with
natively compiled C code.following is a java program that prints date

import java.util.*;

public class HelloDate


{

public static void main (String[] args) {


System.out.println ("Hello, it's: ");
System.out.println(new Date());
}
}

1. C)

XML
Extensible Markup Language (XML) is a set of rules for encoding documents in
machine-readable form. It is defined in the XML 1.0 Specification[4] produced by the
W3C, and several other related specifications, all gratis open standards.[5]

XML's design goals emphasize simplicity, generality, and usability over the Internet.[6] It
is a textual data format with strong support via Unicode for the languages of the world.
Although the design of XML focuses on documents, it is widely used for the
representation of arbitrary data structures, for example in web services.

Many application programming interfaces (APIs) have been developed that software
developers use to process XML data, and several schema systems exist to aid in the
definition of XML-based languages.

As of 2009, hundreds of XML-based languages have been developed,[7] including RSS,


Atom, SOAP, and XHTML. XML-based formats have become the default for most
office-productivity tools, including Microsoft Office (Office Open XML),
OpenOffice.org (OpenDocument), and Apple's iWork.[8]
XML Declaration
XML documents may begin by declaring some information about themselves, as
in the following example.
<?xml version="1.0" encoding="UTF-8" ?>

Example

Here is a small, complete XML document, which uses all of these constructs and
concepts.

<?xml version="1.0" encoding="UTF-8" ?>


<painting>
<img src="madonna.jpg" alt='Foligno Madonna, by Raphael'/>
<caption>This is Raphael's "Foligno" Madonna, painted in
<date>1511</date>–<date>1512</date>.
</caption>
</painting>

2. A)

MAIL SERVER
A mail server (also known as a mail transfer agent or MTA, a mail transport agent, a mail
router or an Internet mailer) is an application that receives incoming e-mail from local
users (people within the same domain) and remote senders and forwards outgoing e-mail
for delivery. A computer dedicated to running such applications is also called a mail
server. Microsoft Exchange, qmail, Exim and sendmail are among the more common
mail server programs.

The mail server works in conjunction with other programs to make up what is sometimes
referred to as a messaging system. A messaging system includes all the applications
necessary to keep e-mail moving as it should. When you send an e-mail message, your e-
mail program, such as Outlook or Eudora, forwards the message to your mail server,
which in turn forwards it either to another mail server or to a holding area on the same
server called a message store to be forwarded later. As a rule, the system uses SMTP
(Simple Mail Transfer Protocol) or ESMTP (extended SMTP) for sending e-mail, and
either POP3 (Post Office Protocol 3) or IMAP (Internet Message Access Protocol) for
receiving e-mail.

2. B)

FTP SERVER
File Transfer Protocol (FTP) is a standard network protocol used to copy a file from one
host to another over a TCP/IP-based network, such as the Internet. FTP is built on a
client-server architecture and utilizes separate control and data connections between the
client and server.[1] FTP users may authenticate themselves using a clear-text sign-in
protocol but can connect anonymously if the server is configured to allow it.

The first FTP client applications were interactive command-line tools, implementing
standard commands and syntax. Graphical user interface clients have since been
developed for many of the popular desktop operating systems in use today.

A client makes a TCP connection to the server's port 21. This connection, called the
control connection, remains open for the duration of the session, with a second
connection, called the data connection, opened by the server from its port 20 to a client
port (specified in the negotiation dialog) as required to transfer file data. The control
connection is used for session administration (i.e., commands, identification, passwords)
[4]
exchanged between the client and server using a telnet-like protocol. For example
"RETR filename" would transfer the specified file from the server to the client. Due to
this two-port structure, FTP is considered an out-of-band, as opposed to an in-band
protocol such as HTTP.[4]

The server responds on the control connection with three digit status codes in ASCII with
an optional text message, for example "200" (or "200 OK.") means that the last command
was successful. The numbers represent the code number and the optional text represent
explanations (i.e., <OK>) or needed parameters (i.e., <Need account for storing file>).[1]
A file transfer in progress over the data connection can be aborted using an interrupt
message sent over the control connection.

FTP can be run in active or passive mode, which determine how the data connection is
established. In active mode, the client sends the server the IP address and port number on
which the client will listen, and the server initiates the TCP connection. In situations
where the client is behind a firewall and unable to accept incoming TCP connections,
passive mode may be used. In this mode the client sends a PASV command to the server
and receives an IP address and port number in return. The client uses these to open the
data connection to the server.[3] Both modes were updated in September 1998 to add
support for IPv6. Other changes were made to passive mode at that time, making it
extended passive mode.[5]

While transferring data over the network, four data representations can be used[2]:

• ASCII mode: used for text. Data is converted, if needed, from the sending host's
character representation to "8-bit ASCII" before transmission, and (again, if
necessary) to the receiving host's character representation. As a consequence, this
mode is inappropriate for files that contain data other than plain text.
• Image mode (commonly called Binary mode): the sending machine sends each
file byte for byte, and the recipient stores the bytestream as it receives it. (Image
mode support has been recommended for all implementations of FTP).
• EBCDIC mode: use for plain text between hosts using the EBCDIC character set.
This mode is otherwise like ASCII mode.
• Local mode: Allows two computers with identical setups to send data in a
proprietary format without the need to convert it to ASCII

For text files, different format control and record structure options are provided. These
features were designed to facilitate files containing Telnet or ASA formatting.

Data transfer can be done in any of three modes[1]:

• Stream mode: Data is sent as a continuous stream, relieving FTP from doing any
processing. Rather, all processing is left up to TCP. No End-of-file indicator is
needed, unless the data is divided into records.
• Block mode: FTP breaks the data into several blocks (block header, byte count,
and data field) and then passes it on to TCP.[2]
• Compressed mode: Data is compressed using a single algorithm (usually Run-
length encoding).

2. C)

NEWS SERVER
A news server is a set of computer software used to handle Usenet articles. It may also
refer to a computer itself which is primarily or solely used for handling Usenet. A reader
server provides an interface to read and post articles, generally with the assistance of a
news client. A transit server exchanges articles with other servers. Most servers can
provide both functions

4.

WEB BROWSERS
A web browser or Internet browser is a software application for retrieving, presenting,
and traversing information resources on the World Wide Web. An information resource
is identified by a Uniform Resource Identifier (URI) and may be a web page, image,
video, or other piece of content.[1] Hyperlinks present in resources enable users to easily
navigate their browsers to related resources.

Although browsers are primarily intended to access the World Wide Web, they can also
be used to access information provided by Web servers in private networks or files in file
systems. Some browsers can also be used to save information resources to file systems.
Function

The primary purpose of a web browser is to bring information resources to the user. This
process begins when the user inputs a Uniform Resource Identifier (URI), for example
http://en.wikipedia.org/, into the browser. The prefix of the URI determines how the URI
will be interpreted. The most commonly used kind of URI starts with http: and identifies
a resource to be retrieved over the Hypertext Transfer Protocol (HTTP). Many browsers
also support a variety of other prefixes, such as https: for HTTPS, ftp: for the File
Transfer Protocol, and file: for local files. Prefixes that the web browser cannot directly
handle are often handed off to another application entirely. For example, mailto: URIs
are usually passed to the user's default e-mail application and news: URIs are passed to
the user's default newsgroup reader.

In the case of http, https, file, and others, once the resource has been retrieved the web
browser will display it. HTML is passed to the browser's layout engine to be transformed
from markup to an interactive document. Aside from HTML, web browsers can generally
display any kind of content that can be part of a web page. Most browsers can display
images, audio, video, and XML files, and often have plug-ins to support Flash
applications and Java applets. Upon encountering a file of an unsupported type or a file
that is set up to be downloaded rather than displayed, the browser prompts the user to
save the file to disk.

Interactivity in a web page can also be supplied by JavaScript, which usually does not
require a plugin. JavaScript can be used along with other technologies to allow "live"
interaction with the web page's server via AJAX.

Information resources may contain hyperlinks to other information resources. Each link
contains the URI of a resource to go to. When a link is clicked, the browser navigates to
the resource indicated by the link's target URI, and the process of bringing content to the
user begins again.

Difference between Internet Explorer and Mozila Fire Fox

(1) Mozilla Firefox uses Open Source software that is a collaboration of varied
programmers internationally that volunteer to be able to contribute and build a
better web browser regardless of their culture or language. Firefox is available in
62 languages whereas Internet Explorer is only available in 33 languages.

(2) Different Layout engines - Mozilla Firefox uses Gecko, the Mozilla project's
open-source layout engine, and is used by a variety of products derived from the
Mozilla code base, including Thunderbird E-mail client, and Seamonkey
application suite.

Microsoft Internet Explorer uses the layout engine Trident and is used by many
applications on the Microsoft Windows platform to render HTML, as in Outlook
Express, some versions of Microsoft Outlook, and the mini-browsers in Winamp and
RealPlayer.

(3) Firefox has for many years has had variety of add-on, programs and enhancements
to choose from to let the user personalize their own web browser to make the Internet
a better experience according to their interests.

Microsoft has only just recently expanded to allow add-on for users.

(4) Firefox security vulnerabilities are fixed fairly rapidly, it doesn't discriminate it's
users and no validation needed for updates which means a safer internet experience
for everyone.

Microsoft Internet Explorer updates requires a validation of purchase for the Operating
System. If the users computer fails the validation, no updates can be installed. Also some
vulnerabilities are do not seem to be perceived by Microsoft as a priority, leaving the
users computer prone to spyware and viruses

3.
An HTML tag is a container for whatever you put within that tag. For example, the bold
tag <b> is used to make text bold. If you want the words "Hello everyone" to be in a
emboldened style on your document, you would then encapsulate it within bold tags. For
example:- <b>Something Important to remember</b>*

Before we go any further, we'll run through the required steps to create a valid HTML
document.

Basic Document structure

Every page must contain an opening <HTML> "tag" - thus indicating to the browser that
the of code is markup to be rendered.

The <HEAD> section follows, which will contain whats known as document headers.
These headers don't actually render anything visible to the end user, but provide
information about that document (Metadata) and varying other references to scripts or
stylesheets.

The head section also contains the <TITLE> tag which displays on the blue bar at the top
left of the browser window and also provides the text for a favourites listing. After the
title tag is opened and the text inserted, the tag must be closed using </TITLE>. When all
the page headers are set, the head section is closed, by entering </HEAD>.

The section of a web document where the majority of content and markup is displayed
and rendered, is within the <BODY> tag. Commonly, the body tag will contain the bulk
of tables, images and links. After the content of the webpage has finished, the body tag is
then closed (</BODY>), and the whole document closed by </HTML>
Tip: HTML elements (for HTML 4) are not case sensitive, so something scripted as
<hTmL> will work just as <html> or <HTML> would. However, using the same case
across documents is good practice for scripting/programming as a whole, as consistency
is a good asset. XHTML, which is the future of HTML, will require "well-formed"
documents and as such will not allow upper case tags or combinations of upper and lower
case.

As you can see in the illustration above, there is another essential piece at the very top.
This is a piece of metadata again, and its not even within the structure of the document,
so as you would expect, it displays nothing on screen. This is a very important inclusion
as it defines the document type - which is not a requirement, but it should be included as
part of every web document.

This particular document states HTML PUBLIC, which is pretty self explanatory, the
W3C are the body who regulate and standardise markup languages such as HTML, DTD
is the "document type definition" HTML4.0 is the particular specification of HTML we
are using, transitional is the type of document we have created and finally, EN shows that
the language is English.

For an HTML document to validate correctly, it MUST have this document type line,
before the <HTML> tag.

HTML elements, attributes and structure

HTML elements can be manipulated using attributes contained inline, within a block of
source code.

For example:
The anchor element <a> is for defining hyperlinks. On its own, it does very little, but by
adding the href attribute (<a href="page.html">), the anchor now has a reference to a
document, which when clicked, would load that document.
It could be added to further by including a definition for the target of the link: <a
href="page.html" target="_blank"> which instructs the browser to open a new browser
window, before loading the document within that window.

Almost all HTML elements can be customised by the use of attributes and there are a
great many attributes at the disposal of a developer to use.

Structure and nesting

HTML tags are opened and closed in a structured, hierarchical way. The nesting of
HTML is important in order for the output to appear how you expect it to in your
browser.

Fig 2: Some correct markup?

The above example is incorrect. the closing </a> should be before the closing </p> tag.
Internet Explorer has the capacity to "fix" markup errors, but if viewed in a stricter
browser such as Netscape or Opera - incorrect markup will not appear as expected.

Fig 3: Corrected markup.

The line is now correct, as the paragraph and anchor tags have been opened and closed
correctly. There are a few cases where nesting can take place, but this is predominantly
within tables, which are made up of multiple tags. For the most part, HTML tags must be
opened and closed in a structured fashion.

set-2
1. HTML text tags with coding and corresponding output on the HTML page are given as
follows(under every text tags code is given first and then the result of the code).

a. FONT COLOR

 <FONT COLOR="#0000FF">Test text.</FONT>


Test text.
 <FONT COLOR="blue">Test text.</FONT>
Test text.

b. FONT FACES

<FONT FACE="arial">Test text</FONT> compared to default text.


Test text compared to default text.

COMBINING FONT FACE AND STYLES

• <FONT FACE="arial"><B><I>Test text</I></B></FONT> compared to default


text.
Test text compared to default text.

c. FONT LOGICAL STYLES


The <BIG>Big<BIG> Text</BIG> tag</BIG> can be cumulative.

The Big Text tag can be cumulative.


An example of the <ADDRESS>Mail Address tag</ADDRESS> in a document.

An example of the

Mail Address tag


in a document.

d.FONT PHYSICAL STYLES


 <BLACKFACE>Blackface Text</BLACKFACE>, compared to normal text.

Blackface Text, compared to normal text.

 <B>Bold Text</B>, compared to normal text.

Bold Text, compared to normal text.

e.FONT SIZES
<FONT SIZE="3">Test text</FONT>
Test text
<FONT SIZE="7">Test text</FONT>

Test text
f. HEADERS

 Normal text before <H2>Header 2 text,</H2> normal text after.

Normal text before

Header 2 text,
normal text after.
 Normal text before <H3>Header 3 text,</H3> normal text after.

Normal text before

Header 3 text,
normal text after.

g. HIDING TEXT/TAGS
COMMENTING IN THE HTML CODING

• <!-- -->
Example code:
<!-- Tags and text will <B>not</B> be read by browser -->

Results of example code:

• <COMMENT>
Example code:
<COMMENT>Text will not be read by browser, <B>but tags will be.</B>
</COMMENT>

4.
Stylesheets represent a major breakthrough for web pages designers,expanding their
ability to improve the appearance of their pages.
Style sheets simplify HTML markup and largely relieve HTML of the responsibilities
of presentation. They give both authors and users control over the presentation of
documents—font information,alignment,colors etc. Style information can be specified
for individual elements or groups of elements. Style information may be specified in
an HTML document or in external style sheets. The mechanisms for associating a
style sheet with a document is independent of the style sheet language

For example,the following short CSS style sheet (stored in the file “special.css”),seta
the text color of a paragraph to green and surrounds it with a solid red border:

P.special{

color:green;

border: solid red;

Authors may link this style sheet to their source HTML document with the LINK
element:

<!DOCTYPE HTML PUBLIC”-//W3C//DTD HTML 4.01//EN”

“http://www.w3.org/TR/html4/strict.dtd”>

<HTML>

<HEAD>

<LINK href=”special.css” rel=”stylesheet”type=”text/css”>

</HEAD>

<BODY>

<P class=”special”>This paragraph should have special green text.

</BODY>

</HTML>
3.
links and anchors
HTML offers many of the conventional publishing idioms for rich text and structured
documents, but what separates it from most other markup languages is its features for
hypertext and interactive documents. This section introduces the link (or hyperlink, or
Web link), the basic hypertext construct. A link is a connection from one Web resource to
another. Although a simple concept, the link has been one of the primary forces driving
the success of the Web.

A link has two ends -- called anchors -- and a direction. The link starts at the "source"
anchor and points to the "destination" anchor, which may be any Web resource (e.g., an
image, a video clip, a sound bite, a program, an HTML document, an element within an
HTML document, etc.).

linked resource

The default behavior associated with a link is the retrieval of another Web resource. This
behavior is commonly and implicitly obtained by selecting the link (e.g., by clicking,
through keyboard input, etc.).

The following HTML excerpt contains two links, one whose destination anchor is an
HTML document named "chapter2.html" and the other whose destination anchor is a GIF
image in the file "forest.gif":

<BODY>
...some text...
<P>You'll find a lot more in <A href="chapter2.html">chapter two</A>.
See also this <A href="../images/forest.gif">map of the enchanted forest.</A>
</BODY>

By activating these links (by clicking with the mouse, through keyboard input, voice
commands, etc.), users may visit these resources. Note that the hrefattribute in each
source anchor specifies the address of the destination anchor with a URI.

The destination anchor of a link may be an element within an HTML document. The
destination anchor must be given an anchor name and any URI addressing this anchor
must include the name as its fragment identifier.

Destination anchors in HTML documents may be specified either by the A element


(naming it with the name attribute), or by any other element (naming with the id
attribute).
Thus, for example, an author might create a table of contents whose entries link to header
elements H2, H3, etc., in the same document. Using the A element to create destination
anchors, we would write:

<H1>Table of Contents</H1>
<P><A href="#section1">Introduction</A><BR>
<A href="#section2">Some background</A><BR>
<A href="#section2.1">On a more personal note</A><BR>
...the rest of the table of contents...
...the document body...
<H2><A name="section1">Introduction</A></H2>
...section 1...
<H2><A name="section2">Some background</A></H2>
...section 2...
<H3><A name="section2.1">On a more personal note</A></H3>
...section 2.1...

We may achieve the same effect by making the header elements themselves the anchors:

<H1>Table of Contents</H1>
<P><A href="#section1">Introduction</A><BR>
<A href="#section2">Some background</A><BR>
<A href="#section2.1">On a more personal note</A><BR>
...the rest of the table of contents...
...the document body...
<H2 id="section1">Introduction</H2>
...section 1...
<H2 id="section2">Some background</H2>
...section 2...
<H3 id="section2.1">On a more personal note</H3>
...section 2.1...

Other link relationships

By far the most common use of a link is to retrieve another Web resource, as illustrated in
the previous examples. However, authors may insert links in their documents that express
other relationships between resources than simply "activate this link to visit that related
resource". Links that express other types of relationships have one or more link types
specified in their source anchor.

The roles of a link defined by A or LINK are specified via the rel and rev attributes.

For instance, links defined by the LINK element may describe the position of a document
within a series of documents. In the following excerpt, links within the document entitled
"Chapter 5" point to the previous and next chapters:
<HEAD>
...other head information...
<TITLE>Chapter 5</TITLE>
<LINK rel="prev" href="chapter4.html">
<LINK rel="next" href="chapter6.html">
</HEAD>

The link type of the first link is "prev" and that of the second is "next" (two of several
recognized link types). Links specified by LINK are not rendered with the document's
contents, although user agents may render them in other ways (e.g., as navigation tools).

Even if they are not used for navigation, these links may be interpreted in interesting
ways. For example, a user agent that prints a series of HTML documents as a single
document may use this link information as the basis of forming a coherent linear
document. Further information is given below on using links for the benefit of search
engines.

Specifying anchors and links

Although several HTML elements and attributes create links to other resources (e.g., the
IMG element, the FORM element, etc.), this chapter discusses links and anchors created by
the LINK and A elements. The LINK element may only appear in the head of a
document. The A element may only appear in the body.

When the A element's href attribute is set, the element defines a source anchor for a link
that may be activated by the user to retrieve a Web resource. The source anchor is the
location of the A instance and the destination anchor is the Web resource.

The retrieved resource may be handled by the user agent in several ways: by opening a
new HTML document in the same user agent window, opening a new HTML document
in a different window, starting a new program to handle the resource, etc. Since the A
element has content (text, images, etc.), user agents may render this content in such a way
as to indicate the presence of a link (e.g., by underlining the content).

When the name or id attributes of the A element are set, the element defines an anchor
that may be the destination of other links.

Authors may set the name and href attributes simultaneously in the same A instance.

The LINK element defines a relationship between the current document and another
resource. Although LINK has no content, the relationships it defines may be rendered by
some user agents.
Link titles

The title attribute may be set for both A and LINK to add information about the nature
of a link. This information may be spoken by a user agent, rendered as a tool tip, cause a
change in cursor image, etc.

Thus, we may augment a previous example by supplying a title for each link:

<BODY>
...some text...
<P>You'll find a lot more in <A href="chapter2.html"
title="Go to chapter two">chapter two</A>.
<A href="./chapter2.html"
title="Get chapter two.">chapter two</A>.
See also this <A href="../images/forest.gif"
title="GIF image of enchanted forest">map of
the enchanted forest.</A>
</BODY>

Internationalization and links

Since links may point to documents encoded with different character encodings, the A
and LINK elements support the charset attribute. This attribute allows authors to
advise user agents about the encoding of data at the other end of the link.

The hreflang attribute provides user agents with information about the language of a
resource at the end of a link, just as the lang attribute provides information about the
language of an element's content or attribute values.

Armed with this additional knowledge, user agents should be able to avoid presenting
"garbage" to the user. Instead, they may either locate resources necessary for the correct
presentation of the document or, if they cannot locate the resources, they should at least
warn the user that the document will be unreadable and explain the cause.

2.

Table formatting by visual user agents

The following description describes the HTML table attributes that tell visual user agents
how to format tables. Style sheets will offer better control of visual table formatting. At
the writing of this specification, [CSS1] did not offer mechanisms to control all aspects of
visual table formatting.

This version of HTML includes mechanisms to control:


• horizontal and vertical alignment of cell contents,
• border styles
• and cell margins

Horizontal and vertical alignment

The following attributes may be set for different table elements (see their definitions).

<!-- horizontal alignment attributes for cell contents -->


<!ENTITY % cellhalign
"align (left|center|right|justify|char) #IMPLIED
char CDATA #IMPLIED -- alignment char, e.g. char=':' --
charoff CDATA #IMPLIED -- offset for alignment char --"
>
<!-- vertical alignment attributes for cell contents -->
<!ENTITY % cellvalign
"valign (top|middle|bottom|baseline) #IMPLIED"
>

Attribute definitions

align = left|center|right|justify|char
This attribute specifies the alignment of data and the justification of text in a cell.
Possible values:

• left: Left-flush data/Left-justify text. This is the default value for


table data.
• center: Center data/Center-justify text. This is the default value for
table headers.
• right: Right-flush data/Right-justify text.
• justify: Double-justify text.
• char:Align text around a specific character.

valign = top|middle|bottom|baseline
This attribute specifies the vertical position of data within a cell. Possible values:

• top: Cell data is flush with the top of the cell.


• middle: Cell data is centered vertically within the cell. This is the
default value.
• bottom: Cell data is flush with the bottom of the cell.
• baseline: All cells in the same row as a cell whose valign attribute
has this value should have their textual data positioned so that the first text
line occurs on a baseline common to all cells in the row. This constraint
does not apply to subsequent text lines in these cells.

char = cdata
This attribute specifies a character within a text fragment which will act as an axis
for alignment. The default value for this attribute is the decimal point character
for the current language (as set by the lang attribute (e.g., the period (".") in
English and the comma (",") in French). The value of this attribute is case-
sensitive.
charoff = length
When present, this attribute specifies the offset to the first occurrence of the
alignment character on each line. If a line doesn't include the alignment character,
it should be horizontally shifted to end at the alignment position.

When charoff is used so set the offset of an alignment character, the direction of
offset is determined by the current text direction (set by the dir attribute). In left-
to-right texts (the default), offset is from the left margin. In right-to-left texts,
offset is from the right margin.

The table in this example aligns a row of currency values along a decimal point. We set
the alignment character to "." explicitly.

<TABLE border="border">
<COLGROUP>
<COL><COL align="char" char=".">
<THEAD>
<TR><TH>Vegetable <TH>Cost per kilo
<TBODY>
<TR><TD>Lettuce <TD>$1
<TR><TD>Silver carrots <TD>$10.50
<TR><TD>Golden turnips <TD>$100.30
</TABLE>

Inheritance of alignment specifications

The alignment of cell contents can be specified on a cell by cell basis, or inherited from
enclosing elements, such as the row, column or the table itself.

The order of precedence (from highest to lowest) for the attributes align, char, and
charoff is the following:

1. An alignment attribute set on an element within a cell's data (e.g., P).


2. An alignment attribute set on a cell (TH and TD).
3. An alignment attribute set on a column or column group (COL and
COLGROUP). When a cell is part of a multi-column span, the alignment property
is inherited from the cell definition at the beginning of the span.
4. An alignment attribute set on a row or row group (TR, THEAD, TFOOT, and
TBODY). When a cell is part of a multi-row span, the alignment property is
inherited from the cell definition at the beginning of the span.
5. An alignment attribute set on the table (TABLE).
6. The default alignment value.

The order of precedence (from highest to lowest) for the attribute valign (as well as the
other inherited attributes lang, dir, and style) is the following:

1. An attribute set on an element within a cell's data (e.g., P).


2. An attribute set on a cell (TH and TD).
3. An attribute set on a row or row group (TR, THEAD, TFOOT, and TBODY).
When a cell is part of a multi-row span, the attribute value is inherited from the
cell definition at the beginning of the span.
4. An attribute set on a column or column group (COL and COLGROUP). When a
cell is part of a multi-column span, the attribute value is inherited from the cell
definition at the beginning of the span.
5. An attribute set on the table (TABLE).
6. The default attribute value.

Furthermore, when rendering cells, horizontal alignment is determined by columns in


preference to rows, while for vertical alignment, rows are given preference over columns.

The default alignment for cells depends on the user agent. However, user agents should
substitute the default attribute for the current directionality (i.e., not just "left" in all
cases).

User agents that do not support the "justify" value of the align attribute may substitute the
"left" value.

Borders and rules

The following attributes affect a table's external frame and internal rules.

Attribute definitions

frame = void|above|below|hsides|lhs|rhs|vsides|box|border
This attribute specifies which sides of the frame that surrounds a table will be
visible. Possible values:

• void: No sides. This is the default value.


• above: The top side only.
• below: The bottom side only.
• hsides: The top and bottom sides only.
• vsides: The right and left sides only.
• lhs: The left-hand side only.
• rhs: The right-hand side only.
• box: All four sides.
• border: All four sides.
rules = none|groups|rows|cols|all
This attribute specifies which rules will appear between cells within a table.
Possible values:

• none: No rules. This is the default value.


• groups: Rules will appear between row groups (see THEAD,
TFOOT, and TBODY) and column groups (see COLGROUP and COL)
only.
• rows: Rules will appear between rows only.
• cols: Rules will appear between columns only.
• all: Rules will appear between all rows and columns.

border = cdata
This attributes specifies the width (in pixels only) of the frame around a table (see
the Note below for more information about this attribute).

In the following table, borders five pixels thick will be rendered on the left- and right-
hand sides of the table and rules should be displayed between all columns.

<TABLE border="5" frame="vsides" rules="cols">


<TR> <TD>1 <TD>2 <TD>3
<TR> <TD>4 <TD>5 <TD>6
<TR> <TD>7 <TD>8 <TD>9
</TABLE>

The following settings should be observed by user agents for backwards compatibility.

• Setting border="0" implies frame="void" and, unless otherwise specified,


rules="none".
• Other values of border imply frame="border" and, unless otherwise specified,
rules="all".
• The value "border" in the start tag of the TABLE element should be interpreted as
the value of the frame attribute. It implies rules="all" and some default (non-zero)
value for the border attribute.

Thus, for example:

<FRAME border="2"> <=> <FRAME border="2" frame="border" rules="all">

and

<FRAME border> <=> <FRAME frame="border" rules="all">

Note: The border attribute also defines the border behavior for the OBJECT and IMG
elements, but takes different values for those elements.
Cell margins

Two attributes control spacing between and within cells.

Attribute definitions

cellspacing = length
This attribute specifies how much space should be left between the table frame
and the first or last cell border for each row or column, and between the cells in a
table.
cellpadding = length
This attribute specifies the amount of space between the border of the cell and its
contents, on all sides of the contents.

In the following table, the cellspacing attribute specifies that cells will be separated from
each other and from the table frame by twenty pixels. The cellpadding attribute specifies
that the top margin of the cell and the bottom margin of the cell will each be separated
from the cell's contents by 10% of the available vertical space (the total being 20%).
Similarly, the left margin of the cell and the right margin of the cell will each be
separated from the cell's contents by 10% of the available horizontal space (the total
being 20%).

<TABLE>
<TR cellspacing="20"> <TD>Data1 <TD cellpadding="20%">Data2 <TD>Data3
</TABLE>

If a table or given column has a fixed width, cellspacing and cellpadding may demand
more space than assigned. We recommend that user agents give these attributes
precedence over the width attribute when a conflict occurs, but this is not a requirement.

Some sample tables

The following table samples illustrate the interaction of all the table elements.

Sample 1

In "ascii art", the following table:

<TABLE border="border">
<CAPTION>A test table with merged cells</CAPTION>
<TR><TH rowspan=2><TH colspan="2">Average
<TH rowspan="2">other<BR>category<TH>Misc
<TR><TH>height<TH>weight
<TR><TH align="left">males<TD>1.9<TD>0.003
<TR><TH align="left" rowspan="2">females<TD>1.7<TD>0.002
</TABLE>

You might also like