Your Ad Here

   
  Welcome to online books
  HTML BEGINNERS
 

Basic HTML Tags

Tag

Description

<html>

Defines an HTML document

<body>

Defines the document's body

<h1> to <h6>

Defines header 1 to header 6

<p>

Defines a paragraph

<br>

Inserts a single line break

<hr>

Defines a horizontal rule

<!-->

Defines a comment

Text Formatting Tags

Tag

Description

<b>

Defines bold text

<big>

Defines big text

<em>

Defines emphasized text 

<i>

Defines italic text

<small>

Defines small text

<strong>

Defines strong text

<sub>

Defines subscripted text

<sup>

Defines superscripted text

<ins>

Defines inserted text

<del>

Defines deleted text

<s>

Deprecated. Use <del> instead

<strike>

Deprecated. Use <del> instead

<u>

Deprecated. Use styles instead

"Computer Output" Tags

Tag

Description

<code>

Defines computer code text

<kbd>

Defines keyboard text 

<samp>

Defines sample computer code

<tt>

Defines teletype text

<var>

Defines a variable

<pre>

Defines preformatted text

<listing>

Deprecated. Use <pre> instead

<plaintext>

Deprecated. Use <pre> instead

<xmp>

Deprecated. Use <pre> instead

 

 

&nbsp; - spaces

INSERT IMAGES

 

 

An image:

<img src="constr4.gif"

width="144" height="50">

 

A moving image:

<img src="hackanm.gif"

width="48" height="48">

 

 

INSERTING IMAGE FROM OTHER FOLDER OR ANOTHER SERVER

 

An image from another folder:

<img src="/images/netscape.gif"

width="33" height="32">

 

<p>

An image from W3Schools:

<img src="http://www.w3schools.com/images/ie.gif" width="73" height="68">

</p>

 

ALIGN IMAGE WITHIN THE TEXT

 

<p>

An image

<img src="hackanm.gif"

align="bottom" width="48" height="48">

in the text

</p>

 

<p>

An image

<img src ="hackanm.gif"

align="middle" width="48" height="48">

in the text

</p>

 

<p>

An image

<img src ="hackanm.gif"

align="top" width="48" height="48">

in the text

</p>

 

<p>Note that bottom alignment is the default alignment</p>

 

<p>

An image

<img src ="hackanm.gif"

width="48" height="48">

in the text

</p>

 

<p>

<img src ="hackanm.gif"

width="48" height="48">

An image before the text

</p>

 

<p>

An image after the text

<img src ="hackanm.gif"

width="48" height="48">

</p>

 

IMAGES AT LEFT/RIGHT

 

<p>

<img src ="hackanm.gif"

align ="left" width="48" height="48">

A paragraph with an image.

</p>

 

<p>

<img src ="hackanm.gif"

align ="right" width="48" height="48">

A paragraph with an image

</p>

 

ADJUST IMAGES TO DIFFERENT SIZES

 

<p>

<img src="hackanm.gif"

width="20" height="20">

</p>

 

<p>

<img src="hackanm.gif"

width="45" height="45">

</p>

 

<p>

<img src="hackanm.gif"

width="70" height="70">

</p>

 

DISPLAY AN ALTERNATE TEXT FOR AN IMAGE

 

<img src="goleft.gif" alt="Go Left" width="32" height="32">

 

<p>

Text-only browsers cannot display images and will only display the text that is specified in the "alt" attribute for the image. Here, the "alt"-text is "Go Left".</p>

<p>

Note that if you hold the mouse pointer over the image, most browsers will display the "alt"-text.

</p>

 

MAKE AN HYPER LINK FOR AN IMAGE

<p>

You can also use an image as a link:

<a href="lastpage.htm">

<img border="0" src="buttonnext.gif" width="65" height="38">

</a>

</p>

 

CREATE AN IMAGE MAP WITH CLICK ABLE REGIONS

 

<p>

Click on one of the planets to watch it closer:

</p>

 

<img src="planets.gif"

width="145" height="126"

usemap="#planetmap">

 

<map id="planetmap" name="planetmap">

 

<area shape="rect"

coords="0,0,82,126"

alt="Sun"

href="sun.htm">

 

<area shape="circle"

coords="90,58,3"

alt="Mercury"

href="mercur.htm">

 

<area shape="circle"

coords="124,58,8"

alt="Venus"

href="venus.htm">

 

</map>

 

<p>

<b>Note:</b> We use both an <b>id</b> and a <b>name</b> attribute in the map tag

because some versions of Netscape don't understand the id attribute.</p>

 

BACKGROUNDS

 

<body bgcolor="#d0d0d0">//backgnd color

<body background="background.jpg">//image

 

STYLES

 

<head>

<style type="text/css">

h1 {color: red}

h3 {color: blue}

</style>

 

</head>

 

<body>

<h1>This is header 1</h1>

<h3>This is header 3</h3>

</body>

 

</html>

<html>

