Web Pages
03:18What is java
Java is a programming language originally developed by James Gosling at Sun Microsystems (which has since merged into 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 it has fewer low-level facilities than either of them. 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" (WORA), meaning that code that runs on one platform does not need to be recompiled to run on another. Java is as of 2012 one of the most popular programming languages in use, particularly for client-server web applications, with a reported 10 million users.[10][11]
The original and reference implementation Java compilers, virtual machines, and class libraries were developed by Sun from 1991 and first released in 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 and GNU Classpath.
why we use java
Java is a programming language and computing platform first released by Sun Microsystems in 1995. It is the underlying technology that powers state-of-the-art programs including utilities, games, and business applications. Java runs on more than 850 million personal computers worldwide, and on billions of devices worldwide, including mobile and TV devices.
Why do I need Java?
There are lots of applications and websites that won't work unless you have Java installed, and more are created every day. Java is fast, secure, and reliable. From laptops to datacenters, game consoles to scientific supercomputers, cell phones to the Internet, Java is everywhere!
Why do I need Java?
There are lots of applications and websites that won't work unless you have Java installed, and more are created every day. Java is fast, secure, and reliable. From laptops to datacenters, game consoles to scientific supercomputers, cell phones to the Internet, Java is everywhere!
Usage
Java technology is a high-level programming and a platform independent language. Java is designed to work in the distributed environment on the Internet. Java has a GUI features that provides you better "look and feel" over the C++ language, moreover it is easier to use than C++ and works on the concept of object-oriented programming model. Java enable us to play online games, video, audio, chat with people around the world, Banking Application, view 3D image and Shopping Cart. Java find its extensive use in the intranet applications and other e-business solutions that are the grassroots of corporate computing. Java , regarded as the most well described and planned language to develop an applications for the Web.
Java is a well known technology which allows you for software designed and written only once for an "virtual machine" to run on a different computers, supports various Operating System like Windows PCs, Macintoshes, and Unix computers. On the web aspect, Java is popular on web servers, used by many of the largest interactive websites. Java is used to create standalone applications which may run on a single computer or in distributed network. It is also be used to create a small application program based on applet, which is further used for Web page. Applets make easy and possible to interact with the Web page.
HyperText Markup Language (HTML) is the main markup language for displaying web pages and other information that can be displayed in a web browser. HTML is written in the form of HTML elements consisting of tags enclosed in angle brackets (like
HTML Layout
HTML Page Layouts
Web page layout is very important to give better look to your website. You should design your webpage layout very carefully.
You may have noticed that there are many websites which have put their content in multiple columns - they are formatted like a magazine or newspaper. This is easily achieved by using tables or division or span tags. Sometime you use CSS as well to position various elements or to create backgrounds or colorful look for the pages.
HTML Layout - Using Tables:
The simplest and most popular way of creating layouts is using HTML <table> tag. These tables are arranged in columns and rows, so you can utilize these rows and columns in whatever way you like.For example, the following HTML layout example is achieved using a table with 3 rows and 2 columns - but the header and footer column spans both columns using the colspan attribute:
<table width="100%" border="0"> <tr> <td colspan="2" style="background-color:#CC99FF;"> <h1>This is Web Page Main title</h1> </td> </tr> <tr valign="top"> <td style="background-color:#FFCCFF; width:100px;text-align:top;"> <b>Main Menu</b><br /> HTML<br /> PHP<br /> PERL... </td> <td style="background-color:#eeeeee;height:200px; width:300px;text-align:top;"> Technical and Managerial Tutorials </td> </tr> <tr> <td colspan="2" style="background-color:#CC99FF;"> <center> Copyright © 2007 Tutorialspoint.com </center> </td> </tr> </table> |
|
Multiuple Columns Layouts - Using Tables
You can design your webpage to put your web content in multiple pages. You can keep your content in middle column and you can use left column to use menu and right column can be used to put advertisement or some other stuff. It will be very similar to our site tutorialspoint.com.Here is an example to create three column layout:
<table width="100%" border="0"> <tr valign="top"> <td style="background-color:#FFCCFF;width:20%; text-align:top;"> <b>Main Menu</b><br /> HTML<br /> PHP<br /> PERL... </td> <td style="background-color:#eeeeee;height:200px; width:60%;text-align:top;"> Technical and Managerial Tutorials </td> <td style="background-color:#FFCCFF; width:20%;text-align:top;"> <b>Right Menu</b><br /> HTML<br /> PHP<br /> PERL... </td> </tr> <table> |
|
HTML Layouts - Using DIV, SPAN
The div element is a block level element used for grouping HTML elements. While the div tag is a block-level element, the HTML span element is used for grouping elements at an inline level.Although we can achieve pretty nice layouts with HTML tables, tables weren't really designed as a layout tool. Tables are more suited to presenting tabular data.
You can achieve same result whatever you have achieved using <table> tag in previous example.
<div style="width:100%"> <div style="background-color:#CC99FF;"> <b style="font-size:150%">This is Web Page Main title</b> </div> <div style="background-color:#FFCCFF; height:200px;width:100px;float:left;"> <b>Main Menu</b><br /> HTML<br /> PHP<br /> PERL... </div> <div style="background-color:#eeeeee; height:200px;width:300px;float:left;"> Technical and Managerial Tutorials </div> <div style="background-color:#CC99FF;clear:both"> <center> Copyright © 2007 Tutorialspoint.com </center> </div> </div> |
This is Web Page Main title
Main Menu
HTML PHP PERL...
Technical and Managerial Tutorials
|
Better layout can be created by using DIV, SPAN and CSS. For more information on CSS, please refer CSS Tutorial.
HTML - Tags
The basic structure for all HTML documents is simple and should include the following minimum elements or tags:
Now we will explain each of these tags one by one. In this tutorial you will find the terms element and tag are used interchangeably.
Following two elements appear as direct children of an <html> element:
Each <head> element should contain a <title> element indicating the title of the document, although it may also contain any combination of the following elements, in any order:
A <body> element may contain anything from a couple of paragraphs under a heading to more complicated layouts containing forms and tables.
Most of what you will be learning in this and the following five chapters will be written between the opening <body> tag and closing </body> tag.
- <html> - The main container for HTML pages
- <head> - The container for page header information
- <title> - The title of the page
- <body> - The main body of the page
Now we will explain each of these tags one by one. In this tutorial you will find the terms element and tag are used interchangeably.
The <html> Element:
The <html> element is the containing element for the whole HTML document. Each HTML document should have one <html> and each document should end with a closing </html> tag.Following two elements appear as direct children of an <html> element:
- <head>
- <body>
The <head> Element:
The <head> element is just a container for all other header elements. It should be the first thing to appear after the opening <html> tag.Each <head> element should contain a <title> element indicating the title of the document, although it may also contain any combination of the following elements, in any order:
- The <base> tag is used to areate a "base" url for all links on the page. Check HTML Base tag.
- The <object> tag is designed to include images, JavaScript objects, Flash animations, MP3 files, QuickTime movies and other components of a page. Check HTML Object tag.
- The <link> tag is used to link to an external file, such as a style sheet or JavaScript file. Check HTML Link tag.
- The <style> tag is used to include CSS rules inside the document. Check HTML Style tag.
- The <script> tag is used to include JAVAScript or VBScript inside the document. Check HTML Script tag.
- The <meta> tag includes information about the document such as keywords and a description, which are particularly helpful for search applications. Check HTML Meta tag.
Example:
Following is the example of head tag.<head> <title>HTML Basic tags</title> <meta name="Keywords" content="HTML, Web Pages" /> <meta name="description" content="HTML Basic Tags" /> <base href="http://www.tutorialspoint.com" /> <link rel="stylesheet" type="text/css" href="tp.css" /> <script type="text/javascript"> _uacct = "UA-232293"; urchinTracker(); </script> </head> |
The <title> Element:
You should specify a title for every page that you write inside the <title> element. This element is a child of the <head> element). It is used in several ways:- It displays at the very top of a browser window.
- It is used as the default name for a bookmark in browsers such as IE and Netscape.
- Its is used by search engines that use its content to help index pages.
Example:
Here is the example of using title tag.<head> <title>HTML Basic tags</title> </head> |
The <body> Element:
The <body> element appears after the <head> element and contains the part of the Web page that you actually see in the main browser window, which is sometimes referred to as body content.A <body> element may contain anything from a couple of paragraphs under a heading to more complicated layouts containing forms and tables.
Most of what you will be learning in this and the following five chapters will be written between the opening <body> tag and closing </body> tag.
Example:
Here is the example of using body tag.<body> <p>This is a paragraph tag.</p> </body> |
Putting all together:
Now if we will put all these tags together, it will constitute a complete HTML document as follows:<html> <head> <title>HTML Basic tags</title> <meta name="Keywords" content="HTML, Web Pages" /> <meta name="description" content="HTML Basic Tags" /> <base href="http://www.tutorialspoint.com" /> <link rel="stylesheet" type="text/css" href="tp.css" /> <script type="text/javascript"> _uacct = "UA-232293"; urchinTracker(); </script> </head> <body> <p>This is a paragraph tag.</p> </body> </html> |
-
HTML- Attributes
Attributes are another important part of HTML markup. An attribute is used to define the characteristics of an element and is placed inside the element's opening tag. All attributes are made up of two parts: a name and a value:
- The name is the property you want to set. For example, the <font> element in the example carries an attribute whose name is face, which you can use to indicate which typeface you want the text to appear in.
- The value is what you want the value of the property to be. The first example was supposed to use the Arial typeface, so the value of the face attribute is Arial.
<font face="arial" color="#CC0000">
Core Attributes:
The four core attributes that can be used on the majority of HTML elements (although not all) are:
- id
- title
- class
- style
The id Attribute:
The id attribute can be used to uniquely identify any element within a page ( or style sheet ). There are two primary reasons that you might want to use an id attribute on an element:
- If an element carries an id attribute as a unique identifier it is possible to identify just that element and its content.
- If you have two elements of the same name within a Web page (or style sheet), you can use the id attribute to distinguish between elements that have the same name.
<p id="html">This para explains what is HTML</p> <p id="css">This para explains what is Casecading Style Sheet</p>
- Begin with a letter (A.Z or a.z) and can then be followed by any number of letters, digits (0.9), hyphens, underscores, colons, and periods.
- Remain unique within that document; no two attributes may have the same value within that HTML document.
The title Attribute:
The title attribute gives a suggested title for the element. They syntax for the title attribute is similar as explained for id attribute:
The behavior of this attribute will depend upon the element that carries it, although it is often displayed as a tooltip or while the element is loading.
For example:
<h4 title="Hello HTML!">Titled Heading Tag Example</h4>
Titled Heading Tag Example
The class Attribute:
The class attribute is used to associate an element with a style sheet, and specifies the class of element. You learn more about the use of the class attribute when you will learn Casecading Style Sheet (CSS). So for now you can avoid it.
The value of the attribute may also be a space-separated list of class names. For example:
class="className1 className2 className3"
The style Attribute:
The style attribute allows you to specify CSS rules within the element. For example:
<p style="font-family:arial; color:#FF0000;">Some text...</p>
Internationalization Attributes:
There are three internationalization attributes, which are available to most (although not all) XHTML elements.
- dir
- lang
- xml:lang
The dir Attribute:
The dir attribute allows you to indicate to the browser the direction in which the text should flow.The dir attribute can take one of two values, as you can see in the table that follows:
Value Meaning ltr Left to right (the default value) rtl Right to left (for languages such as Hebrew or Arabic that are read right to left)
<html dir=rtl> <head> <title>Display Directions</title> </head> <body> This is how IE 5 renders right-to-left directed text. </body> </html>
The lang Attribute:
The lang attribute allows you to indicate the main language used in a document, but this attribute was kept in HTML only for backwards compatibility with earlier versions of HTML. This attribute has been replaced by the xml:lang attribute in new XHTML documents.
When included within the <html> tag, the lang attribute specifies the language you've generally used within the document. When used within other tags, the lang attribute specifies the language you used within that tag's content. Ideally, the browser will use lang to better render the text for the user.
The values of the lang attribute are ISO-639 standard two-character language codes.Check HTML Language Codes: ISO 639 for a complete list of language codes.
Example:
<html lang=en> <head> <title>English Language Page</title> </head> <body> This page is using English Language </body> </html>
The xml:lang Attribute:
The xml:lang attribute is the XHTML replacement for the lang attribute. The value of the xml:lang attribute should be an ISO-639 country code as mentioned in previous section.
Generic Attributes:
Here's a table of some other attributes that are readily usable with many of HTML's tags.
Attribute Options Function align right, left, center Horizontally aligns tags valign top, middle, bottom Vertically aligns tags within an HTML element. bgcolor numeric, hexidecimal, RGB values Places a background color behind an element background URL Places an background image behind an element id User Defined Names an element for use with Cascading Style Sheets. class User Defined Classifies an element for use with Cascading Style Sheets. width Numeric Value Specifies the width of tables, images, or table cells. height Numeric Value Specifies the height of tables, images, or table cells. title User Defined "Pop-up" title for your elements.
For a complete list of HTML Tags and related attributes please check reference to HTML Tags List.
-
HTML - List
You can list out your items, subjects or menu in the form of a list. HTML gives you three different types of lists.
- <ul> - An unordered list. This will list items using bullets
- <ol> - A ordered list. This will use different schemes of numbers to list your items
- <dl> - A definition list. This is arrange your items in the same way as they are arranged in a dictionary.
HTML Unordered Lists:
An unordered list is a collection of related items that have no special order or sequence. The most common unordered list you will find on the Web is a collection of hyperlinks to other documents.
This list is created by using <ul> tag. Each item in the list is marked with a butllet. The bullet itself comes in three flavors: squares, discs, and circles. The default bullet displayed by most web browsers is the traditional full disc.
One Movie list is given below:
<center> <h2>Movie List</h2> </center> <ul> <li>Ram Teri Ganga Meli</li> <li>Mera Naam Jocker</li> <li>Titanic</li> <li>Ghost in the ship</li> </ul>
Movie List
- Ram Teri Ganga Meli
- Mera Naam Jocker
- Titanic
- Ghost in the ship
<ul type="square"> <ul type="disc"> <ul type="circle">
<ul type="square"> <ul type="disc"> <ul type="circle"> - Hindi
- English
- Maths
- Physics
- Hindi
- English
- Maths
- Physics
- Hindi
- English
- Maths
- Physics
HTML Ordered Lists:
The typical browser formats the contents of an ordered list just like an unordered list, except that the items are numbered instead of bulleted. The numbering starts at one and is incremented by one for each successive ordered list element tagged with <li>
This list is created by using <ol> tag. Each item in the list is marked with a number.
One Movie list is given below:
<center> <h2>Movie List</h2> </center> <ol> <li>Ram Teri Ganga Meli</li> <li>Mera Naam Jocker</li> <li>Titanic</li> <li>Ghost in the ship</li> </ol>
Movie List
- Ram Teri Ganga Meli
- Mera Naam Jocker
- Titanic
- Ghost in the ship
<ol type="I"> - Upper-Case Numerals. <ol type="i"> - Lower-Case Numerals. <ol type="a"> - Lower-Case Letters. <ol type="A"> - Upper-Case Letters.
<ol type="I"> <ol type="i"> <ol type="a"> <ol type="A"> - Hindi
- English
- Maths
- Physics
- Hindi
- English
- Maths
- Physics
- Hindi
- English
- Maths
- Physics
- Hindi
- English
- Maths
- Physics
<center> <h2>Movie List</h2> </center> <ol start="5"> <li>Ram Teri Ganga Meli</li> <li>Mera Naam Jocker</li> <li>Titanic</li> <li>Ghost in the ship</li> </ol>
Movie List
- Ram Teri Ganga Meli
- Mera Naam Jocker
- Titanic
- Ghost in the ship
HTML Definition Lists:
HTML and XHTML also support a list style entirely different from the ordered and unordered lists we have discussed so far - definition lists . Like the entries you find in a dictionary or encyclopedia, complete with text, pictures, and other multimedia elements, the Definition List is the ideal way to present a glossary, list of terms, or other name/value list.
Definition List makes use of following three tags.
- <dl> - Defines the start of the list
- <dt> - A term
- <dd> - Term definition
- </dl> - Defines the end of the list
<dl> <dt><b>HTML</b></dt> <dd>This stands for Hyper Text Markup Language</dd> <dt><b>HTTP</b></dt> <dd>This stands for Hyper Text Transfer Protocol</dd> </dl>
- HTML
- This stands for Hyper Text Markup Language
- HTTP
- This stands for Hyper Text Transfer Protocol
Appropriate List Usage:
Following are just a suggestion and there is no hard and fast rule to use them:
Use unordered lists for:
- Link collections
- Short, nonsequenced groups of text
- Emphasizing the high points of a presentation
- Tables of contents
- Sets of sequential sections of text
- Assigning numbers to short phrases that can be referenced elsewhere
- Glossaries
- Custom bullets - make the item after the <dt> tag an icon-sized bullet image)
- Any list of name/value pairs
-
HTML - Forms
HTML Forms are required when you want to collect some data from the site visitor. For example registration information: name, email address, credit card, etc.
A form will take input from the site visitor and then will post your back-end application such as CGI, ASP Script or PHP script etc. Then your back-end application will do required processing on that data in whatever way you like.
Form elements are like text fields, textarea fields, drop-down menus, radio buttons, checkboxes, etc. which are used to take information from the user.
A simple syntax of using <form> is as follows:
<form action="back-end script" method="posting method"> form elements like input, textarea etc. </form>
- name: This is the name of the form.
- action: Here you will specify any script URL which will receive uploaded data.
- method: Here you will specify method to be used to upload data. It can take various values but most frequently used are GET and POST.
- target: It specifies the target page where the result of the script will be displayed. It takes values like _blank, _self, _parent etc.
- enctype: You can use the enctype attribute to specify how the browser encodes the data before it sends it to the server. Possible values are like:
- application/x-www-form-urlencoded - This is the standard method most forms use. It converts spaces to the plus sign and non-alphanumeric characters into the hexadecimal code for that character in ASCII text.
- mutlipart/form-data - This allows the data to be sent in parts, with each consecutive part corresponding the a form control, in the order they appear in the form. Each part can have an optional content-type header of its own indicating the type of data for that form control.
There are different types of form controls that you can use to collect data from a visitor to your site.
- Text input controls
- Buttons
- Checkboxes and radio buttons
- Select boxes
- File select boxes
- Hidden controls
- Submit and reset button
HTML Forms - Text Input Controls:
There are actually three types of text input used on forms:
- Single-line text input controls: Used for items that require only one line of user input, such as search boxes or names. They are created using the <input> element.
- Password input controls: Single-line text input that mask the characters a user enters.
- Multi-line text input controls: Used when the user is required to give details that may be longer than a single sentence. Multi-line input controls are created with the <textarea> element.
Single-line text input controls:
Single-line text input controls are created using an <input> element whose type attribute has a value of text.
Here is a basic example of a single-line text input used to take first name and last name:
<form action="/cgi-bin/hello_get.cgi" method="get"> First name: <input type="text" name="first_name" /> <br> Last name: <input type="text" name="last_name" /> <input type="submit" value="submit" /> </form>
- type: Indicates the type of input control you want to create. This element is also used to create other form controls such as radio buttons and checkboxes.
- name: Used to give the name part of the name/value pair that is sent to the server, representing each form control and the value the user entered.
- value: Provides an initial value for the text input control that the user will see when the form loads.
- size: Allows you to specify the width of the text-input control in terms of characters.
- maxlength: Allows you to specify the maximum number of characters a user can enter into the text box.
Password input controls::
This is also a form of single-line text input controls are created using an <input> element whose type attribute has a value of password.
Here is a basic example of a single-line password input used to take user password:
<form action="/cgi-bin/hello_get.cgi" method="get"> Login : <input type="text" name="login" /> <br> Password: <input type="text" name="password" /> <input type="submit" value="submit" /> </form>
Multiple-Line Text Input Controls:
If you want to allow a visitor to your site to enter more than one line of text, you should create a multiple-line text input control using the <textarea> element.
Here is a basic example of a multi-line text input used to take item description:
<form action="/cgi-bin/hello_get.cgi" method="get"> Description : <br /> <textarea rows="5" cols="50" name="description"> Enter description here... </textarea> <input type="submit" value="submit" /> </form>
- name: The name of the control. This is used in the name/value pair that is sent to the server.
- rows: Indicates the number of rows of text area box.
- cols: Indicates the number of columns of text area box.
HTML Forms - Creating Button:
There are various ways in HTML to create clickable buttons. You can create clickable button using <input> tag.
When you use the <input> element to create a button, the type of button you create is specified using the type attribute. The type attribute can take the following values:
- 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.
<form action="http://www.example.com/test.asp" method="get"> <input type="submit" name="Submit" value="Submit" /> <br /><br /> <input type="reset" value="Reset" /> <input type="button" value="Button" /> </form>
<form action="http://www.example.com/test.asp" method="get"> <input type="image" name="imagebutton" src="URL" /> </form>
You can use <button> element to create various buttons. Here is the syntax:
<form action="http://www.example.com/test.asp" method="get"> <button type="submit">Submit</button> <br /><br /> <button type="reset"> Reset </button> <button type="button"> Button </button> </form>
HTML Forms - Checkboxes Control:
Checkboxes are used when more than one option is required to be selected. They are created using <input> tag as shown below.
Here is example HTML code for a form with two checkboxes
<form action="/cgi-bin/checkbox.cgi" method="get"> <input type="checkbox" name="maths" value="on"> Maths <input type="checkbox" name="physics" value="on"> Physics <input type="submit" value="Select Subject" /> </form>
- type: Indicates that you want to create a checkbox.
- name: Name of the control.
- value: The value that will be used if the checkbox is selected. More than one checkbox should share the same name only if you want to allow users to select several items from the same list.
- checked: Indicates that when the page loads, the checkbox should be selected.
HTML Forms - Raidobox Control:
Radio Buttons are used when only one option is required to be selected. They are created using <input> tag as shown below:
Here is example HTML code for a form with two radio button:
<form action="/cgi-bin/radiobutton.cgi" method="post"> <input type="radio" name="subject" value="maths" /> Maths <input type="radio" name="subject" value="physics" /> Physics <input type="submit" value="Select Subject" /> </form>
- type: Indicates that you want to create a radiobox.
- name: Name of the control.
- value: Used to indicate the value that will be sent to the server if this option is selected.
- checked: Indicates that this option should be selected by default when the page loads.
HTML Forms - Select box Control:
Drop Down Box is used when we have many options available to be selected but only one or two will be selected..
Here is example HTML code for a form with one drop down box
<form action="/cgi-bin/dropdown.cgi" method="post"> <select name="dropdown"> <option value="Maths" selected>Maths</option> <option value="Physics">Physics</option> </select> <input type="submit" value="Submit" /> </form>
- name: This is the name for the control.
- size: This can be used to present a scrolling list box.
- multiple: If set to "multiple" then allows a user to select multiple items from the menu.
- value: The value that is sent to the server if this option is selected.
- selected: Specifies that this option should be the initially selected value when the page loads.
- label: An alternative way of labeling options.
HTML Forms - File Select Boxes:
If you want to allow a user to upload a file to your web site from his computer, you will need to use a file upload box, also known as a file select box. This is also created using the <input> element.
Here is example HTML code for a form with one file select box
<form action="/cgi-bin/hello_get.cgi" method="post" name="fileupload" enctype="multipart/form-data"> <input type="file" name="fileupload" accept="image/*" /> </form>
HTML Forms - Hidden Controls:
If you will want to pass information between pages without the user seeing it. Hidden form controls remain part of any form, but the user cannot see them in the Web browser. They should not be used for any sensitive information you do not want the user to see because the user could see this data if she looked in the source of the page.
Following hidden form is being used to keep current page number. When a user will click next page then the value of hidden form will be sent to the back-end application and it will decide which page has be displayed next.
<form action="/cgi-bin/hello_get.cgi" method="get" name="pages"> <p>This is page 10</p> <input type="hidden" name="pgaenumber" value="10" /> <input type="submit" value="Next Page" /> </form>
HTML Forms - Submit and Reset Button:
These are special buttons which can be created using <input> When submit button is clicked then Forms data is submitted to the back-end application. When reset button is clicked then all the forms control are reset to default state.
You already have seen submit button above, we will give one reset example here:
<form action="/cgi-bin/hello_get.cgi" method="get"> First name: <input type="text" name="first_name" /> <br> Last name: <input type="text" name="last_name" /> <input type="submit" value="Submit" /> <input type="reset" value="Reset" /> </form>
-
HTML - Styles
Style sheets describe how documents are presented on screens, in print, or perhaps how they are pronounced. W3C has actively promoted the use of style sheets on the Web since the Consortium was founded in 1994.
Cascading Style Sheets (CSS) is a style sheet mechanism that has been specifically developed to meet the needs of Web designers and users.
With CSS, you can specify a number of style properties for a given HTML element. Each property has a name and a value, separated by a colon (:). Each property declaration is separated by a semi-colon (;).
<p style="color:red;font-size:24px;">Using Style Sheet Rules</p>
Using Style Sheet Rules
External Style Sheet:
If you have to give same look and feel to many pages then it is a good idea to keep all the style sheet rules in a single style sheet file and include this file in all the HTML pages. You can incluse a style sheet file into HTML document using <link> element. Below is an example:
<head> <link rel="stylesheet" type="text/css" href="yourstyle.css"> </head>
Internal Style Sheet:
If you want to apply Style Sheet rules to a single document only then you can include those rules into that document only. Below is an example:
<head> <style type="text/css"> body{background-color: pink;} p{color:blue; 20px;font-size:24px;} </style> </head>
Inline Style Sheet:
You can apply style sheet rules directly to any HTML element. This should be done only when you are interested to make a particular change in any HTML element only. To use inline styles you use the style attribute in the relevant tag. Below is an example:
<p style="color:red;font-size:24px;">Using Style Sheet Rules</p>
Using Style Sheet Rules
-
HTML - Scripts
A script is a small piece of program that can add interactivity to your website. For example, a script could generate a pop-up alert box message, or provide a dropdown menu. This script could be Javascript or VBScript.
You can write your Event Handlers using any of the scripting language and then you can trigger those functions using HTML attributes.
There are two ways of using a style sheet in an HTML document:
External Script:
If you have to use a single script functionality among many HTML pages then it is a good idea to keep that function in a single script file and then include this file in all the HTML pages. You can incluse a style sheet file into HTML document using <script> element. Below is an example:
<head> <script src="yourfile.js" type="text/javascript" /> </head>
Internal Script:
You can write your script code directly into your HTML document. Usually we keep script code in header of the document using <script> tag, otherwise there is no restriction and you can put your source code anywhere in the document. You can specify whether to make a script run automatically (as soon as the page loads), or after the user has done something (like click on a link). Below is an example this would write a Hello Javascript! message as soon as the page loads.:
<head> <title>Internal Script</title> </head> <body> <script type="text/javascript"> document.write("Hello Javascript!") </script> </body>
Advertisements
Writing Event Handler:
It is very easy to write an event handler. Following example explains how to write an event handler. Let's write one simple function myAlert in the header of the document. We will call this function when any user will bring mouse over a paragraph written in the example.
<head> <title>Event Handler Example t</title> <script type="text/javascript"> function myAlert() { alert("I am an event handler...."); return; } </script> </head> <body> <span onmouseover="myAlert();"> Bring your mouse here to see an alert </span> </body>
AdvertisementsBring your mouse here to see an alert
Hide Scripts from Older Browsers
Athough most (if not all) browsers these days support scripts, some older browsers don't. If a browser doesn't support JavaScript, instead of running your script, it would display the code to the user. To prevent this from happening, you can simply place HTML comments around the script. Older browsers will ignore the script, while newer browsers will run it.
JavaScript Example: <script type="text/javascript"> <!-- document.write("Hello Javascript!"); //--> </script> VBScript Example: <script type="text/vbscript"> <!-- document.write("Hello VBScript!") '--> </script>
The <noscript> Element:
You can also provide alternative info for users whose browsers don't support scripts and for users who have disabled scripts. You do this using the <noscript> tag.
JavaScript Example: <script type="text/javascript"> <!-- document.write("Hello Javascript!"); //--> </script> <noscript>Your browser does not support Javascript!</noscript> VBScript Example: <script type="text/vbscript"> <!-- document.write("Hello VBScript!") '--> </script> <noscript>Your browser does not support VBScript!</noscript>
Default Scripting Language
You can specify a default scripting language for all your script tags to use. This saves you from having to specify the language everytime you use a script tag within the page. Below is the example:
<meta http-equiv="Content-Script-Type" content="text/JavaScript" />
-
HTML - Images
Images are very important to beautify as well as to depicts many concepts on your web page. Its is true that one single image is worth than thuasands of words. So as a Web Developer you should have clear understanding on how to use images in your web pages.
Insert Image - The <img> Element:
You will insert any image in your web page by using <img> tag. Following is the simple syntax to use this tag.
<img src="image URL" attr_name="attr_value"...more attributes />
Image Attributes:
Following are most frequently used attributes for <img> tag.
- width: sets width of the image. This will have a value like 10 or 20%etc.
- height: sets height of the image. This will have a value like 10 or 20% etc.
- border: sets a border around the image. This will have a value like 1 or 2 etc.
- src: specifies URL of the image file.
- alt: this is an alternate text which will be displayed if image is missing.
- align: this sets horizontal alignment of the image and takes value either left, right or center.
- valign: this sets vertical alignment of the image and takes value either top, bottom or center.
- hspace: horizontal space around the image. This will have a value like 10 or 20%etc.
- vspace: vertical space around the image. This will have a value like 10 or 20%etc.
- name: name of the image with in the document.
- id: id of the image with in the document.
- style: this will be used if you are using CSS.
- title: specifies a text title. The browser, perhaps flashing the title when the mouse passes over the link.
- ismap and usemap: These attributes for the <img> tag tell the browser that the image is a special mouse-selectable visual map of one or more hyperlinks, commonly known as an image map. We will see how to use these attributes in Image Links chapter.
A Simple Example:
<img src="http://www.tutorialspoint.com/images/html.gif" alt="HTML Tutorial" />
Image Attributes - width, height, title, border and align:
Now let us try to set some more attributes:
<img src="http://www.tutorialspoint.com/images/html.gif"
alt="HTML Tutorial" width="100" height="100"
border="2" align="right" title="HTML Tutorial" />
You can remove an image border by setting border="0" or through CSS by setting img {border:0px;}.
To Become more comfortable with other image attributes - Do Online Practice
Wrapping text around images:
Example 1:
<p>This is the first paragraph that appears above the paragraph with the image!</p>
<p><img src="http://www.tutorialspoint.com/images/html.gif" width="75" height="75" alt="HTML Tutorial" align="right">
The image will appear along the right hand side of the paragraph. As you can see this is very nice for adding a little eye candy that relates to the specified paragraph.</p>
<p>The left and right image-alignment values tell the browser to place an image against the left or right margin, respectively, of the current text flow. The browser then renders subsequent document content in the remaining portion of the flow adjacent to the image. The net result is that the document content following the image gets wrapped around the image. </p>
This is the first paragraph that appears above the paragraph with the image!
The image will appear along the right hand side of the paragraph. As you can see this is very nice for adding a little eye candy that relates to the specified paragraph.
The left and right image-alignment values tell the browser to place an image against the left or right margin, respectively, of the current text flow. The browser then renders subsequent document content in the remaining portion of the flow adjacent to the image. The net result is that the document content following the image gets wrapped around the image.
You can use vspace or hspace attributes if you want to keep some distance between text and image. Let us revise above example:
<p>This is the first paragraph that appears above the paragraph with the image!</p>
<p><img src="http://www.tutorialspoint.com/images/html.gif" vspace="10" hspace="15" width="75" height="75" alt="HTML Tutorial" align="right">
The image will appear along the right hand side of the paragraph. As you can see this is very nice for adding a little eye candy that relates to the specified paragraph.</p>
<p>The left and right image-alignment values tell the browser to place an image against the left or right margin, respectively, of the current text flow. The browser then renders subsequent document content in the remaining portion of the flow adjacent to the image. The net result is that the document content following the image gets wrapped around the image. </p>
This is the first paragraph that appears above the paragraph with the image!
The image will appear along the right hand side of the paragraph. As you can see this is very nice for adding a little eye candy that relates to the specified paragraph.
The left and right image-alignment values tell the browser to place an image against the left or right margin, respectively, of the current text flow. The browser then renders subsequent document content in the remaining portion of the flow adjacent to the image. The net result is that the document content following the image gets wrapped around the image.
Which image format is suitable for you ?
The images in Graphics Interchange Format - GIF format are best used for banners, clip art, and buttons. The main reason for this is that gifs can have a transparent background which is priceless when it comes to web design. On the down side, gifs are usually larger files, not as compressed as a jpeg, which calls for slow load times and large transfer rates. Gifs are also limited to the 256 color scheme.
Ths images in Joint Photographic Experts Group - JPEG format have an unlimited color wheel, and have a high compression rate downsizing your load times and saving hard drive space. JPEGs don't allow for transparent backgrounds, but their size/quality ratio is outstanding. Its best to use JPEG format for photo galleries, or artwork to allow the viewer to catch that extra bit of detail. Avoid Jpegs for graphical design, stick to using them for thumbnails and backgrounds.
The images in Portable Network Graphics - PNG format is an extensible file format for the lossless, portable, well-compressed storage of raster images. PNG provides a patent-free replacement for GIF and can also replace many common uses of TIFF. Indexed-color, grayscale, and truecolor images are supported, plus an optional alpha channel. Sample depths range from 1 to 16 bits. PNG also compresses better than GIF in almost every case (5% to 25% in typical cases).
For more Web Graphics including patterns you can look into Free Web Graphics
-
HTML - Text Links
Click here to download java platforms
Click Here to download java development toolkit
Click Here to download java runtime envirnoment
Web pages can contain links that take you directly to other pages and even specific parts of a given page. These links are known as hyperlinks.
Hyperlinks allow visitors to navigate between Web sites by clicking on words, phrases, and images. Thus you can create hyperlinks using text or images available on your any web page.
In this tutorial you will learn how to create text links between the different pages of your site, links within pages of your sites, and how to link to other sites ( or external sites). If you want to know more about URL then check Understanding URL Tutorial.
Linking Documents - The <a> Element:
A link is specified using the <a> element. This element is called anchor tag as well. Anything between the opening <a> tag and the closing </a> tag becomes part of the link and a user can click that part to reach to the linked document.
Following is the simple syntax to use this tag.
<a href="Document URL" attr_name="attr_value"...more attributes />
Anchor Attributes:
Following are most frequently used attributes for <a> tag.
- href: specifies the URL of the target of a hyperlink. Its value is any valid document URL, absolute or relative, including a fragment identifier or a JavaScript code fragment.
- target: specify where to display the contents of a selected hyperlink. If set to "_blank" then a new window will be opened to display the loaded page, if set to "_top" or "_parent" then same window will be used to display the loaded document, if set to "_self" then loads the new page in current window. By default its "_self".
- name & id: attributes places a label within a document. When that label is used in a link to that document, it is the equivalent of telling the browser to goto that label.
- event: attributes like onClick, onMouseOver etc. are used to trigger any Javascript ot VBscript code.
- title: attribute lets you specify a title for the document to which you are linking. The value of the attribute is
any string, enclosed in quotation marks. The browser might use it when displaying the link, perhaps flashing the
title when the mouse passes over the link.
- accesskey: attribute attribute provides a keyboard shortcut that can be used to activate a link. For example, you could make the T key an access key so that when the user presses either the Alt or Ctrl key on his keyboard (depending on his operating system) along with the T key, the link gets activated.
A Simple Example:
<a href="http://www.tutorialspoint.com/" target="_blank" >TP Home</a> |
<a href="http://www.amrood.com/" target="_self" >AMROOD Home</a> |
<a href="http://www.change-images.com/" target="_top" >Change Images Home</a>
Tutorials Point | AMROOD | Change Images Base Path for Links:
It is not required to give a complete URL for every link. You can get rid of it if you will use <base> tag in your header. This tag is used to give a base path for all the links. So your browser will concatenate given relative path to this base path and will make a complete URL.
For example we have used following base tag in all the pages at tutorialspoint.com:
<head> <base href="http://www.tutorialspoint.com/"> </head>
Linking to a Page Section:
You can create a link to a particular section of a page by using name attribute. Here we will create three links with-in this page itself.
First create a link to reach to the top of this page. Here is the code we have used for the title heading HTML Text Links
<h1>HTML Text Links <a name="top"></a></h1>
<a href="/html/html_text_links.htm#top">Go to the Top</a>
Go to the Top
You can use this type of URL in any other page to reach directly to a particular section.
Setting Link Colors:
You can set colors of your links, active links and visited links using link, alink and vlink attributes of <body> tag. But it is recommended to use CSS to set colors of links, visited links and active links.
Following is the example we have used for our web side tutorialspoint.com
a:link {color:#900B09; background-color:transparent} a:visited {color:#900B09; background-color:transparent} a:active {color:#FF0000; background-color:transparent} a:hover {color:#FF0000; background-color:transparent}
Otherwise you can use <body> tag to set link colors. Here is the syntax.
<body alink="#FF0000" link="#900B09" vlink="#900B09"> ....... </body>
Create Download Links:
You can create text link to make your PDF, or DOC or ZIP files downloadable. This is very simple, you just need to give complete URL of the downloadable file as follows:
<a href="http://www.example.com/file.pdf">Download File</a>
Download File
How To Raise a "File Download" Dialog Box ?
Sometime it is desired that you want to give option where a use will click a link and it will pop up a "File Download" box to the user in stead of displaying actual content. This is very easy and will be achived through HTTP header.
This HTTP header will be different from the header mentioned in previous section.
For example,if you want make a FileName file downloadable from a given link then its syntax will be as follows.
#!/usr/bin/perl # HTTP Header print "Content-Type:application/octet-stream; name=\"FileName\"\r\n"; print "Content-Disposition: attachment; filename=\"FileName\"\r\n\n"; # Actual File Content will go hear. open( FILE, "<FileName" ); while(read(FILE, $buffer, 100) ) { print("$buffer"); }
-
HTML - Image links
Previous chapters has tought you how to create hyper text link using text and how to use images in your web page. Now we will learn how to use images to create hyper links. See example below:
<a href="http://www.tutorialspoint.com/index.htm" target="_self" > <img src="/images/home.gif" alt="Tutorials Point Home" border="0"/> </a>
Mouse-Sensitive Images:
The HTML and XHTML standards provide a feature that lets you embed many different links inside the same image. Clicking different areas of the image causes the browser to link to different target documents. Such mouse-sensitive images known as image maps.
There are two ways to create image maps:
- A server-side image maps: is enabled by the ismap attribute for the <img> tag and requires access to a server and related image-map processing applications.
- A client-side image maps: is created with the usemap attribute for the <img> tag, along with corresponding <map> and <area> tags.
Server-Side Image Maps:
You add an image to an anchor simply by placing an <img> tag within the body of the <a> tag. Make that embedded image into a mouse-sensitive one by adding the ismap attribute to the <img> tag. This special <img> attribute tells the browser that the image is a special map containing more than one link.
When the user clicks some place within the image, the browser passes the coordinates of the mouse pointer along with the URL specified in the <a> tag to the document server. The server uses the mouse-pointer coordinates to determine which document to deliver back to the browser.
When ismap is used, the href attribute of the containing <a> tag must contain the URL of a server application like amap file or cgi script etc. to process the incoming request based on the passed coordinates.
The coordinates of the mouse position are screen pixels counted from the upper-left corner of the image, beginning with (0,0). The coordinates, preceded by a question mark, are added to the end of the URL.
For example, if a user clicks 50 pixels over and 30 pixels down from the upper-left corner of the image displayed from the following link:
<a href="/cgi-bin/logo.map" target="_self" > <img ismap src="/images/html.gif" alt="HTML" border="0"/> </a>
/cgi-bin/logo.map?50,30
NOTE: Converting the coordinates into a specific document is handled by the server side application, either cgi programme or special map files provided by seb server. For more detail Check Using HTML ismap.
Client-Side Image Maps:
Client side image maps are enabled by the usemap attribute for the <img /> tag and defined by special <map> and <area> extension tags.
The image that is going to form the map is inserted into the page using the <img /> element as normal, except it carries an extra attribute called usemap. The value of the usemap attribute is the value of the name attribute on the <map> element, which you are about to meet, preceded by a pound or hash sign.
The <map> element actually creates the map for the image and usually follows directly after the <img /> element. It acts as a container for the <area /> elements that actually define the clickable hotspots. The <map> element carries only one attribute, the name attribute, which is the name that identifies the map. This is how the <img /> element knows which <map> element to use.
The <area> element specifies the shape and the coordinates that define the boundaries of each clickable hotspot. Here's an example from the image map:
<img src=/images/html.gif alt="HTML Map" border="0" usemap="#html"/> <!-- Create Mappings --> <map name="html"> <area shape="circle" coords="154,150,59" href="link1.htm" alt="link 1" target="_self" /> <area shape="poly" coords="272,79,351,79,351,15,486,15,486,218,272,218, 292,166,292,136,270,76" alt="link 2" href="link2.htm" target="_self" /> <area shape="rect" coords="325,224,488,286" alt="link 3" href="link3.htm" target="_self" /> </map>
- rect = x1 , y1 , x2 , y2
- x1 and y1 are the coordinates of the upper left corner of the rectangle; x2 and y2 are the coordinates of the lower right corner. Therefore, a rectangle which goes from 10,5 to 20,25 would have the attribute coords="10,5,20,25". A rectangle which defines the upper-left quarter of an image might use coords="0,0,50%,50%".
- circle = xc , yc , radius
- xc and yc are the coordinates of the center of the circle, and radius is the circle's radius. A circle centered at 200,50 with a radius of 25 would have the attribute coords="200,50,25"; one centered at the image's center and having a diameter of half the image would be defined by coords="50%,50%,25%".
- poly = x1 , y1 , x2 , y2 , x3 , y3 , ... xn , yn
- The various x-y pairs define vertices (points) of the polygon, with a "line" being drawn from one point to the next point. A diamond-shaped polygon with its top point at 20,20 and 40 pixels across at its widest points would have the attribute coords="20,20,40,40,20,60,0,40". A "line" is always drawn from the coordinates of the last point to the coordinates of the first point in order to close the polygon.
To Become more comfortable - Do Online Practice
NOTE: Following image crop utility can help you to identify image cordinates online Image Crop Utility. Just upload your image and click the area to identify cordinates of that area.
-
HTML - Email links
This is very easy to put an HTML email link on your page. But while doing so, you need to put your email address on your web page which can cause a spamming problem for your email account. There are many guys over the internet who can run programs to harvest these types of emails for spamming. So if you are going to put your email link on a public website then you have be prepared for anti-spamming as well.
You can have another option to facilitate people to send you emails. This option is to use HTML forms to take user data and then use CGI script to send an email.
A simple example, check our Contact Us Form. We take user feedback using this form and then we are using one CGI program which is collecting this information and sending email to one given email ID.
You will learn about HTML Forms in HTML Forms and you can learn about CGI in our another tutorial PERL & CGI.
HTML Email Tag:
HTML <a> tag provides you facility to specifiy an email address to send an email. While using <a> tag as an email tag then you will use mailto:email address along with href attribute. Following is the syntax of using mailto instead of using http.
<a href= "mailto:abc@example.com">Send Email</a>
Send Email
This is another risk to use this procedure because if users do not have email client installed on their computer then it would not be possible to send you email.
Default Email Subject and Body:
You can specify a default email subject and email body alongwith your email address. Following is the example to use default subject and body.
<a href="mailto:abc@example.com?subject=Feedback&body=Message"> Send Feedback </a>
Send Feedback
-
Send E-mail in HTML
Click here to download java platforms
Click Here to download java development toolkit
Click Here to download java runtime envirnoment -
Set Frame Inside HTML
Frames divide a browser window into several pieces or panes, each pane containing a separate XHTML/HTML document. One of the key advantages that frames offer is that you can then load and reload single panes without having to reload the entire contents of the browser window. A collection of frames in the browser window is known as a frameset.
The window is divided up into frames in a similar pattern to the way tables are organized: into rows and columns. The simplest of framesets might just divide the screen into two rows, while a complex frameset could use several rows and columns.
There are few drawbacks also you should be aware of with frames are as follows:
- Some browsers do not print well from framesets.
- Some smaller devices cannot cope with frames, often because their screen is not big enough to be divided up.
- Some time your page will be displayed differently on different computers due to different screen resolution.
- The browser's back button might not work as the user hopes.
- There are still few browsers who do not support farme technology.
You also need to learn the <noframes> element, which provides a message for users whose browsers do not support frames.
Now we will discuss these tags in detail one by one.
Creating Frames - The <frameset> Element:
- The <frameset> tag replaces the <body> element in frameset documents.
- The <frameset> tag defines how to divide the window into frames.
- Each frameset defines a set of rows or columns. If you define frames by using rows then horizontal frames are created. If you define frames by using columns then vertical farmes are created.
- The values of the rows/columns indicate the amount of screen area each row/column will occupy.
- Each farme is indicated by <frame> tag and it defines what HTML document to put into the frame.
Example:
Following is the example to create three horizontal frames:
<html> <head> <title>Frames example</title> </head> <frameset rows="10%,80%,10%"> <frame src="/html/top_frame.htm" /> <frame src="/html/main_frame.htm" /> <frame src="/html/bottom_frame.htm" /> <noframes> <body> Your browser does not support frames. </body> </noframes> </frameset> </html>
To become more comfortable - Do Online Practice
The <frameset> Element Attributes:
Following are important attributes of <frameset> and should be known to you to use frameset.
- cols: specifies how many columns are contained in the frameset and the size of each column. You can specify the width of each column in one of four ways:
- Absolute values in pixels. For example to create three vertical frames, use cols="100, 500,100".
- A percentage of the browser window. For example to create three vertical frames, use cols="10%, 80%,10%".
- Using a wildcard symbol. For example to create three vertical frames, use cols="10%, *,10%". In this case wildcard takes remainder of the window.
- As relative widths of the browser window. For example to create three vertical frames, use cols="3*,2*,1*". This is an alternative to percentages. You can use relative widths of the browser window. Here the window is divided into sixths: the first column takes up half of the window, the second takes one third, and the third takes one sixth.
- rows: attribute works just like the cols attribute and can take the same values, but it is used to specify the rows in the frameset. For example to create two horizontal frames, use rows="10%, 90%". You can specify the height of each row in the same way as explained above for columns.
- border: attribute specifies the width of the border of each frame in pixels. For example border="5". A value of zero specifies that no border should be there.
- frameborder: specifies whether a three-dimensional border should be displayed between frames. This attrubute takes value either 1 (yes) or 0 (no). For example frameborder="0" specifies no border.
- framespacing: specifies the amount of space between frames in a frameset. This can take any integer value. For example framespacing="10" means there should be 10 pixels spacing between each frames.
Loading Content - The <frame> Element:
The <frame> element indicates what goes in each frame of the frameset. The <frame> element is always an empty element, and therefore should not have any content, although each <frame> element should always carry one attribute, src, to indicate the page that should represent that frame.
From the above example, lets take small snippet:
<frame src="/html/top_frame.htm" /> <frame src="/html/main_frame.htm" /> <frame src="/html/bottom_frame.htm" />
The <frame> Element Attributes:
Following are important attributes of and should be known to you to use frames.
- src: indicates the file that should be used in the frame. Its value can be any URL. For example, src="/html/top_frame.htm" will load an HTML file avaible in html directory.
- name: attribute allows you to give a name to a frame. It is used to indicate which frame a document should be loaded into. This is especially important when you want to create links in one frame that load pages into a second frame, in which case the second frame needs a name to identify itself as the target of the link.
- frameborder: attribute specifies whether or not the borders of that frame are shown; it overrides the value given in the frameborder attribute on the <frameset> element if one is given, and the possible values are the same. This can take values either 1 (yes) or 0 (no).
- marginwidth: allows you to specify the width of the space between the left and right of the frame's borders and the frame's content. The value is given in pixels. For example marginwidth="10".
- marginheight: allows you to specify the height of the space between the top and bottom of the frame's borders and its contents. The value is given in pixels. For example marginheight="10".
- noresize: By default you can resize any frame by clicking and dragging on the borders of a frame. The noresize attribute prevents a user from being able to resize the frame. For example noresize="noresize".
- scrolling: controls the appearance of the scrollbars that appear on the frame. This takes values either "yes", "no" or "auto". For example scrolling="no" means it should not have scroll bars.
- longdesc: allows you to provide a link to another page containing a long description of the contents of the frame. For example longdesc="framedescription.htm"
Browser Support - The <noframes> Element:
If a user is using any old browser or any browser which does not support frames then <noframes> element should be displayed to the user.
In XHTML you must place a <body> element inside the <noframes> element because the <frameset> element is supposed to replace the <body> element, but if a browser does not understand the <frameset> element it should understand what is inside the <body> element contained in the <noframes> element.
You can put some nice message for your user having old browsers. For example Sorry!! your browser does not support frames.
Frame's name and target attributes:
One of the most popular uses of frames is to place navigation bars in one frame and then load the pages with the content into a separate frame.
As you have already seen, each <frame> element can carry the name attribute to give each frame a name.This name is used in the links to indicate which frame the new page should load into. Consider this very simple example, create following content in index.htm file:
<frameset cols="200, *"> <frame src="/html/menu.htm" name="menu_page" /> <frame src="/html/main.htm" name="main_page" /> </frameset>
Keep some content in main.htm file and the links in the menu.htm file look like this:
<a href="http://www.google.com" target="main_page">Google</a> <br /><br /> <a href="http://www.microsoft.com" target="main_page">Microsoft</a> <br /><br /> <a href="http://news.bbc.co.uk/" target="main_page">BBC News</a>
The target attribute can also take the attribute values listed in the table that follows.
Vlaue Description _self Loads the page into the current frame. _blank Loads a page into a new browser window.opening a new window. _parent Loads the page into the parent window, which in the case of a single frameset is the main browser window. _top Loads the page into the browser window, replacing any current frames.. Inline Frames - The <iframe> Element:
You can define an inline frame with the <iframe> tag. The <iframe> tag is not used within a <frameset> tag. Instead, it appears anywhere in your document. The <iframe> tag defines a rectangular region within the document in which the browser displays a separate document, including scrollbars and borders.
Use the src attribute with <iframe> to specify the URL of the document that occupies the inline frame.
Following is the example to show how to use the <iframe>. This tag is used along with <body> tag:
<body> ...other document content... <iframe src="/html/menu.htm" width="75" height="200" align="right"> Your browser does not support inline frames. To view this <a href="/html/menu.htm">document</a> correctly, you'll need a copy of Internet Explorer or the latest Netscape Navigator. </iframe> ...subsequent document content... </body> |
For inline alignment, use top, middle, or bottom as the value of this attribute. The frame is aligned with the top, middle, or bottom of the adjacent text, respectively. To allow text to flow around the inline frame, use the left or right values for this attribute. The frame is moved to the left or right edge of the text flow, respectively, and the remaining content of the document is flowed around the frame. A value of center places the inline frame in the middle of the display, with text flowing above and below.
HTML File Upload
HTML File Upload is used to show the list of all file, when a user click on browse button A form in an HTML (web page) contain an input element with type="file". This involve one or more files into the submission of form. The file are stored into hard disk of the web server, that is why file input is called" file upload".
Understand with Example
The Tutorial illustrate an example from HTML File Upload. In this code, we create a html page which show you a :In HTML,the type of control used in form is defined by the Type attribute. The default value of Type is text, which enables a a single-line text input field. The size attribute define the number of characters in text field.
Output on the browser is displayed as

Understand with Example
The Tutorial illustrate an example from HTML File Upload. In this code, we create a html page which show you a :In HTML,the type of control used in form is defined by the Type attribute. The default value of Type is text, which enables a a single-line text input field. The size attribute define the number of characters in text field.
<html> <body> <form action="fileinsert.html" method="post"> <p> Enter Your Text (Optional):<br> <input type="text" name="textwrite" size="15"> </p> <p> Specify your File:<br> <input type="file" name="datasize" size="30"> </p> <div> <input type="submit" value="Send"> </div> </form> </body> </html> |

HTML- Comments
Comments are piece of code which is ignored by any web browser. It is good practice to comment your code, especially in complex documents, to indicate sections of a document, and any other notes to anyone looking at the code. Comments help you and others
understand your code.
HTML Comment lines are indicated by the special beginning tag <!-- and ending tag --> placed at the beginning and end of EVERY line to be treated as a comment.
Comments do not nest, and the double-dash sequence "--" may not appear inside a comment except as part of the closing --> tag. You must also make sure that there are no spaces in the start-of-comment string.
For example: Given line is a valid comment in HTML
But following line is not a valid comment and will be displayed by the borwser. This is because there is a space between the left angle bracket and the exclamation mark.
Be careful if you use comments to "comment out" HTML that would otherwise be shown to the user, since some older browsers will still pay attention to angle brackets inside the comment and close the comment prematurely -- so that some of the text that was supposed to be inside the comment mistakenly appears as part of the document.
For example:
Conditional comments work as follows:
For example:
Similarly if you are using Casecading Style Sheet in your HTML code then it is recommended to put that style sheet code inside proper HTML Comments to make old browser works properly.
For example:
NOTE: To become familiar with JAVA Script and Cascading Style Sheet you need to refer different tutorial.
To Become more comfortable - Do Online Practice
HTML Comment lines are indicated by the special beginning tag <!-- and ending tag --> placed at the beginning and end of EVERY line to be treated as a comment.
Comments do not nest, and the double-dash sequence "--" may not appear inside a comment except as part of the closing --> tag. You must also make sure that there are no spaces in the start-of-comment string.
For example: Given line is a valid comment in HTML
<!-- This is commented out --> |
< !-- This is commented out --> |
Multiline Comments:
You have seen how to comment a single line in HTML. You can comment multiple lines by the special beginning tag <!-- and ending tag --> placed before the first line and end of the lastline to be treated as a comment.For example:
<!-- This is a multiline comment <br /> and can span through as many as lines you like. --> |
Conditional Comments :
Conditional comments only work in Explorer on Windows, and are thus excellently suited to give special instructions meant only for Explorer on Windows. They are supported from Explorer 5 onwards, and it is even possible to distinguish between 5.0, 5.5 and 6.0.Conditional comments work as follows:
<!--[if IE 6]> Special instructions for IE 6 here <![endif]--> |
- Their basic structure is the same as an HTML comment (<!-- -->). Therefore all other browsers will see them as normal comments and will ignore them entirely.
- Explorer Windows, though, has been programmed to recognize the special <!--[if IE]> syntax, resolves the if and parses the content of the conditional comment as if it were normal page content.
- Since conditional comments use the HTML comment structure, they can only be included in HTML files, and not in CSS files.
Using Comment tag
There are few browsers who supports <comment> tag to comment a part of code.<p>This is <comment>not</comment> Internet Explorer.</p> |
Commenting Scripts and Style Sheets:
If you are using Java Script or VB Script in your HTML code then it is recommended to put that script code inside proper HTML Comments to make old browser works properly.For example:
<script> <!-- document.write("Hello World!") //--> </script> |
For example:
<style> <!-- img{ border:0px; } //--> </style> |
To Become more comfortable - Do Online Practice
Tag Inside Table in HTML
Tables are very useful to arrange in HTML and they are used very frequently by almost all web developers. Tables are just like spreadsheets and they are made up of rows and columns.
You will create a table in HTML/XHTML by using <table> tag. Inside <table> element the table is written out row by row. A row is contained inside a <tr> tag . which stands for table row. And each cell is then written inside the row element using a <td> tag . which stands for table data.
This will produce following result:
NOTE: In the above example border is an attribute of <table> and it will put border across all the cells. If you do not need a border then you cal use border="0". The border attribute and other attributes also mentione din this session are deprecated and they have been replaced by CSS. So it is recommended to use CSS instead of using any attribute directly.
To Become more comfortable - Do Online Practice
This will produce following result. You can see its making heading as a bold one:
To Become more comfortable - Do Online Practice
NOTE: Each cell must, however, have either a <td> or a <th> element in order for the table to display correctly even if that element is empty.
This will produce following result:
To Become more comfortable - Do Online Practice
This will produce following result:
To Become more comfortable - Do Online Practice
Here is an example of using bgcolor attribute:
This will produce following result:
To Become more comfortable - Do Online Practice
Here is an example of using background attribute:
This will produce following result:
To Become more comfortable - Do Online Practice
This will produce following result:
To Become more comfortable - Do Online Practice
This will produce following result:
The three elements for separating the head, body, and foot of a table are:
This will produce following result:
To Become more comfortable - Do Online Practice
Following is the example of using another table and other tags inside a table cell.
This will produce following result:
You will create a table in HTML/XHTML by using <table> tag. Inside <table> element the table is written out row by row. A row is contained inside a <tr> tag . which stands for table row. And each cell is then written inside the row element using a <td> tag . which stands for table data.
Example:
<table border="1"> <tr> <td>Row 1, Column 1</td> <td>Row 1, Column 2</td> </tr> <tr> <td>Row 2, Column 1</td> <td>Row 2, Column 2</td> </tr> </table> |
|
To Become more comfortable - Do Online Practice
Table Heading - The <th> Element:
Table heading can be defined using <th> element. This tag will be put to replace <td> tag which is used to represent actual data. Normally you will put your top row as table heading as shown below, otherwise you can use <th> element at any place:<table border="1"> <tr> <th>Name</th> <th>Salary</th> </tr> <tr> <td>Ramesh Raman</td> <td>5000</td> </tr> <tr> <td>Shabbir Hussein</td> <td>7000</td> </tr> </table> |
|
NOTE: Each cell must, however, have either a <td> or a <th> element in order for the table to display correctly even if that element is empty.
Table Cellpadding and Cellspacing:
There are two attribiutes called cellpadding and cellspacing which you will use to adjust the white space in your table cell. Cellspacing defines the width of the border, while cellpadding represents the distance between cell borders and the content within. Following is the example:<table border="1" cellpadding="5" cellspacing="5"> <tr> <th>Name</th> <th>Salary</th> </tr> <tr> <td>Ramesh Raman</td> <td>5000</td> </tr> <tr> <td>Shabbir Hussein</td> <td>7000</td> </tr> </table> |
|
Colspan and Rowspan Attributes:
You will use colspan attribute if you want to merge two or more columns into a single column. Similar way you will use rowspan if you want to merge two or more rows. Following is the example:<table border="1"> <tr> <th>Column 1</th> <th>Column 2</th> <th>Column 3</th> </tr> <tr><td rowspan="2">Row 1 Cell 1</td> <td>Row 1 Cell 2</td><td>Row 1 Cell 3</td></tr> <tr><td>Row 2 Cell 2</td><td>Row 2 Cell 3</td></tr> <tr><td colspan="3">Row 3 Cell 1</td></tr> </table> |
|
Tables Backgrounds
You can set table background using of the following two ways:- Using bgcolor attribute - You can set background color for whole table or just for one cell.
- Using background attribute - You can set background image for whole table or just for one cell.
Here is an example of using bgcolor attribute:
<table border="5" bordercolor="green" bgcolor="gray"> <tr> <th>Column 1</th> <th>Column 2</th> <th>Column 3</th> </tr> <tr><td rowspan="2">Row 1 Cell 1</td> <td bgcolor="red">Row 1 Cell 2</td><td>Row 1 Cell 3</td></tr> <tr><td>Row 2 Cell 2</td><td>Row 2 Cell 3</td></tr> <tr><td colspan="3">Row 3 Cell 1</td></tr> </table> |
|
Here is an example of using background attribute:
<table border="1" background="/images/home.gif"> <tr> <th>Column 1</th> <th>Column 2</th> <th>Column 3</th> </tr> <tr><td rowspan="2">Row 1 Cell 1</td> <td bgcolor="red">Row 1 Cell 2</td><td>Row 1 Cell 3</td></tr> <tr><td>Row 2 Cell 2</td><td>Row 2 Cell 3</td></tr> <tr><td colspan="3" background="/images/pattern1.gif"> Row 3 Cell 1 </td></tr> </table> |
|
Table height and width:
You can set a table width and height using width and height attrubutes. You can specify table width or height in terms of integer value or in terms of percentage of available screen area. Following is the example:<table border="1" width="400" height="150"> <tr> <td>Row 1, Column 1</td> <td>Row 1, Column 2</td> </tr> <tr> <td>Row 2, Column 1</td> <td>Row 2, Column 2</td> </tr> </table> |
|
Using Table Caption:
The caption tags will serve as a title or explanation and show up at the top of the table. This tag is depracated in newer version of HTML/XHTML.<table border="1"> <caption>This is the caption</caption> <tr> <td>row 1, column 1</td><td>row 1, columnn 2</td> </tr> </table> |
|
Using a Header, Body, and Footer:
Tables can be divided into three portions: a header, a body, and a foot. The head and foot are rather similar to headers and footers in a word-processed document that remain the same for every page, while the body is the main content of the table.The three elements for separating the head, body, and foot of a table are:
- <thead> - to create a separate table header.
- <tbody> - to indicate the main body of the table.
- <tfoot> - to create a separate table footer.
<table border="1" width="100%"> <thead> <tr> <td colspan="4">This is the head of the table</td> </tr> </thead> <tfoot> <tr> <td colspan="4">This is the foot of the table</td> </tr> </tfoot> <tbody> <tr> <td>Cell 1</td> <td>Cell 2</td> <td>Cell 3</td> <td>Cell 4</td> </tr> <tr> ...more rows here containing four cells... </tr> </tbody> <tbody> <tr> <td>Cell 1</td> <td>Cell 2</td> <td>Cell 3</td> <td>Cell 4</td> </tr> <tr> ...more rows here containing four cells... </tr> </tbody> </table> |
|
Nested Tables:
You can use one table inside another table. Not only tables you can use almost all the tags inside table data tag <td>.Following is the example of using another table and other tags inside a table cell.
<table border="1"> <tr> <td> <table border="1"> <tr> <th>Name</th> <th>Salary</th> </tr> <tr> <td>Ramesh Raman</td> <td>5000</td> </tr> <tr> <td>Shabbir Hussein</td> <td>7000</td> </tr> </table> </td> <td> <ul> <li>This is another cell</li> <li>Using list inside this cell</li> </ul> </td> </tr> <tr> <td>Row 2, Column 1</td> <td>Row 2, Column 2</td> </tr> </table> |
|
0 comments: