Unit-I Introduction To Web Technologies: Advantages of Web Technology
Unit-I Introduction To Web Technologies: Advantages of Web Technology
Unit-I Introduction To Web Technologies: Advantages of Web Technology
Web technology is the development of the mechanism that allows two of more computer
devices to communicate over a network.
For instance, in a typical office setting, a number of computers plus additional devices such
as printers may be interconnected via a network, allowing for quick and convenient
transmission of information. The processes involved in web technology are complex and
diverse, which is why major businesses employ whole departments to deal with the issue.
Web technology has revolutionized communication methods and has made operations far
more efficient.
Web server can refer to either the hardware (the computer) or the software (the computer
application) that helps to deliver Web content that can be accessed through the Internet.
Most popular Web server in the world developed by the Apache software
foundation. Apache web server is an open source and can be installed as almost all operating
systems including Linux, Unix, Windows, FreeBSD, Mac OS X and more. About 60% of
webserver machines run the Apache web server. Can have Apache with Tomcat module to
have JSP and J2EE related support.
1
Guide to download and install Tomcat 6:
Note: it should not contain the path up to bin folder. Here, we have taken the URL path
according to our installation convention.
For Windows OS, go through the following steps:
Now click on all the subsequent ok buttons one by one. It will set the JDK path.
Step 2: For setting the class path variable for JDK, do like this:
OR
First, right click on the
My Computer->properties->advance->Environment
Variables->path.
Step 3: The process of installing Tomcat 6.0 begins here from now. It takes various steps for
installing and configuring the Tomcat 6.0. For Windows OS, Tomcat comes in two forms:
.zip file and .exe file (the Windows installer file). Here we are exploring the installation
process by using the .exe file. First unpack the zipped file and simply execute the '.exe' file.
2
A Welcome screen shot appears that shows the beginning of installation process. Just click on
the 'Next' button to proceed the installation process.
3
Step 6:
A screen shot of 'Configuration Options' displays on the screen. Choose the location for the
Tomcat files as per your convenience. You can also opt the default Location
The port number will be your choice on which you want to run the tomcat server. The port
number 8080 is the default port value for tomcat server to proceed the HTTP requests. The
user can also change the 'port number' after completing the process of installation; for this,
users have to follow the following tips.
Go to the specified location as " Tomcat 6.0 \conf \server.xml ". Within the server.xml file
choose "Connector" tag and change the port number.
Now, click on the 'Next' button to further proceed the installation process.
Step 7:
4
This window asks for the location of the installed Java Virtual Machine. Browse the location
of the JRE folder and click on the Install button. This will install the Apache tomcat at the
specified location.
Step 8:
To get the information about installer click on the "Show details" button
Step 10: A window of Apache Service Manager appears with displaying the running process.
5
Let the running process goes on.
Step 11: After completing the installation process, the Apache Tomcat Manager appears on
the toolbar panel like shown in the below picture.
6
A configured window appears on the desktop. Now, just click on the Startup button. The
installation process will be completed.
Click on the Start up button -- select Control Panel -- Administrator Tool -- Services -- select
Apache Tomcat.
The following screen displays on the monitor.
Double click on the Apache Tomcat. The window of Apache Tomcat Properties appears on
the screen.
7
Now, Click on the start up button. The Apache Tomcat is now ready to function.
1.Start the tomcat server from the bin folder of Tomcat 6.0 directory by double clicking the
"tomcat6.exe" file. OR create a shortcut of this .exe file at your desktop.
2. Now Open web browser and type URL http://localhost:8080 in the address bar to test the
server
3. To Stop the Tomcat Server: Stop the server by pressing the "Ctrl + c" keys.
8
It is a form of mini-server that can run on almost any windows os.
It is a package of independently created program installed computers use a Microsoft
windows os.
It is a windows web development environment. It allows to create web applications
with Apache, PHP and the MySQL database. It also comes with PHPMyAdmin to
easily manage databases.
It installs automatically and its usage is very intuitive.
In Internet Explorer, you may get a warning about downloading the file. Click the
yellow information bar that appears above the Web page in IE, and choose Download
File…
In Vista you may see a message warning you that XAMPP may not work when
installed in the C:\Program Files directory. The default installation is in C:\XAMPP
so you don’t have to worry about this problem.
9
If you plan on doing a lot of development, day in and day out, you might want to turn
on the “Install Apache as service” and “Install MySQL as service” checkboxes. A
service starts up every time you turn on your computer, so Apache, PHP, and MySQL
are always running. However, if you won’t be building database sites frequently, or
you don’t have a lot of RAM in your computer, don’t turn on these boxes (you’ll just
have to manually start the servers when you wish to build dynamic pages, using the
XAMPP control panel described on the next page).
6. Click Install.
The installer places all the files onto your system. This process takes a while, since a
lot of programs and files are being installed.
7. Finally, click the Finish button.
A window appears “congratulating” you (way to double-click the installer program!),
and asking whether you wish to start the XAMPP Control panel.
8. Click Yes, to open the XAMPP Control Panel (see screenshot below).
The XAMPP Control Panel lets you start and stop the Apache Web server and
MySQL database server.
In this figure, both Apache and MySQL are currently NOT running, as indicated by
the word Start to the right of their names. Click the Start buttons to turn the servers
on. You can open the Control Panel by clicking the XAMPP Control Panel shortcut
on your desktop.
9. If the buttons to the right of Apache and MySQL say Start, click them to start
the Web server and the MySQL database server.
You probably get a Windows security alert about both MySQL and Apache: Click the
Unblock button in both cases. This action allows the two servers to run, and tells the
Windows firewall protection service that everything is OK.If Apache and MySQL are
already running, these buttons say Stop. (Clicking them turns off the Web server and
MySQL.) Whenever you start Apache, PHP automatically starts as well. At this point,
you should have a complete testing server running on your machine. You just need to
make sure it’s working.
10
10. To do so, launch a Web browser, and, in the Location bar, type http://localhost/.
You encounter a page that lists a bunch of languages; click the language you prefer,
and you’re taken to a kind of Web-based control panel for XAMPP (see screenshot
below).
Once installed, you can view your XAMPP home page from http://localhost/xampp/.
From the left-hand list of links, you can access helpful programs and information,
such as phpMyAdmin (for working with the MySQL database) and phpinfo() for
finding out more about the server setup.
Once you’ve installed XAMPP, you’ll see a shortcut called XAMPP Control Panel on your
desktop. Double-click this icon to control the servers you’ve just installed—you can turn the
servers off and on, as well as turn them into services (which launch each time you start up
your computer).
To uninstall XAMPP, just go to the location where you installed XAMPP (like C:\XAMPP\)
and run the program named Uninstall.exe. This action, however, deletes any databases you
created, and destroys any Web pages that you placed on the server. To prevent this process,
just follow these steps: First, use phpMyAdmin to export any database you wish to save (you
can find instructions at http://php.about.com/od/learnmysql/ss/mysql_backup_3.html), and
then make a copy of your Web pages which are located in the C:\XAMPP\htdocs folder.
11
3. WAMP (BUNDLE SERVER):
WAMPs are packages of independently created programs installed on computers that use a
Microsoft Windows operating system.
WAMP is an acronym formed from the initials of the operating system Microsoft Windows
and the principal components of the package: Apache, MySQL and one of PHP, Perl or
Python. Apache is a web server. MySQL is an open-source database. PHP is a scripting
language that can manipulate information held in a database and generate web pages
dynamically each time content is requested by a browser. Other programs may also be
included in a package, such as phpMyAdmin which provides a graphical user interface for
the MySQL database manager, or the alternative scripting languages Python or Perl.
WAMP stands for Windows Apache MySQL PHP. WAMP Server is an open source
software, which is free to use under the GPL licence (General Public Licence). Wamp is a
combination of numbers of software that allows to develop dynamic website with Apache
Server, MySQL database and PHP script language.
It also provides the facility of PHPMYAdmin and SQLite manager to handle the database
more easily and effectively.
We are installing the WAMP 2.0i version, that includes the latest version of Apache 2.2.11,
PHP 5.3.0 and MySQL 5.1.36.
Let's see installation of Wamp on XP step by step :
1. Search on Google :
If you don't have Wamp so you can search on google and download from there.
12
2. Download Wamp: You can download wamp from any website by clicking on download
tab or link.
3. Save File
13
5. Click Run to Install
6. Click Next
14
8. Choose the directory and click next.
9. Select Additional Icon :You can select either one or both the icon and then click on next button.
15
11. Installing Process:The installing process going on wait for while to install the wamp.
13. Click Finish :The moment you click on finish button, your Wamp Server installed on
your computer.
16
14. Take a look on Wamp Setting.
Look at your right hand side of your task bar, there was a small wamp icon in the shape of
semi-circle.
Just left click on the icon and look at all the setting are available here. You can also change
the setting according to your requirement.
17
The WampServer shows all the configuration of all the software and also two tools on the left
hand side. The first one is phpinfo() from there you can get information about the php and
the second one is phpmyadmin, this is your database and you can create database by clicking
on the phpmyadmin. Let's see the image of database :
Running & Testing on WAMP server: It provides a simple and effective way to use wamp
server, how to run a program , how to enable few features and so on.
After successful installation you can see a folder inside the C:\drive named wamp.
Inside folder there will be many files and folders like: alias, bin, lang, logs, scripts,
tmp etc.
Develop PHP programs inside the www folder e.g C:\wamp\www. Now start the
wamp server either by double click on the icon appear on the desktop or go to start
option and select wamp server.
After selecting the wamp server you can see an icon appear on the tray as sown in
below figure
Initially the icon will be partially red, it means no service is currently running, click
on it and a popup menu will appear, select the start all services option. Now the color
of the icon should change to white that means all services are running, if the color of
the icon appears half yellow then all services are not running the follow either of these
steps.
Left click on the icon, select apache, go to service option , click start/ resume
service.
Left click on the icon , select MySQL, go to service option, click start/resume
service.
18
Another option is left click on the icon and select restart all services.
To check whether the server is running or not again click on the icon of wamp server
and select Localhost option. Home page of the server will be displayed in Internet
Browser.
Develop a small program to check whether your server is running or not. Open the
c:\wamp\www folder , create a new folder named PHP, and open a blank text file
write the following code:
<?=”Hello PHP”?>
In the above code <?= ?> is an alternate of echo language construct, to enable this
option click on the wamp server icon on task bar, select PHP, select PHP settings, and
then check the short open tag option.
19
Then save the file with any name and .php extension. Start the server, click on the
localhost link, it will open the home page of the server and then click on the php link,
it will display the list of file name as link.
20
Click it and it will display Helo PHP in the web browser.
IIS is a web server similar to WAMP, which could be installed in your system, in case
IIS is installed and currently running in your system then you need to stop the service.
To stop IIS server go to Start option, select Control Panel, Administrative tool, select
services. In the service window search IIS service and stop the service.
IIS 7.5 supports HTTP, HTTPS, FTP, FTPS, SMTP and NNTP. It is an integral part of the
Windows Server family of products (and their client counterparts in the cases of Windows
NT 4.0 and Windows 2000), as well as certain editions of Windows XP, Windows Vista and
Windows 7.
The first Microsoft web server was a research project at the European Microsoft Windows
NT Academic Centre (EMWAC).
21
IIS 7.0 has a modular architecture. Modules, also called extensions, can be added or removed
individually so that only modules required for specific functionality have to be installed. IIS 7
includes native modules as part of the full installation. These modules are individual features
that the server uses to process requests and include the following
22
Step3: Select IIS
The Windows Component Wizard will appear. You need to select the Internet Information
Service(IIS) checkbox and then click Next
Do not be concerned if you do not see this step. It means your system has probably been
installed via the network, meaning you don't have to locate and insert your CD.
Step5: Installing
Once your WIndows XP Professional CD (or network based installation) is available you will
see a window like the following, indicating that Internet Information Services is being
installed.
23
Step6: Finished
When installation has finished you will see the following window, which shows that you
have successfully installed Microsoft Internet Information Services 5.1
Whenever your web browser fetches afile (a page, a picture etc) from a web server, it
does so using HTTP (Hyper Text Transfer Protocol).
HTTP is a request / response protocol, which means your computer sends a request from
some file ( e.g. Get me the file “home.html”) and web server sends back a response (“ Here’s
the file”, followed by file itself)
Java Servlets are programs that run on a Web or Application server and act as a
middle layer between a request coming from a Web browser or other HTTP client and
databases or applications on the HTTP server.
Following diagram shows the position of Servelts in a Web Application.
A servlet life cycle can be defined as the entire process from its creation till the destruction.
The following are the paths followed by a servlet
24
HTTPServlet class provides specialized methods that handle the various types of HTTP
requests. A Servlet developer typically overrides one of these methods. Methods are
doDelete(), doGet(), doOptions(), doPost(), doPut() and doTrace().
For handling the input, HTTP request makes use of two commonly used methods such as
GET and POST as
1. Handling HTTP-GET request
2. Handling HTTP-POST request
Develop a Servlet that handles an HTTP-GET request. The Servlet is invoked when a form
on a web page (HTML) is submitted. Write two programs
1. HTML Script in which Servlet is invoked
2. Servlet program
HTML Source code ColorGet.html is defines a form that contains a select element and a
submit button. Notice action parameters of the form tag specify a URL. URL identifies a
servlet to process the HTTP-GET request.
HTML program is as follows
<html>
<body>
<center>
<form name=”Form1” action=http://localhost:8080/servlet/ColorGetServlet>
<B> Color:</B>
<select name=”color” size=”1”>
<option value=”Red”>Red</option>
<option value=”Green”>Green</option>
<option value=”Blue”>Blue</option>
</select>
<br>
<input type=”submit” value=”submit”>
</form>
</center>
</body>
</html>
Sorce code for ColorGetServlet.java. The doGet() method is available to process by HTTP-
GET requests that are sent to this servlet. It uses getParameter() method of HTTP servlet
request to obtain selection that are made by user. A response is then formulated as
25
{
String color=request.getParameter(“color”);
// Set response content type
response.setContentType("text/html");
PrintWriter pw = response.getWriter();
pw.println(“<B> The Selected color is:”);
pw.println(color);
pw.close();
}
}
Compile the Servlet and then perform the steps to test the example
1. Start the Servletrunner
2. Display the web page in a browser
3. Select a color
4. Submit the web page
After completing the steps, the browser displays the response that is dynamically generated
by the Servlet. Parameters for an HTTP-GET request are included as part of the URL that is
sent to the web server. Assume that the user selects the red option and submit the form. The
URL sent from the browser to the server in the following
http://localhost:8080/servlet/ColorGetServlet ? color=red
Here ? is for query string
CLIENT-SERVER MODEL
The client-server model is a distributed communication framework of network processes
among service requestors, clients and service providers. The client-server connection is
established through a network or the Internet.
The client-server model is a core network computing concept also building functionality for
email exchange and Web/database access. Web technologies and protocols built around the
client-server model are:
Clients include Web browsers, chat applications, and email software, among others. Servers
include Web, database, application, chat and email, etc.
A server manages most processes and stores all data. A client requests specified data or
processes. The server relays process output to the client. Clients sometimes handle
processing, but require server data resources for completion.
26
The client-server model differs from a peer-to-peer (P2P) model where communicating
systems are the client or server, each with equal status and responsibilities. The P2P model is
decentralized networking. The client-server model is centralized networking.
One client-server model drawback is having too many client requests underrun a server and
lead to improper functioning or total shutdown. Hackers often use such tactics to terminate
specific organizational services through distributed denial-of-service (DDoS) attacks.
27
What is CSS?
CSS stands for Cascading Style Sheets.
It provides an additional feature to HTML.
CSS handles the look and feel part of a web page.
Using CSS, you can control the color of the text, the style of fonts, the spacing between
paragraphs.
CSS - Syntax
A style rule is made of three parts −
Selector − A selector is an HTML tag at which a style will be applied. This could be any
tag like <h1> or <table> etc.
Property - A property is a type of attribute of HTML tag. Put simply, all the HTML
attributes are converted into CSS properties. They could be color, border etc.
Value - Values are assigned to properties. For example, color property can have value
either red or #F1F1F1 etc.
h1 {
color: #36CFFF;
* {
color: #000000;
This rule renders the content of every element in our document in black.
.black {
color: #000000;
This rule renders the content in black for every element with class attribute set to black in our
document.
For example:
28
h1.black {
color: #000000;
This rule renders the content in black for only <h1> elements with class attribute set to black.
The ID Selectors
All the elements having that id will be formatted according to the defined rule.
#black {
color: #000000;
This rule renders the content in black for every element with id attribute set to black in our
document.
For example −
h1#black {
color: #000000;
This rule renders the content in black for only <h1> elements with id attribute set to black.
<html>
<head>
<style>
p{
text-align: center;
color: blue;
}
</style>
</head>
<body>
<p>This style will be applied on every paragraph.</p>
<p id="para1">Me too!</p>
<p>And me!</p>
</body>
</html>
CSS Id Selector
The id selector selects the id attribute of an HTML element to select a specific element.
<html>
<head>
29
<style>
#para1 {
text-align: center;
color: blue;
}
</style>
</head>
<body>
<p id="para1">Hello Javatpoint.com</p>
<p>This paragraph will not be affected.</p>
</body>
</html>
The class selector selects HTML elements with a specific class attribute.
<html>
<head>
<style>
.c1 {
text-align: center;
color: blue;
}
</style>
</head>
<body>
<h1 class="c1">This heading is blue and center-aligned.</h1>
<p class="c1">This paragraph is blue and center-aligned.</p>
</body>
</html>
30
CSS Universal Selector
The universal selector is used as a wildcard character. It selects all the elements on the pages.
<html>
<head>
<style>
*{
color: green;
font-size: 20px;
}
</style>
</head>
<body>
<h2>This is heading</h2>
<p>This style will be applied on every paragraph.</p>
<p id="para1">Me too!</p>
<p>And me!</p>
</body>
</html>
The grouping selector is used to select all the elements with the same style definitions.
<html>
<head>
<style>
h1, h2, p {
text-align: center;
color: blue;
}
</style>
</head>
<body>
<h1>Hello Javatpoint.com</h1>
<h2>Hello Javatpoint.com (In smaller font)</h2>
<p>This is a paragraph.</p>
</body>
</html>
How to add CSS
1. Inline CSS
2. Internal CSS
31
3. External CSS
1) Inline CSS
For example:
2) Internal CSS
Internal CSS is used to apply CSS on a single document or page. It can affect all the elements of
the page.
For example:
<style>
p{color:blue}
</style>
3) External CSS
External CSS is used to apply CSS on multiple pages or all pages. Here, we write all the CSS code
in a css file. Its extension must be .css for example style.css.
For example:
p{color:blue}
You need to link this style.css file to your html pages like this:
CSS Comments
Comments are single or multiple lines statement and written within /*............*/ .
32
CSS Background
1) CSS background-color
The background-color property is used to specify the background color of the element.
<html>
<head>
<style>
h2, p {
background-color: #b0d4de;
}
</style>
</head>
<body>
<h2>My first CSS page.</h2>
<p>Hello Javat. This is an example of CSS background-color.</p>
</body>
</html>
2) CSS background-image
<html>
<head>
<style>
body {
background-image: url("a.jpeg");
margin-left:100px;
}
</style>
</head>
<body>
<h1>Hello Java</h1>
</body>
</html>
CSS Border
The CSS border is a shorthand property used to set the border on an element.
33
The CSS border properties are given below
o border-style
o border-color
o border-width
o border-radius
CSS border-style
<html>
<head>
<style>
p.none {border-style: none;}
p.dotted {border-style: dotted;}
p.dashed {border-style: dashed;}
p.solid {border-style: solid;}
p.double {border-style: double;}
</style>
</head>
<body>
<p class="none">No border.</p>
<p class="dotted">A dotted border.</p>
<p class="dashed">A dashed border.</p>
<p class="solid">A solid border.</p>
<p class="double">A double border.</p>
</body>
</html>
CSS border-width
<html>
<head>
<style>
p.one {
border-style: solid;
border-width: 5px;
}
34
p.two {
border-style: solid;
border-width: medium;
}
p.three {
border-style: solid;
border-width: 1px;
}
</style>
</head>
<body>
<p class="one">Write your text here.</p>
<p class="two">Write your text here.</p>
<p class="three">Write your text here.</p>
</body>
</html>
CSS border-color
<html>
<head>
<style>
p.one {
border-style: solid;
border-color: red;
}
p.two {
border-style: solid;
border-color: #98bf21;
}
</style>
</head>
<body>
<p class="one">This is a solid red border</p>
<p class="two">This is a solid green border</p>
</body>
</html>
The inline element takes the required width only. It doesn't force the line break so the flow of text
doesn't break in inline example.
35
o <span>
o <a>
o <em>
o <b> etc.
<html>
<head>
<style>
p{
display: inline;
}
</style>
</head>
<body>
<p>Hello Javatpoint.com</p>
<p>Java Tutorial.</p>
<p>SQL Tutorial.</p>
<p>HTML Tutorial.</p>
<p>CSS Tutorial.</p>
</body>
</html>
Output:
Hello Javatpoint.com Java Tutorial. SQL Tutorial. HTML Tutorial. CSS Tutorial.
The CSS display block element takes as much as horizontal space as they can.
<html>
<head>
<style>
p{
display: block;
}
</style>
</head>
<body>
<p>Hello Javatpoint.com</p>
<p>Java Tutorial.</p>
<p>SQL Tutorial.</p>
36
<p>HTML Tutorial.</p>
<p>CSS Tutorial.</p>
</body>
</html>
Output:
Hello Javatpoint.com
Java Tutorial.
SQL Tutorial.
HTML Tutorial.
CSS Tutorial.
CSS Float
It is used to push an element to the left or right, allowing other element to wrap around it.
after the floating elements which flow around it. both, none, inherit
float It specifies whether the box should float or not. left, right, none,
inherit
Value Description
37
<html>
<head>
<style>
img {
float: right;
}
</style>
</head>
<body>
<p>The following paragraph contains an image with style
<b>float:right</b>. The result is that the image will float to the right in the paragraph.</p>
<img src="a.jpeg" alt="Good Morning Friends"/>
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
This is some text. This is some text. This is some text.
</p>
</body>
</html>
CSS Font
By the use of CSS font property you can change the text size, color, style and more.
EXAMPLES-
body {
font-size: 100%;
}
h1 { color: red; }
h1 { font-family: sans-serif; }
h2 { font-family: serif; }
<p style="font-size:xx-small;"> This font size is extremely small.</p>
<p style="font-size:x-small;"> This font size is extra small</p>
<p style="font-size:small;"> This font size is small</p>
<p style="font-size:medium;"> This font size is medium. </p>
<p style="font-size:large;"> This font size is large. </p>
38
<p style="font-size:x-large;"> This font size is extra large. </p>
<p style="font-size:xx-large;"> This font size is extremely large. </p>
<p style="font-size:smaller;"> This font size is smaller. </p>
<p style="font-size:larger;"> This font size is larger. </p>
<p style="font-size:200%;"> This font size is set on 200%. </p>
<p style="font-size:20px;"> This font size is 20 pixels. </p>
EXAMPLE-2
<style>
body {
font-size: 100%;
}
h2 { font-style: italic; }
h3 { font-style: oblique; }
h4 { font-style: normal; }
}
</style>
CSS word wrap property is used to break the long words and wrap onto the next line.
This property is used to prevent overflow when an unbreakable string is too long to fit in the
containing box.
39
CSS Word Wrap Values
Value Description
<html>
<head>
<style>
p.test {
width: 11em;
background-color: #00ffff;
border: 1px solid #000000;
padding:10px;
word-wrap: break-word;
}
</style>
</head>
<body>
<p class="test"> In this paragraph, there is a very long word:
iamsooooooooooooooooooooooooooooooolongggggggggggggggg.The long word will break and wrap to
the next line.</p>
</body>
</html>
padding
The padding properties specify the width of the padding area of a box.
[Syntax]
40
XHTML - Introduction
XHTML stands for EXtensible HyperText Markup Language.
XHTML defines quality standard for your webpages.easily maintain, edit, convert and format your
document in the long run.
XHTML syntax is very similar to HTML syntax and almost all the valid HTML elements are valid in
XHTML as well.
HTML vs XHTML
There are some changes in XHTML as compared to HTML. These changes can be categorized in
three parts:
o The xmlns attribute in <html> is mandatory and must specify the xml namespace for the
document.
o <html>, <head>, <title>, and <body> are mandatory with their respective closing tags.
41
XHTML Syntax
XHTML syntax is very similar to HTML syntax and all the valid HTML elements are also valid in
XHTML. But XHTML is case sensitive so you have to pay a bit extra attention while writing an
XHTML document to make your HTML document compliant to XHTML.
You must remember the following important points while writing a new XHTML document or
converting existing HTML document into XHTML document:
XHTML is case-sensitive markup language. So, all the XHTML tags and attributes must be written
in lower case.
42
<!-- Valid in XHTML-->
<img src="/images/xhtml.gif" />
3.Attribute Quotes
4.Attribute Minimization
XHTML doesn't allow you to minimize attributes. You have to explicitly state the attribute and its
value.
5.The id Attribute
In XHTML, the language attribute of script tag is deprecated so you have to use type attribute
instead of this.
43
<!-- Valid in XHTML -->
<script type="text/JavaScript">
document.write("Hello XHTML!");
</script>
7.Element Prohibitions
The following elements are not allowed to have any other element inside them.
Element Prohibition
<pre> It must not contain the <img>, <object>, <big>, <small>, <sub>, or <sup>
elements.
<button> It must not contain the <input>, <select>, <textarea>, <label>, <button>,
<form>, <fieldset>, <iframe> or <isindex> elements.
8.Empty Elements
They include a space before the trailing / and > of empty elements. For example, <br />, <hr />,
and <img src="/html/xhtml.gif" alt="xhtml" />.
XHTML Doctypes
There are three types of Document Type Definitions (DTDs). The easiest and most commonly used
is the XHTML Transitional document.
o Strict
o Transitional
o Frameset
It is recommended to use when you want to use Cascading Style Sheet (CSS) strictly and avoiding
to write most of the XHTML attributes.
44
Add the following DTD at the top of your XHTML document.
Syntax:
It is recommended to use when you want to use many XHTML attributes as well as few Cascading
Style Sheet (CSS) properties.
Syntax:
It is recommended to use when you want to use HTML Frames to partition the browser window
into two or more frames.
45