<head>

<link rel="stylesheet" type="text/css" href="styles.css" >

</head>

 

<body>

<h1>I am formatted with a linked style sheet</h1>

<p>Me too!</p>

</body>

<a href="lastpage.htm"

style="text-decoration:none">

THIS IS A LINK!

</a>

 

HEAD SECTION

<title>The title is not displayed</title>

<html>

<head>

<base target="_blank">

</head>

 

<body>

 

<p>

<a href="http://www.w3schools.com"

target="_blank">This link</a>

will load in a new window because the target attribute is set to "_blank".

</p>

 

<p>

<a href="http://www.w3schools.com">

This link</a>

will also load in a new window even without a target attribute.

</p>

FORMS AND INPUTS

 

<form>

 

First name:

<input type="text" name="firstname">

Male:

<input type="radio" checked="checked"

name="Sex" value="male">

<br>

Female:

<input type="radio"

name="Sex" value="female">

<br>

I have a bike:

<input type="checkbox" name="Bike">

<br>

I have a car:

<input type="checkbox" name="Car">

Username:

<input type="text" name="user">

<br>

Password:

<input type="password" name="password">

</form>

 

DROPDOWN LIST:

 

<form>

<select name="cars">

<option value="volvo">Volvo

<option value="saab">Saab

<option value="fiat">Fiat

<option value="audi">Audi

</select>

</form>

 

 

USING BORDER

 

<fieldset>

<legend>

Health information:

</legend>

<form>

Height <input type="text" size="3">

Weight <input type="text" size="3">

</form>

</fieldset>

FORMS AND INPUTS:

 

  1. TO CREATE BUTTON, TEXT,PASSWAORD:

 

             <input type="button" value="Hello world!">

              Username:

              <input type="text" name="user">

 

              Password:

              <input type="password" name="password">

 

<html>

<body>

 

<form>

<select name="cars">

<option value="volvo">Volvo

<option value="saab">Saab

<option value="fiat">Fiat

<option value="audi">Audi

</select>

</form>

 

</body>

</html>

html>

<body>

 

<form>

Male:

<input type="radio" checked="checked"

name="Sex" value="male">

<br>

Female:

<input type="radio"

name="Sex" value="female">

</form>

 

<p>

When a user clicks on a radio-button, the button becomes checked, and all other buttons with the same name become unchecked

</p>

 

</body>

</html>

 

<html>

<body>

 

<form>

I have a bike:

<input type="checkbox" name="Bike">

<br>

I have a car:

<input type="checkbox" name="Car">

</form>

 

</body>

</html>

<html>

<body>

 

<form>

Username:

<input type="text" name="user">

<br>

Password:

<input type="password" name="password">

</form>

<p>

Note that when you type characters in a password field, the browser displays asterisks or bullets instead of the characters.

</p>

</body>

</html>


 


FRAMES

<html>

 

 

 

<frameset cols="25%,50%,25%">

 

 

 

  <frame src="frame_a.htm">

 

  <frame src="frame_b.htm">

 

  <frame src="frame_c.htm">

 

 

 

</frameset>

 

 

 

</html>

 

<html>

 

 

 

<frameset rows="25%,50%,25%">

 

 

 

  <frame src="frame_a.htm">

 

  <frame src="frame_b.htm">

 

  <frame src="frame_c.htm">

 

 

 

</frameset>

 

 

 

</html>

 

<html>

 

 

 

<frameset rows="50%,50%">

 

 

 

<frame src="frame_a.htm">

 

 

 

<frameset cols="25%,75%">

 

<frame src="frame_b.htm">

 

<frame src="frame_c.htm">

 

</frameset>

 

 

 

</frameset>

 

 

 

</html>

 

 

 

<html>

 

<frameset cols="120,*">

 

 

 

<frame src="tryhtml_contents.htm">

 

<frame src="frame_a.htm"

 

name="showframe">

 

 

 

</frameset>

 

 

 

</html>

 

<html>

 

<body>

 

 

 

<iframe src="default.asp"></iframe>

 

 

 

<p>Some older browsers don't support iframes.</p>

 

<p>If they don't, the iframe will not be visible.</p>

 

 

 

 

 

</body>

 

</html>

 

<html>

 

 

 

<frameset cols="20%,80%">

 

 

 

 <frame src="frame_a.htm">

 

 <frame src="link.htm#C10">

 

 

 

</frameset>

 

 

 

</html>

 

<html>

 

 

 

<frameset cols="180,*">

 

 

 

<frame src="content.htm">

 

<frame src="link.htm" name="showframe">

 

 

 

</frameset>

 

 

 

</html>


 

INSERT IMAGES

 

 

An image:

<img src="constr4.gif"

width="144" height="50">

 

A moving image:

<img src="hackanm.gif"

width="48" height="48">

 

 

INSERTING IMAGE FROM OTHER FOLDER OR ANOTHER SERVER

 

An image from another folder:

<img src="/images/netscape.gif"

width="33" height="32">

 

<p>

An image from W3Schools:

<img src="http://www.w3schools.com/images/ie.gif" width="73" height="68">

</p>

 

ALIGN IMAGE WITHIN THE TEXT

 

<p>

An image

<img src="hackanm.gif"

align="bottom" width="48" height="48">

in the text

</p>

 

<p>

An image

<img src ="hackanm.gif"

align="middle" width="48" height="48">

in the text

</p>

 

<p>

An image

<img src ="hackanm.gif"

align="top" width="48" height="48">

in the text

</p>

 

<p>Note that bottom alignment is the default alignment</p>

 

<p>

An image

<img src ="hackanm.gif"

width="48" height="48">

in the text

</p>

 

<p>

<img src ="hackanm.gif"

width="48" height="48">

An image before the text

</p>

 

<p>

An image after the text

<img src ="hackanm.gif"

width="48" height="48">

</p>

 

IMAGES AT LEFT/RIGHT

 

<p>

<img src ="hackanm.gif"

align ="left" width="48" height="48">

A paragraph with an image.

</p>

 

<p>

<img src ="hackanm.gif"

align ="right" width="48" height="48">

A paragraph with an image

</p>

 

ADJUST IMAGES TO DIFFERENT SIZES

 

<p>

<img src="hackanm.gif"

width="20" height="20">

</p>

 

<p>

<img src="hackanm.gif"

width="45" height="45">

</p>

 

<p>

<img src="hackanm.gif"

width="70" height="70">

</p>

 

DISPLAY AN ALTERNATE TEXT FOR AN IMAGE

 

<img src="goleft.gif" alt="Go Left" width="32" height="32">

 

<p>

Text-only browsers cannot display images and will only display the text that is specified in the "alt" attribute for the image. Here, the "alt"-text is "Go Left".</p>

<p>

Note that if you hold the mouse pointer over the image, most browsers will display the "alt"-text.

</p>

 

MAKE AN HYPER LINK FOR AN IMAGE

<p>

You can also use an image as a link:

<a href="lastpage.htm">

<img border="0" src="buttonnext.gif" width="65" height="38">

</a>

</p>

 

CREATE AN IMAGE MAP WITH CLICK ABLE REGIONS

 

<p>

Click on one of the planets to watch it closer:

</p>

 

<img src="planets.gif"

width="145" height="126"

usemap="#planetmap">

 

<map id="planetmap" name="planetmap">

 

<area shape="rect"

coords="0,0,82,126"

alt="Sun"

href="sun.htm">

 

<area shape="circle"

coords="90,58,3"

alt="Mercury"

href="mercur.htm">

 

<area shape="circle"

coords="124,58,8"

alt="Venus"

href="venus.htm">

 

</map>

 

<p>

<b>Note:</b> We use both an <b>id</b> and a <b>name</b> attribute in the map tag

because some versions of Netscape don't understand the id attribute.</p>

 

BACKGROUNDS

 

<body bgcolor="#d0d0d0">//backgnd color

<body background="background.jpg">//image

 

STYLES

 

<head>

<style type="text/css">

h1 {color: red}

h3 {color: blue}

</style>

 

</head>

 

<body>

<h1>This is header 1</h1>

<h3>This is header 3</h3>

</body>

 

</html>

<html>

<head>

<link rel="stylesheet" type="text/css" href="styles.css" >

</head>

 

<body>

<h1>I am formatted with a linked style sheet</h1>

<p>Me too!</p>

</body>

<a href="lastpage.htm"

style="text-decoration:none">

THIS IS A LINK!

</a>

 

HEAD SECTION

<title>The title is not displayed</title>

<html>

<head>

<base target="_blank">

</head>

 

<body>

 

<p>

<a href="http://www.w3schools.com"

target="_blank">This link</a>

will load in a new window because the target attribute is set to "_blank".

</p>

 

<p>

<a href="http://www.w3schools.com">

This link</a>

will also load in a new window even without a target attribute.

</p>

FORMS AND INPUTS

 

<form>

 

First name:

<input type="text" name="firstname">

Male:

<input type="radio" checked="checked"

name="Sex" value="male">

<br>

Female:

<input type="radio"

name="Sex" value="female">

<br>

I have a bike:

<input type="checkbox" name="Bike">

<br>

I have a car:

<input type="checkbox" name="Car">

Username:

<input type="text" name="user">

<br>

Password:

<input type="password" name="password">

</form>

 

DROPDOWN LIST:

 

<form>

<select name="cars">

<option value="volvo">Volvo

<option value="saab">Saab

<option value="fiat">Fiat

<option value="audi">Audi

</select>

</form>

 

 

USING BORDER

 

<fieldset>

<legend>

Health information:

</legend>

<form>

Height <input type="text" size="3">

Weight <input type="text" size="3">

</form>

</fieldset>

 


<html>

<body>

 

<p>

<a href="lastpage.htm">

This text</a> is a link to a page on

this Web site.

</p>

 

<p>

<a href="http://www.microsoft.com/">

This text</a> is a link to a page on

the World Wide Web.

</p>

 

</body>

</html>

<html>

<body>

<p>

You can also use an image as a link:

<a href="lastpage.htm">

<img border="0" src="buttonnext.gif" width="65" height="38">

</a>

</p>

 

</body>

</html>

<html>

<body>

 

<a href="lastpage.htm" target="_blank">Last Page</a>

 

<p>

If you set the target attribute of a link to "_blank",

the link will open in a new window.

</p>

 

</body>

</html>

<html>

<body>

 

<p>

<a href="#C4">

See also Chapter 4.

</a>

</p>

 

<p>

<h2>Chapter 1</h2>

<p>This chapter explains ba bla bla</p>

 

<h2>Chapter 2</h2>

<p>This chapter explains ba bla bla</p>

 

<h2>Chapter 3</h2>

<p>This chapter explains ba bla bla</p>

 

<a name="C4"><h2>Chapter 4</h2></a>

<p>This chapter explains ba bla bla</p>

 

<h2>Chapter 5</h2>

<p>This chapter explains ba bla bla</p>

 

<h2>Chapter 6</h2>

<p>This chapter explains ba bla bla</p>

 

<h2>Chapter 7</h2>

<p>This chapter explains ba bla bla</p>

 

<h2>Chapter 8</h2>

<p>This chapter explains ba bla bla</p>

 

<h2>Chapter 9</h2>

<p>This chapter explains ba bla bla</p>

 

<h2>Chapter 10</h2>

<p>This chapter explains ba bla bla</p>

 

<h2>Chapter 11</h2>

<p>This chapter explains ba bla bla</p>

 

<h2>Chapter 12</h2>

<p>This chapter explains ba bla bla</p>

 

<h2>Chapter 13</h2>

<p>This chapter explains ba bla bla</p>

 

<h2>Chapter 14</h2>

<p>This chapter explains ba bla bla</p>

 

<h2>Chapter 15</h2>

<p>This chapter explains ba bla bla</p>

 

<h2>Chapter 16</h2>

<p>This chapter explains ba bla bla</p>

 

<h2>Chapter 17</h2>

<p>This chapter explains ba bla bla</p>

 

</body>

</html>

 

<html>

<body>

 

<p>Locked in a frame?</p>

 

<a href="http://www.w3schools.com/"

target="_top">Click here!</a>

 

</body>

</html>

<html>

 

<body>

 

<p>

This is a mail link:

<a href="mailto:someone@microsoft.com?subject=Hello%20again">

Send Mail</a>

</p>

 

<p>

<b>Note:</b> Spaces between words should be replaced by %20 to <b>ensure</b> that the browser will display your text properly.

</p>

 

</body>

</html>



LISTS

 

UNORDERED &ORDERED LIST

 

<html>

<body>

<h4>An Unordered List:</h4>

<ul>

  <li>Coffee</li>

  <li>Tea</li>

</ul>

<h4>An Ordered List:</h4>

<ol>

  <li>Coffee</li>

  <li>Tea</li>

</ol>

</body>

</html>

 

NUMBERED LIST

 

<html>

<body>

<h4>Numbered list:</h4>

<ol>

 <li>Apples</li>

 <li>Bananas</li>

 </ol> 

 

LETTER LIST

 

<h4>Letters list:</h4>

<ol type="A">

 <li>Apples</li>

 <li>Bananas</li>

 <li>Lemons</li>

 <li>Oranges</li>

</ol> 

<h4>Lowercase letters list:</h4>

<ol type="a">

 <li>Apples</li>

 <li>Bananas</li><ol/>

 

<h4>Roman numbers list:</h4>

<ol type="I">

 <li>Apples</li>

 <li>Bananas</li>

</ol> 

 

<h4>Lowercase Roman numbers list:</h4>

<ol type="i">

 <li>Apples</li>

 <li>Bananas</li>

 </ol> 

 

<h4>Disc bullets list:</h4>

<ul type="disc">

 <li>Apples</li>

 <li>Bananas</li>

 </ul> 

 

<h4>Circle bullets list:</h4>

<ul type="circle">

 <li>Apples</li>

 <li>Bananas</li>

</ul> 

 

<h4>Square bullets list:</h4>

<ul type="square">

 <li>Apples</li>

 <li>Bananas</li>

</ul> 

 

NESTED LIST

 

<h4>A nested List:</h4>

<ul>

  <li>Coffee</li>

  <li>Tea

    <ul>

    <li>Black tea</li>

    <li>Green tea</li>

    </ul>

  </li>

  <li>Milk</li>

</ul>

 

 

<h4>A nested List:</h4>

<ul>

  <li>Coffee</li>

  <li>Tea

    <ul>

    <li>Black tea</li>

    <li>Green tea

      <ul>

      <li>China</li>

      <li>Africa</li>

      </ul>

    </li>

    </ul>

  </li>

  <li>Milk</li>

</ul>

 

<h4>A Definition List:</h4>

<dl>

  <dt>Coffee</dt>

  <dd>Black hot drink</dd>

  <dt>Milk</dt>

  <dd>White cold drink</dd>

</dl>

 

 

 

 



TABLES

<html>

<body>

 

<p>

Each table starts with a table tag.

Each table row starts with a tr tag.

Each table data starts with a td tag.

</p>

 

<h4>One column:</h4>

<table border="1">

<tr>

  <td>100</td>

</tr>

</table>

 

<h4>One row and three columns:</h4>

<table border="1">

<tr>

  <td>100</td>

  <td>200</td>

  <td>300</td>

</tr>

</table>

 

<h4>Two rows and three columns:</h4>

<table border="1">

<tr>

  <td>100</td>

  <td>200</td>

  <td>300</td>

</tr>

<tr>

  <td>400</td>

  <td>500</td>

  <td>600</td>

</tr>

</table>

 

</body>

</html>

<html>

<body>

 

<h4>With a normal border:</h4> 

<table border="1">

<tr>

  <td>First</td>

  <td>Row</td>

</tr>  

<tr>

  <td>Second</td>

  <td>Row</td>

</tr>

</table>

 

<h4>With a thick border:</h4> 

<table border="8">

<tr>

  <td>First</td>

  <td>Row</td>

</tr>  

<tr>

  <td>Second</td>

  <td>Row</td>

</tr>

</table>

 

<h4>With a very thick border:</h4> 

<table border="15">

<tr>

  <td>First</td>

  <td>Row</td>

</tr>  

<tr>

  <td>Second</td>

  <td>Row</td>

</tr>

</table>

 

</body>

</html>

<html>

<body>

 

<h4>Table headers:</h4>

<table border="1">

<tr>

  <th>Name</th>

  <th>Telephone</th>

  <th>Telephone</th>

</tr>

<tr>

  <td>Bill Gates</td>

  <td>555 77 854</td>

  <td>555 77 855</td>

</tr>

</table>

 

<h4>Vertical headers:</h4>

<table border="1">

<tr>

  <th>First Name:</th>

  <td>Bill Gates</td>

</tr>

<tr>

  <th>Telephone:</th>

  <td>555 77 854</td>

</tr>

<tr>

  <th>Telephone:</th>

  <td>555 77 855</td>

</tr>

</table>

 

</body>

</html>

<html>

<body>

 

<h4>This table has no borders:</h4>

<table>

<tr>

  <td>100</td>

  <td>200</td>

  <td>300</td>

</tr>

<tr>

  <td>400</td>

  <td>500</td>

  <td>600</td>

</tr>

</table>

 

<h4>And this table has no borders:</h4>

<table border="0">

<tr>

  <td>100</td>

  <td>200</td>

  <td>300</td>

</tr>

<tr>

  <td>400</td>

  <td>500</td>

  <td>600</td>

</tr>

</table>

 

</body>

</html>

<html>

<body>

 

<table border="1">

<tr>

  <td>Some text</td>

  <td>Some text</td>

</tr>

<tr>

  <td></td>

  <td>Some text</td>

</tr>

</table>

 

<p>

As you can see, one of the cells has no border. That is because it is empty. Try to insert a space in the cell. Still it has no border.

</p>

 

<p>

The trick is to insert a no-breaking space in the cell.

</p>

 

<p>No-breaking space is a character entity. If you don't know what a character entity is, read the chapter about it.

</p>

 

<p>The no-breaking space entity starts with an ampersand ("&"),

then the letters "nbsp", and ends with a semicolon (";")

</p>

 

<p>

</p>

 

</body>

</html>

<html>

<body>

 

<h4>

This table has a caption,

and a thick border:

</h4>

 

<table border="6">

<caption>My Caption</caption>

<tr>

  <td>100</td>

  <td>200</td>

  <td>300</td>

</tr>

<tr>

  <td>400</td>

  <td>500</td>

  <td>600</td>

</tr>

</table>

 

</body>

</html>

<html>

<body>

 

<h4>Cell that spans two columns:</h4>

<table border="1">

<tr>

  <th>Name</th>

  <th colspan="2">Telephone</th>

</tr>

<tr>

  <td>Bill Gates</td>

  <td>555 77 854</td>

  <td>555 77 855</td>

</tr>

</table>

 

<h4>Cell that spans two rows:</h4>

<table border="1">

<tr>

  <th>First Name:</th>

  <td>Bill Gates</td>

</tr>

<tr>

  <th rowspan="2">Telephone:</th>

  <td>555 77 854</td>

</tr>

<tr>

  <td>555 77 855</td>

</tr>

</table>

 

</body>

</html>

<html>

<body>

 

<table border="1">

<tr>

  <td>

   <p>This is a paragraph</p>

   <p>This is another paragraph</p>

  </td>

  <td>This cell contains a table:

   <table border="1">

   <tr>

     <td>A</td>

     <td>B</td>

   </tr>

   <tr>

     <td>C</td>

     <td>D</td>

   </tr>

   </table>

  </td>

</tr>

<tr>

  <td>This cell contains a list

   <ul>

    <li>apples</li>

    <li>bananas</li>

    <li>pineapples</li>

   </ul>

  </td>

  <td>HELLO</td>

</tr>

</table>

 

</body>

</html>

<html>

<body>

 

<h4>Without cellpadding:</h4>

<table border="1">

<tr>

  <td>First</td>

  <td>Row</td>

</tr>  

<tr>

  <td>Second</td>

  <td>Row</td>

</tr>

</table>

 

<h4>With cellpadding:</h4>

<table border="1"

cellpadding="10">

<tr>

  <td>First</td>

  <td>Row</td>

</tr>  

<tr>

  <td>Second</td>

  <td>Row</td>

</tr>

</table>

 

</body>

</html>

<html>

<body>

 

<h4>Without cellspacing:</h4>

<table border="1">

<tr>

  <td>First</td>

  <td>Row</td>

</tr>  

<tr>

  <td>Second</td>

  <td>Row</td>

</tr>

</table>

 

<h4>With cellspacing:</h4>

<table border="1"

cellspacing="10">

<tr>

  <td>First</td>

  <td>Row</td>

</tr>  

<tr>

  <td>Second</td>

  <td>Row</td>

</tr>

</table>

 

</body>

</html>

 

html>

<body>

 

<h4>A background color:</h4>

<table border="1"

bgcolor="red">

<tr>

  <td>First</td>

  <td>Row</td>

</tr>  

<tr>

  <td>Second</td>

  <td>Row</td>

</tr>

</table>

 

<h4>A background image:</h4>

<table border="1"

background="bgdesert.jpg">

<tr>

  <td>First</td>

  <td>Row</td>

</tr>  

<tr>

  <td>Second</td>

  <td>Row</td>

</tr>

</table>

 

</body>

</html>

<html>

<body>

 

<h4>Cell backgrounds:</h4> 

<table border="1">

<tr>

  <td bgcolor="red">First</td>

  <td>Row</td>

</tr>  

<tr>

  <td

  background="bgdesert.jpg">

  Second</td>

  <td>Row</td>

</tr>

</table>

 

</body>

</html>

 

<html>

<body>

 

<table width="400" border="1">

 <tr>

  <th align="left">Money spent on....</th>

  <th align="right">January</th>

  <th align="right">February</th>

 </tr>

 <tr>

  <td align="left">Clothes</td>

  <td align="right">$241.10</td>

  <td align="right">$50.20</td>

 </tr>

 <tr>

  <td align="left">Make-Up</td>

  <td align="right">$30.00</td>

  <td align="right">$44.45</td>

 </tr>

 <tr>

  <td align="left">Food</td>

  <td align="right">$730.40</td>

  <td align="right">$650.00</td>

 </tr>

 <tr>

  <th align="left">Sum</th>

  <th align="right">$1001.50</th>

  <th align="right">$744.65</th>

 </tr>

</table>

 

</body>

</html>

 

<html>

<body>

 

<p>

If you see no frames around the tables in these examples, your browser is too old, or does not support it.

</p>

 

<h4>With frame="border":</h4>

<table frame="border">

<tr>

  <td>First</td>

  <td>Row</td>

</tr>  

<tr>

  <td>Second</td>

  <td>Row</td>

</tr>

</table>

 

<h4>With frame="box":</h4>

<table frame="box">

<tr>

  <td>First</td>

  <td>Row</td>

</tr>  

<tr>

  <td>Second</td>

  <td>Row</td>

</tr>

</table>

 

<h4>With frame="void":</h4>

<table frame="void">

<tr>

  <td>First</td>

  <td>Row</td>

</tr>  

<tr>

  <td>Second</td>

  <td>Row</td>

</tr>

</table>

 

<h4>With frame="above":</h4>

<table frame="above">

<tr>

  <td>First</td>

  <td>Row</td>

</tr>  

<tr>

  <td>Second</td>

  <td>Row</td>

</tr>

</table>

 

<h4>With frame="below":</h4>

<table frame="below">

<tr>

  <td>First</td>

  <td>Row</td>

</tr>  

<tr>

  <td>Second</td>

  <td>Row</td>

</tr>

</table>

 

<h4>With frame="hsides":</h4>

<table frame="hsides">

<tr>

  <td>First</td>

  <td>Row</td>

</tr>  

<tr>

  <td>Second</td>

  <td>Row</td>

</tr>

</table>

 

<h4>With frame="vsides":</h4>

<table frame="vsides">

<tr>

  <td>First</td>

  <td>Row</td>

</tr>  

<tr>

  <td>Second</td>

  <td>Row</td>

</tr>

</table>

 

<h4>With frame="lhs":</h4>

<table frame="lhs">

<tr>

  <td>First</td>

  <td>Row</td>

</tr>  

<tr>

  <td>Second</td>

  <td>Row</td>

</tr>

</table>

 

<h4>With frame="rhs":</h4>

<table frame="rhs">

<tr>

  <td>First</td>

  <td>Row</td>

</tr>  

<tr>

  <td>Second</td>

  <td>Row</td>

</tr>

</table>

 

</body>

</html>

 

TABLES

 

// Each table starts with a table tag. Each table row starts with a tr tag.Each table data starts with a td tag.//

 

<h4>One column:</h4>

<table border="1">

<tr>

  <td>100</td>

</tr>

</table>

 

<h4>One row and three columns:</h4>

<table border="1">

<tr>

<td>100</td>

  <td>200</td>

  <td>300</td>

</tr>

</table>

 

<h4>Two rows and three columns:</h4>

<table border="1">

<tr>

  <td>100</td>

  <td>200</td>

  <td>300</td>

</tr>

<tr>

  <td>400</td>

  <td>500</td>

  <td>600</td>

</tr>

</table>

 

 

<h4>With a normal border:</h4> 

<table border="1">

<tr>

  <td>First</td>

  <td>Row</td>

</tr>  

<tr>

  <td>Second</td>

  <td>Row</td>

</tr>

</table>

 

<h4>With a thick border:</h4> 

<table border="8">

<tr>

  <td>First</td>

  <td>Row</td>

</tr>  

<tr>

  <td>Second</td>

  <td>Row</td>

</tr>

</table>

 

<h4>With a very thick border:</h4> 

<table border="15">

<tr>

  <td>First</td>

  <td>Row</td>

</tr>  

<tr>

  <td>Second</td>

  <td>Row</td>

</tr>

</table>

 

 

<h4>Table headers:</h4>

<table border="1">

<tr>

  <th>Name</th>

  <th>Telephone</th>

  <th>Telephone</th>

</tr>

<tr>

  <td>Bill Gates</td>

  <td>555 77 854</td>

  <td>555 77 855</td>

</tr>

</table>

 

<h4>Vertical headers:</h4>

<table border="1">

<tr>

  <th>First Name:</th>

  <td>Bill Gates</td>

</tr>

<tr>

  <th>Telephone:</th>

  <td>555 77 854</td>

</tr>

<tr>

  <th>Telephone:</th>

  <td>555 77 855</td>

</tr>

</table>

 

<h4>This table has no borders:</h4>

<table>

<tr>

  <td>100</td>

  <td>200</td>

  <td>300</td>

</tr>

<tr>

  <td>400</td>

  <td>500</td>

  <td>600</td>

</tr>

</table>

 

<h4>And this table has no borders:</h4>

<table border="0">

<tr>

  <td>100</td>

  <td>200</td>

  <td>300</td>

</tr>

<tr>

  <td>400</td>

  <td>500</td>

  <td>600</td>

</tr>

</table>

 

<table border="1">

<tr>

  <td>Some text</td>

  <td>Some text</td>

</tr>

<tr>

  <td></td>

  <td>Some text</td>

</tr>

</table>

 

 

<p>

The trick is to insert a no-breaking space in the cell.

</p>

 

<p>No-breaking space is a character entity. If you don't know what a character entity is, read the chapter about it.

</p>

 

<p>The no-breaking space entity starts with an ampersand ("&"),

then the letters "nbsp", and ends with a semicolon (";")

</p>

 

<h4>

This table has a caption,

and a thick border:

</h4>

 

>

</tr>

</table><table border="6">

<caption>My Caption</caption>

<tr>

  <td>100</td>

  <td>200</td>

  <td>300</td>

</tr>

<tr>

  <td>400</td>

  <td>500</td>

  <td>600</td

 

<h4>Cell that spans two columns:</h4>

<table border="1">

<tr>

  <th>Name</th>

  <th colspan="2">Telephone</th>

</tr>

<tr>

  <td>Bill Gates</td>

  <td>555 77 854</td>

  <td>555 77 855</td>

</tr>

</table>

 

<h4>Cell that spans two rows:</h4>

<table border="1">

<tr>

  <th>First Name:</th>

  <td>Bill Gates</td>

</tr>

<tr>

  <th rowspan="2">Telephone:</th>

  <td>555 77 854</td>

</tr>

<tr>

  <td>555 77 855</td>

</tr>

</table>

 

<table border="1">

<tr>

  <td>

   <p>This is a paragraph</p>

   <p>This is another paragraph</p>

  </td>

  <td>This cell contains a table:

   <table border="1">

   <tr>

     <td>A</td>

     <td>B</td>

   </tr>

   <tr>

     <td>C</td>

     <td>D</td>

   </tr>

   </table>

  </td>

</tr>

<tr>

  <td>This cell contains a list

   <ul>

    <li>apples</li>

    <li>bananas</li>

    <li>pineapples</li>

   </ul>

  </td>

  <td>HELLO</td>

</tr>

</table>

 

<h4>Without cellpadding:</h4>

<table border="1">

<tr>

  <td>First</td>

  <td>Row</td>

</tr>  

<tr>

  <td>Second</td>

  <td>Row</td>

</tr>

</table>

 

<h4>With cellpadding:</h4>

<table border="1"

cellpadding="10">

<tr>

  <td>First</td>

  <td>Row</td>

</tr>  

<tr>

  <td>Second</td>

  <td>Row</td>

</tr>

</table>

 

<h4>Without cellspacing:</h4>

<table border="1">

<tr>

  <td>First</td>

  <td>Row</td>

</tr>  

<tr>

  <td>Second</td>

  <td>Row</td>

</tr>

</table>

 

<h4>With cellspacing:</h4>

<table border="1"

cellspacing="10">

<tr>

  <td>First</td>

  <td>Row</td>

</tr>  

<tr>

  <td>Second</td>

  <td>Row</td>

</tr>

</table>

 

<h4>A background color:</h4>

<table border="1"

bgcolor="red">

<tr>

  <td>First</td>

  <td>Row</td>

</tr>  

<tr>

  <td>Second</td>

  <td>Row</td>

</tr>

</table>

 

<h4>A background image:</h4>

<table border="1"

background="bgdesert.jpg">

<tr>

  <td>First</td>

  <td>Row</td>

</tr>  

<tr>

  <td>Second</td>

  <td>Row</td>

</tr>

</table>

 

<h4>Cell backgrounds:</h4> 

<table border="1">

<tr>

  <td bgcolor="red">First</td>

  <td>Row</td>

</tr>  

<tr>

  <td

  background="bgdesert.jpg">

  Second</td>

  <td>Row</td>

</tr>

</table>

<table width="400" border="1">

 <tr>

  <th align="left">Money spent on....</th>

  <th align="right">January</th>

  <th align="right">February</th>

 </tr>

 <tr>

  <td align="left">Clothes</td>

  <td align="right">$241.10</td>

  <td align="right">$50.20</td>

 </tr>

 <tr>

  <td align="left">Make-Up</td>

  <td align="right">$30.00</td>

  <td align="right">$44.45</td>

 </tr>

 <tr>

  <td align="left">Food</td>

  <td align="right">$730.40</td>

  <td align="right">$650.00</td>

 </tr>

 <tr>

  <th align="left">Sum</th>

  <th align="right">$1001.50</th>

  <th align="right">$744.65</th>

 </tr>

</table>

 

<p>

If you see no frames around the tables in these examples, your browser is too old, or does not support it.

</p>

 

<h4>With frame="border":</h4>

<table frame="border">

<tr>

  <td>First</td>

  <td>Row</td>

</tr>  

<tr>

  <td>Second</td>

  <td>Row</td>

</tr>

</table>

 

<h4>With frame="box":</h4>

<table frame="box">

<tr>

  <td>First</td>

  <td>Row</td>

</tr>  

<tr>

  <td>Second</td>

  <td>Row</td>

</tr>

</table>

 

<h4>With frame="void":</h4>

<table frame="void">

<tr>

  <td>First</td>

  <td>Row</td>

</tr>  

<tr>

  <td>Second</td>

  <td>Row</td>

</tr>

</table>

 

<h4>With frame="above":</h4>

<table frame="above">

<tr>

  <td>First</td>

  <td>Row</td>

</tr>  

<tr>

  <td>Second</td>

  <td>Row</td>

</tr>

</table>

 

<h4>With frame="below":</h4>

<table frame="below">

<tr>

  <td>First</td>

  <td>Row</td>

</tr>  

<tr>

  <td>Second</td>

  <td>Row</td>

</tr>

</table>

 

<h4>With frame="hsides":</h4>

<table frame="hsides">

<tr>

  <td>First</td>

  <td>Row</td>

</tr>  

<tr>

  <td>Second</td>

  <td>Row</td>

</tr>

</table>

 

<h4>With frame="vsides":</h4>

<table frame="vsides">

<tr>

  <td>First</td>

  <td>Row</td>

</tr>  

<tr>

  <td>Second</td>

  <td>Row</td>

</tr>

</table>

 

<h4>With frame="lhs":</h4>

<table frame="lhs">

<tr>

  <td>First</td>

  <td>Row</td>

</tr>  

<tr>

  <td>Second</td>

  <td>Row</td>

</tr>

</table>

 

<h4>With frame="rhs":</h4>

<table frame="rhs">

<tr>

  <td>First</td>

  <td>Row</td>

  <td>Second</td>

  <td>Row</td>

</tr>

</table>

 
 
  Today, there have been 8 visitors (15 hits) on this page!  
 
This website was created for free with Own-Free-Website.com. Would you also like to have your own website?
Sign up for free