HTML: Tables and Forms

BG Java EE Course
BG Java EE Course Manager, Technical Training at BG Java EE Course
HTML – Tables and Forms

Svetlin Nakov
Telerik Corporation
www.telerik.com
Contents
1.   HTML Tables
        Nested Tables
        Cells Width
        Cell Spacing and Padding
        Column and Row Span




                                               2
Contents (2)
2.   HTML Forms
        Form Fields
        Form Controls
            Text field
            Text area
            Select
            Radio button
            Checkbox
            Button
            Image button
                                           3
HTML Tables
HTML Tables
 Tables represent tabular   data
   A table consists of one or several rows
   Each row has one or more columns
 Tables comprised of several core tags:
 <table></table>: begin / end the table
 <tr></tr>: create a table row
 <td></td>: create tabular data (cell)
 Tables are losing
                  favor to <div> and <span>,
 with the CSS revolution
                                                  5
HTML Tables (2)
 Start and end of a table

   <table> ... </table>

 Start and end of a row

   <tr> ... </tr>

 Start and end of a cell in a row

   <td> ... </td>



                                                6
Simple HTML Tables – Example
<table border="1" cellspacing="0" cellpadding="5">
  <tr>
    <td><img src="ppt.gif"></td>
    <td><a href="lecture1.ppt">Lecture 1</a></td>
  </tr>
  <tr>
    <td><img src="ppt.gif"></td>
    <td><a href="lecture2.ppt">Lecture 2</a></td>
  </tr>
  <tr>
    <td><img src="zip.gif"></td>
    <td><a href="lecture2-demos.zip">
       Lecture 2 - Demos</a></td>
  </tr>
</table>
                                                     7
Simple HTML Tables – Example (2)
<table border="1" cellspacing="0" cellpadding="5">
  <tr>
    <td><img src="ppt.gif"></td>
    <td><a href="lecture1.ppt">Lecture 1</a></td>
  </tr>
  <tr>
    <td><img src="ppt.gif"></td>
    <td><a href="lecture2.ppt">Lecture 2</a></td>
  </tr>
  <tr>
    <td><img src="zip.gif"></td>
    <td><a href="lecture2-demos.zip">
       Lecture 2 - Demos</a></td>
  </tr>
</table>
                                                     8
Simple HTML Tables
      Live Demo
Complete HTML Tables
 Tables rows split
                  into three sections: heading,
 body and footer, each containing table rows
 Divides the table into semantic sections

 Table sections:

   <thead> denotes table heading
   <tbody> denotes collection of table rows that
    contain the very data
   <tfoot> denotes table footer but comes
    BEFORE the <tbody> tag
                                                    10
Complete HTML Table: Example
<table>            First comes the header
<thead>
  <tr><td>Column heading</td><td>Column
  heading</td></tr>
</thead>              Then comes the footer
<tfoot>
  <tr><td>Column footer</td><td>Column
  footer</td></tr>
</tfoot>            Last comes the body (data)
<tbody>
  <tr><td>Cell 1</td><td>Cell 2</td></tr>
  <tr><td>Cell 3</td><td>Cell 4</td></tr>
</tbody>
</table>

                                                 11
Complete HTML Table:
                                Example (2)
<table>                               table-full.html
<thead>
  <tr><td>Column heading</td><td>Column
  heading</td></tr>
</thead>
<tfoot>
  <tr><td>Column footer</td><td>Column
  footer</td></tr>
</tfoot>
<tbody>
  <tr><td>Cell 1</td><td>Cell 2</td></tr>
                            Although the footer is
  <tr><td>Cell 3</td><td>Cell 4</td></tr>
</tbody>
                            before the data in the
</table>                   code, it is displayed last
                                                        12
Nested Tables
   Table data “cells” (<td>) can contain nested
    tables (tables within tables):
    <table border="1">               nested-tables.html
      <tr>
        <td>Contact:</td>
        <td>
           <table border="1">
             <tr>
               <td>First Name</td>
               <td>Last Name</td>
             </tr>
           </table>
        </td>
      </tr>
    </table>
                                                          13
Nested Tables
   Live Demo
Cells Width
   Tables and cells can have width attribute
     Width can be given in pixels or percentages
    table-width.html
    <table border="1" width="100%" cellspacing="0">
      <tr>
        <td>Left</td>
        <td width="100%" align="center">Center</td>
        <td>Right</td>
      </tr>
    </table>




                                                       15
Table Width
  Live Demo
Cell Spacing and Padding
 Tables have two important attributes:


  cellspacing            cellpadding


      cell     cell               cell    cell


      cell     cell               cell    cell


    Defines the            Defines the empty
     empty space             space around the cell
     between the cells       contents
                                                     17
Cell Spacing and Padding –
                                     Example
table-cells.html
<html>
  <head><title>Table Cells</title></head>
  <body>
    <table cellspacing="15" cellpadding="0"
    bgcolor="red">
      <tr><td bgcolor="yellow">First</td>
      <td bgcolor="yellow">Second</td></tr>
    </table>
    <br/>
    <table cellspacing="0" cellpadding="10"
    bgcolor="yellow" border="1">
      <tr><td>First</td><td>Second</td></tr>
    </table>
  </body>
</html>
                                                18
Cell Spacing and Padding –
                                  Example (2)
table-cells.html
<html>
  <head><title>Table Cells</title></head>
  <body>
    <table cellspacing="15" cellpadding="0"
    bgcolor="red">
      <tr><td bgcolor="yellow">First</td>
      <td bgcolor="yellow">Second</td></tr>
    </table>
    <br/>
    <table cellspacing="0" cellpadding="10"
    bgcolor="yellow" border="1">
      <tr><td>First</td><td>Second</td></tr>
    </table>
  </body>
</html>
                                                19
Table Cell Spacing
 and Cell Padding
     Live Demo
Column and Row Span
 Table cells have two important attributes:

    colspan                                 rowspan
  colspan="1"      colspan="1"         rowspan="2"     rowspan="1"

       cell[1,1]   cell[1,2]                            cell[1,2]
                                           cell[1,1]
             cell[2,1]                                  cell[2,1]

                         colspan="2"                   rowspan="1"
    Defines how                             Defines how
     many columns                             many rows the
     the cell occupies                        cell occupies
                                                                     21
Column and Row Span – Example
table-colspan-rowspan.html
<html>
  <head><title>Colspan and Rowspan</title></head>
  <body>
    <br/>
    <table cellspacing="0" cellpadding="10"
    border="1">
      <tr bgcolor="yellow"><td>Cell[1,1]</td>
        <td colspan="2">Cell[2,1]</td></tr>
      <tr bgcolor="#FFCC66"><td>Cell[1,2]</td>
        <td rowspan="2">Cell[2,2]</td>
        <td>Cell[3,2]</td></tr>
      <tr bgcolor="#CCCCFF"><td>Cell[1,3]</td>
        <td>Cell[2,3]</td></tr>
      </table>
  </body>
</html>
                                                    22
Column and Row Span –
table-colspan-rowspan.html
                                 Example (2)
<html>
  <head><title>Colspan and Rowspan</title></head>
  <body>
    <br/>
    <table cellspacing="0" cellpadding="10"
    border="1">
      <tr bgcolor="yellow"><td>Cell[1,1]</td>
        <td colspan="2">Cell[2,1]</td></tr>
                Cell[1,1]          Cell[2,1]
      <tr bgcolor="#FFCC66"><td>Cell[1,2]</td>
        <td rowspan="2">Cell[2,2]</td>
        <td>Cell[3,2]</td></tr>
                Cell[1,2]                 Cell[3,2]
      <tr bgcolor="#CCCCFF"><td>Cell[1,3]</td>
                            Cell[2,2]
        <td>Cell[2,3]</td></tr>
      </table> Cell[1,3]                  Cell[2,3]
  </body>
</html>
                                                      23
HTML Forms
Entering User Data from a Web Page
HTML Forms
 Forms are the primary    method for gathering
 data from site visitors
 Create a form block with

   <form></form>
                     The “method" attribute tells how
                      the form data should be sent –
 Example:               via GET or POST request

   <form name="myForm" method="post"
   action="path/to/some-script.php">
      ...
   </form>
           The "action" attribute tells where
             the form data should be sent
                                                        25
Form Fields
   Text fields are single-line entry fields:
     <input type="text" name="FirstName" value="This
     is a text field">

   Text areas can contain multiple lines of text:
     <textarea name="Comments">This is a multi-line
     text field</textarea>

   Hidden fields contain data not shown to user:
     <input type="hidden" name="Account" value="This
     is a hidden text field">

     Often used by JavaScript code
                                                        26
Form Input Controls
   Create a checkbox:
     <input type="checkbox" name="fruit"
     value="apple">

   Create a radio button:
     <input type="radio" name="title" value="Mr.">

   Radio buttons can be grouped, allowing only one
    to be selected from a group:

     <input type="radio" name="town" value="Sofia">
     <input type="radio" name="town" value="Varna">

                                                      27
Other Form Controls
 Pull down menu (drop-down list):

  <select name="gender">
    <option value="Value 1"
      selected="selected">Male</option>
    <option value="Value 2">Female</option>
    <option value="Value 3">Other</option>
  </select>

 Submit button:

  <input type="submit" name="submitBtn"
  value="Apply Now">


                                              28
Other Form Controls (2)
   Reset button – clears the form
     <input type="reset" name="resetBtn"
     value="Clear the form">

   Image button – acts like submit but image is
    displayed instead of button
     <input type="image" src="submit.gif"
     name="submitBtn" alt="Submit">

   Ordinary button – used for JavaScript, no default
    action
     <input type="button" value="simple button">
                                                        29
Other Form Controls (3)
   Password input – acts like normal text field but
    hides the text with * signs
     <input type="password" name="pass" value="">

   Multiple select field – code is like drop down but
    displays list of items to select
     <select name="products" multiple="multiple">
       <option value="Value 1"
         selected="selected">keyboard</option>
       <option value="Value 2">mouse</option>
       <option value="Value 3">speakers</option>
     </select>
                                                         30
HTML Forms – Example
form.html
<form method="POST" action="apply-now.php">
  <input name="subject" type="hidden" value="Class" />
  <p>Degree:
    <select name="degree">
       <option value="BA">Bachelor of Art</option>
       <option value="BS">Bachelor of Science</option>
       <option value="MBA" selected="true">Master of
         Business Administration</option>
    </select>
  </p>
  <p>
    First Name: <input type="text" name="firstname" />
  </p>
  <p>
    Last Name: <input type="text" name="lastname" />
  </p>
  <p>
    Student ID: <input type="password" name="studentid" />
  </p>
                                                             31
HTML Forms – Example (2)
form.html (continuation)
  <p>
    Gender:
    <input name="gender" type="radio" value="Male"
       checked="true" /> Male
    <input name="gender" type="radio" value="Female" />
       Female
  </p>
  <p>
    E-mail: <input type="text" name="email" value="" />
  </p>
  <p>
    <textarea name="terms" cols="30" rows="4"
       readonly="true">TERMS AND CONDITIONS
By clicking the Send Form button you agree to submit this
form.</textarea>
  </p>
  <p>
    <input type="submit" name="button" value="Send Form" />
  </p>
</form>
                                                              32
HTML Forms – Example (3)
form.html (continuation)
  <p>
    Gender:
    <input name="gender" type="radio" value="Male"
       checked="true" /> Male
    <input name="gender" type="radio" value="Female" />
       Female
  </p>
  <p>
    E-mail: <input type="text" name="email" value="" />
  </p>
  <p>
    <textarea name="terms" cols="30" rows="4"
       readonly="true">TERMS AND CONDITIONS
By clicking the Send Form button you agree to submit this
form.</textarea>
  </p>
  <p>
    <input type="submit" name="button" value="Send Form" />
  </p>
</form>
                                                              33
HTML Frames
<frameset>, <frame> and <iframe>
HTML Frames
 Frames provide a way to show multiple HTML
 documents in a single Web page
  The page is split into multiple parts horizontally
   or vertically
  <html>
   <head><title>Frames Example</title></head>
   <frameset cols="25%,*,25%">
     <frame src="left.html" />
     <frame src="middle.html" />
     <frame src="right.html" />
   </frameset>
  </html>                                 frames.html
                                                        35
Embedded Frames: <iframe>
 Embedded frames provide a way to show one
 Web site inside another Web site:

                                     iframe-demo.html
  <html>
   <head><title>IFrame Example</title></head>
    <iframe name="iframeGoogle" width="600" height="400"
  src="http://www.google.com" frameborder="yes"
  scrolling="yes"></iframe>
  </html>




                                                           36
HTML – Tables and Forms




Questions?


              http://academy.telerik.com
1 of 37

Recommended

html-table by
html-tablehtml-table
html-tableDhirendra Chauhan
2K views33 slides
Html table tags by
Html table tagsHtml table tags
Html table tagseShikshak
7.3K views18 slides
Web html table tags by
Web html  table tagsWeb html  table tags
Web html table tagsKainat Ilyas
7.7K views25 slides
HTML Forms by
HTML FormsHTML Forms
HTML FormsRavinder Kamboj
19.1K views28 slides
HTML Tables by
HTML TablesHTML Tables
HTML TablesNisa Soomro
4.4K views18 slides
Html form tag by
Html form tagHtml form tag
Html form tagshreyachougule
1.1K views27 slides

More Related Content

What's hot

Html-list by
Html-listHtml-list
Html-listDhirendra Chauhan
621 views21 slides
Html Table by
Html TableHtml Table
Html Tablenehashinde41
435 views10 slides
Learn html Basics by
Learn html BasicsLearn html Basics
Learn html BasicsMcSoftsis
32K views35 slides
Html ppt by
Html pptHtml ppt
Html pptsantosh lamba
10.4K views39 slides
Introduction to css by
Introduction to cssIntroduction to css
Introduction to cssEvolution Network
1.2K views33 slides
Html ppt by
Html pptHtml ppt
Html pptIblesoft
21K views34 slides

What's hot(20)

Learn html Basics by McSoftsis
Learn html BasicsLearn html Basics
Learn html Basics
McSoftsis32K views
Html ppt by Iblesoft
Html pptHtml ppt
Html ppt
Iblesoft21K views
Html frames by eShikshak
Html framesHtml frames
Html frames
eShikshak11.7K views
Cascading Style Sheet (CSS) by AakankshaR
Cascading Style Sheet (CSS)Cascading Style Sheet (CSS)
Cascading Style Sheet (CSS)
AakankshaR14.3K views
cascading style sheet ppt by abhilashagupta
cascading style sheet pptcascading style sheet ppt
cascading style sheet ppt
abhilashagupta38.3K views
Html5 tutorial for beginners by Singsys Pte Ltd
Html5 tutorial for beginnersHtml5 tutorial for beginners
Html5 tutorial for beginners
Singsys Pte Ltd16.3K views
Introduction to Cascading Style Sheets (CSS) by Chris Poteet
Introduction to Cascading Style Sheets (CSS)Introduction to Cascading Style Sheets (CSS)
Introduction to Cascading Style Sheets (CSS)
Chris Poteet11.7K views
Introduction to html by vikasgaur31
Introduction to htmlIntroduction to html
Introduction to html
vikasgaur3171.7K views
Tables and Forms in HTML by Marlon Jamera
Tables and Forms in HTMLTables and Forms in HTML
Tables and Forms in HTML
Marlon Jamera2.1K views
Html links by JayjZens
Html linksHtml links
Html links
JayjZens1.8K views
Lecture 2 introduction to html by palhaftab
Lecture 2  introduction to htmlLecture 2  introduction to html
Lecture 2 introduction to html
palhaftab6.3K views

Viewers also liked

Html tables examples by
Html tables   examplesHtml tables   examples
Html tables examplesMukesh Tekwani
19.8K views14 slides
Tables frames by
Tables framesTables frames
Tables framesVasya Petrov
2.4K views11 slides
HTML practicals by
HTML practicals HTML practicals
HTML practicals Abhishek Sharma
213K views32 slides
html5.ppt by
html5.ppthtml5.ppt
html5.pptNiharika Gupta
42K views13 slides
Take Better Care of Library Data and Spreadsheets with Google Visualization A... by
Take Better Care of Library Data and Spreadsheets with Google Visualization A...Take Better Care of Library Data and Spreadsheets with Google Visualization A...
Take Better Care of Library Data and Spreadsheets with Google Visualization A...Bohyun Kim
294.8K views69 slides
Introduction to spreadsheets by
Introduction to spreadsheetsIntroduction to spreadsheets
Introduction to spreadsheetsCasey Robertson
52.4K views30 slides

Viewers also liked(6)

Take Better Care of Library Data and Spreadsheets with Google Visualization A... by Bohyun Kim
Take Better Care of Library Data and Spreadsheets with Google Visualization A...Take Better Care of Library Data and Spreadsheets with Google Visualization A...
Take Better Care of Library Data and Spreadsheets with Google Visualization A...
Bohyun Kim294.8K views
Introduction to spreadsheets by Casey Robertson
Introduction to spreadsheetsIntroduction to spreadsheets
Introduction to spreadsheets
Casey Robertson52.4K views

Similar to HTML: Tables and Forms

HTML 5 Tables and Forms by
HTML 5 Tables and FormsHTML 5 Tables and Forms
HTML 5 Tables and FormsDoncho Minkov
2.2K views58 slides
01 HTML-Tables-1.pptx by
01 HTML-Tables-1.pptx01 HTML-Tables-1.pptx
01 HTML-Tables-1.pptxAhmedAlmughalis1
11 views27 slides
Handout5 tables by
Handout5 tablesHandout5 tables
Handout5 tablesNadine Guevarra
686 views2 slides
HTML Tables by
HTML TablesHTML Tables
HTML Tablesstephenjamesbarcelo15
645 views9 slides
Html - Tables, Forms and Frames by Telerik Academy by
Html - Tables, Forms and Frames by Telerik AcademyHtml - Tables, Forms and Frames by Telerik Academy
Html - Tables, Forms and Frames by Telerik AcademyOgnyan Penkov
1.7K views58 slides
Web I - 03 - Tables by
Web I - 03 - TablesWeb I - 03 - Tables
Web I - 03 - TablesRandy Connolly
542 views23 slides

Similar to HTML: Tables and Forms(20)

HTML 5 Tables and Forms by Doncho Minkov
HTML 5 Tables and FormsHTML 5 Tables and Forms
HTML 5 Tables and Forms
Doncho Minkov2.2K views
Html - Tables, Forms and Frames by Telerik Academy by Ognyan Penkov
Html - Tables, Forms and Frames by Telerik AcademyHtml - Tables, Forms and Frames by Telerik Academy
Html - Tables, Forms and Frames by Telerik Academy
Ognyan Penkov1.7K views
Table structure introduction by nobel mujuji
Table structure introductionTable structure introduction
Table structure introduction
nobel mujuji404 views
Html 5-tables-forms-frames (1) by club23
Html 5-tables-forms-frames (1)Html 5-tables-forms-frames (1)
Html 5-tables-forms-frames (1)
club232.6K views
HTML Lecture Part 2 of 2 by Sharon Wasden
HTML Lecture Part 2 of 2HTML Lecture Part 2 of 2
HTML Lecture Part 2 of 2
Sharon Wasden806 views
Web topic 12 tables in html by CK Yang
Web topic 12  tables in htmlWeb topic 12  tables in html
Web topic 12 tables in html
CK Yang445 views
Web forms and html lecture Number 3 by Mudasir Syed
Web forms and html lecture Number 3Web forms and html lecture Number 3
Web forms and html lecture Number 3
Mudasir Syed366 views

More from BG Java EE Course

Rich faces by
Rich facesRich faces
Rich facesBG Java EE Course
6.3K views80 slides
JSP Custom Tags by
JSP Custom TagsJSP Custom Tags
JSP Custom TagsBG Java EE Course
5.3K views21 slides
Java Server Faces (JSF) - advanced by
Java Server Faces (JSF) - advancedJava Server Faces (JSF) - advanced
Java Server Faces (JSF) - advancedBG Java EE Course
64.1K views55 slides
Java Server Faces (JSF) - Basics by
Java Server Faces (JSF) - BasicsJava Server Faces (JSF) - Basics
Java Server Faces (JSF) - BasicsBG Java EE Course
12.3K views63 slides
JSTL by
JSTLJSTL
JSTLBG Java EE Course
1.3K views32 slides
Unified Expression Language by
Unified Expression LanguageUnified Expression Language
Unified Expression LanguageBG Java EE Course
4.2K views29 slides

More from BG Java EE Course (20)

Recently uploaded

JQUERY.pdf by
JQUERY.pdfJQUERY.pdf
JQUERY.pdfArthyR3
107 views22 slides
ICS3211_lecture 09_2023.pdf by
ICS3211_lecture 09_2023.pdfICS3211_lecture 09_2023.pdf
ICS3211_lecture 09_2023.pdfVanessa Camilleri
147 views10 slides
Mineral nutrition and Fertilizer use of Cashew by
 Mineral nutrition and Fertilizer use of Cashew Mineral nutrition and Fertilizer use of Cashew
Mineral nutrition and Fertilizer use of CashewAruna Srikantha Jayawardana
58 views107 slides
Creative Restart 2023: Atila Martins - Craft: A Necessity, Not a Choice by
Creative Restart 2023: Atila Martins - Craft: A Necessity, Not a ChoiceCreative Restart 2023: Atila Martins - Craft: A Necessity, Not a Choice
Creative Restart 2023: Atila Martins - Craft: A Necessity, Not a ChoiceTaste
52 views50 slides
Retail Store Scavenger Hunt.pptx by
Retail Store Scavenger Hunt.pptxRetail Store Scavenger Hunt.pptx
Retail Store Scavenger Hunt.pptxjmurphy154
53 views10 slides
DISTILLATION.pptx by
DISTILLATION.pptxDISTILLATION.pptx
DISTILLATION.pptxAnupkumar Sharma
75 views47 slides

Recently uploaded(20)

JQUERY.pdf by ArthyR3
JQUERY.pdfJQUERY.pdf
JQUERY.pdf
ArthyR3107 views
Creative Restart 2023: Atila Martins - Craft: A Necessity, Not a Choice by Taste
Creative Restart 2023: Atila Martins - Craft: A Necessity, Not a ChoiceCreative Restart 2023: Atila Martins - Craft: A Necessity, Not a Choice
Creative Restart 2023: Atila Martins - Craft: A Necessity, Not a Choice
Taste52 views
Retail Store Scavenger Hunt.pptx by jmurphy154
Retail Store Scavenger Hunt.pptxRetail Store Scavenger Hunt.pptx
Retail Store Scavenger Hunt.pptx
jmurphy15453 views
Creative Restart 2023: Leonard Savage - The Permanent Brief: Unearthing unobv... by Taste
Creative Restart 2023: Leonard Savage - The Permanent Brief: Unearthing unobv...Creative Restart 2023: Leonard Savage - The Permanent Brief: Unearthing unobv...
Creative Restart 2023: Leonard Savage - The Permanent Brief: Unearthing unobv...
Taste62 views
Career Building in AI - Technologies, Trends and Opportunities by WebStackAcademy
Career Building in AI - Technologies, Trends and OpportunitiesCareer Building in AI - Technologies, Trends and Opportunities
Career Building in AI - Technologies, Trends and Opportunities
WebStackAcademy47 views
INT-244 Topic 6b Confucianism by S Meyer
INT-244 Topic 6b ConfucianismINT-244 Topic 6b Confucianism
INT-244 Topic 6b Confucianism
S Meyer49 views
What is Digital Transformation? by Mark Brown
What is Digital Transformation?What is Digital Transformation?
What is Digital Transformation?
Mark Brown41 views
Monthly Information Session for MV Asterix (November) by Esquimalt MFRC
Monthly Information Session for MV Asterix (November)Monthly Information Session for MV Asterix (November)
Monthly Information Session for MV Asterix (November)
Esquimalt MFRC213 views
ANGULARJS.pdf by ArthyR3
ANGULARJS.pdfANGULARJS.pdf
ANGULARJS.pdf
ArthyR352 views
EILO EXCURSION PROGRAMME 2023 by info33492
EILO EXCURSION PROGRAMME 2023EILO EXCURSION PROGRAMME 2023
EILO EXCURSION PROGRAMME 2023
info33492208 views
Interaction of microorganisms with vascular plants.pptx by MicrobiologyMicro
Interaction of microorganisms with vascular plants.pptxInteraction of microorganisms with vascular plants.pptx
Interaction of microorganisms with vascular plants.pptx

HTML: Tables and Forms

  • 1. HTML – Tables and Forms Svetlin Nakov Telerik Corporation www.telerik.com
  • 2. Contents 1. HTML Tables  Nested Tables  Cells Width  Cell Spacing and Padding  Column and Row Span 2
  • 3. Contents (2) 2. HTML Forms  Form Fields  Form Controls  Text field  Text area  Select  Radio button  Checkbox  Button  Image button 3
  • 5. HTML Tables  Tables represent tabular data  A table consists of one or several rows  Each row has one or more columns  Tables comprised of several core tags: <table></table>: begin / end the table <tr></tr>: create a table row <td></td>: create tabular data (cell)  Tables are losing favor to <div> and <span>, with the CSS revolution 5
  • 6. HTML Tables (2)  Start and end of a table <table> ... </table>  Start and end of a row <tr> ... </tr>  Start and end of a cell in a row <td> ... </td> 6
  • 7. Simple HTML Tables – Example <table border="1" cellspacing="0" cellpadding="5"> <tr> <td><img src="ppt.gif"></td> <td><a href="lecture1.ppt">Lecture 1</a></td> </tr> <tr> <td><img src="ppt.gif"></td> <td><a href="lecture2.ppt">Lecture 2</a></td> </tr> <tr> <td><img src="zip.gif"></td> <td><a href="lecture2-demos.zip"> Lecture 2 - Demos</a></td> </tr> </table> 7
  • 8. Simple HTML Tables – Example (2) <table border="1" cellspacing="0" cellpadding="5"> <tr> <td><img src="ppt.gif"></td> <td><a href="lecture1.ppt">Lecture 1</a></td> </tr> <tr> <td><img src="ppt.gif"></td> <td><a href="lecture2.ppt">Lecture 2</a></td> </tr> <tr> <td><img src="zip.gif"></td> <td><a href="lecture2-demos.zip"> Lecture 2 - Demos</a></td> </tr> </table> 8
  • 9. Simple HTML Tables Live Demo
  • 10. Complete HTML Tables  Tables rows split into three sections: heading, body and footer, each containing table rows  Divides the table into semantic sections  Table sections:  <thead> denotes table heading  <tbody> denotes collection of table rows that contain the very data  <tfoot> denotes table footer but comes BEFORE the <tbody> tag 10
  • 11. Complete HTML Table: Example <table> First comes the header <thead> <tr><td>Column heading</td><td>Column heading</td></tr> </thead> Then comes the footer <tfoot> <tr><td>Column footer</td><td>Column footer</td></tr> </tfoot> Last comes the body (data) <tbody> <tr><td>Cell 1</td><td>Cell 2</td></tr> <tr><td>Cell 3</td><td>Cell 4</td></tr> </tbody> </table> 11
  • 12. Complete HTML Table: Example (2) <table> table-full.html <thead> <tr><td>Column heading</td><td>Column heading</td></tr> </thead> <tfoot> <tr><td>Column footer</td><td>Column footer</td></tr> </tfoot> <tbody> <tr><td>Cell 1</td><td>Cell 2</td></tr> Although the footer is <tr><td>Cell 3</td><td>Cell 4</td></tr> </tbody> before the data in the </table> code, it is displayed last 12
  • 13. Nested Tables  Table data “cells” (<td>) can contain nested tables (tables within tables): <table border="1"> nested-tables.html <tr> <td>Contact:</td> <td> <table border="1"> <tr> <td>First Name</td> <td>Last Name</td> </tr> </table> </td> </tr> </table> 13
  • 14. Nested Tables Live Demo
  • 15. Cells Width  Tables and cells can have width attribute  Width can be given in pixels or percentages table-width.html <table border="1" width="100%" cellspacing="0"> <tr> <td>Left</td> <td width="100%" align="center">Center</td> <td>Right</td> </tr> </table> 15
  • 16. Table Width Live Demo
  • 17. Cell Spacing and Padding  Tables have two important attributes:  cellspacing  cellpadding cell cell cell cell cell cell cell cell  Defines the  Defines the empty empty space space around the cell between the cells contents 17
  • 18. Cell Spacing and Padding – Example table-cells.html <html> <head><title>Table Cells</title></head> <body> <table cellspacing="15" cellpadding="0" bgcolor="red"> <tr><td bgcolor="yellow">First</td> <td bgcolor="yellow">Second</td></tr> </table> <br/> <table cellspacing="0" cellpadding="10" bgcolor="yellow" border="1"> <tr><td>First</td><td>Second</td></tr> </table> </body> </html> 18
  • 19. Cell Spacing and Padding – Example (2) table-cells.html <html> <head><title>Table Cells</title></head> <body> <table cellspacing="15" cellpadding="0" bgcolor="red"> <tr><td bgcolor="yellow">First</td> <td bgcolor="yellow">Second</td></tr> </table> <br/> <table cellspacing="0" cellpadding="10" bgcolor="yellow" border="1"> <tr><td>First</td><td>Second</td></tr> </table> </body> </html> 19
  • 20. Table Cell Spacing and Cell Padding Live Demo
  • 21. Column and Row Span  Table cells have two important attributes:  colspan  rowspan colspan="1" colspan="1" rowspan="2" rowspan="1" cell[1,1] cell[1,2] cell[1,2] cell[1,1] cell[2,1] cell[2,1] colspan="2" rowspan="1"  Defines how  Defines how many columns many rows the the cell occupies cell occupies 21
  • 22. Column and Row Span – Example table-colspan-rowspan.html <html> <head><title>Colspan and Rowspan</title></head> <body> <br/> <table cellspacing="0" cellpadding="10" border="1"> <tr bgcolor="yellow"><td>Cell[1,1]</td> <td colspan="2">Cell[2,1]</td></tr> <tr bgcolor="#FFCC66"><td>Cell[1,2]</td> <td rowspan="2">Cell[2,2]</td> <td>Cell[3,2]</td></tr> <tr bgcolor="#CCCCFF"><td>Cell[1,3]</td> <td>Cell[2,3]</td></tr> </table> </body> </html> 22
  • 23. Column and Row Span – table-colspan-rowspan.html Example (2) <html> <head><title>Colspan and Rowspan</title></head> <body> <br/> <table cellspacing="0" cellpadding="10" border="1"> <tr bgcolor="yellow"><td>Cell[1,1]</td> <td colspan="2">Cell[2,1]</td></tr> Cell[1,1] Cell[2,1] <tr bgcolor="#FFCC66"><td>Cell[1,2]</td> <td rowspan="2">Cell[2,2]</td> <td>Cell[3,2]</td></tr> Cell[1,2] Cell[3,2] <tr bgcolor="#CCCCFF"><td>Cell[1,3]</td> Cell[2,2] <td>Cell[2,3]</td></tr> </table> Cell[1,3] Cell[2,3] </body> </html> 23
  • 24. HTML Forms Entering User Data from a Web Page
  • 25. HTML Forms  Forms are the primary method for gathering data from site visitors  Create a form block with <form></form> The “method" attribute tells how the form data should be sent –  Example: via GET or POST request <form name="myForm" method="post" action="path/to/some-script.php"> ... </form> The "action" attribute tells where the form data should be sent 25
  • 26. Form Fields  Text fields are single-line entry fields: <input type="text" name="FirstName" value="This is a text field">  Text areas can contain multiple lines of text: <textarea name="Comments">This is a multi-line text field</textarea>  Hidden fields contain data not shown to user: <input type="hidden" name="Account" value="This is a hidden text field">  Often used by JavaScript code 26
  • 27. Form Input Controls  Create a checkbox: <input type="checkbox" name="fruit" value="apple">  Create a radio button: <input type="radio" name="title" value="Mr.">  Radio buttons can be grouped, allowing only one to be selected from a group: <input type="radio" name="town" value="Sofia"> <input type="radio" name="town" value="Varna"> 27
  • 28. Other Form Controls  Pull down menu (drop-down list): <select name="gender"> <option value="Value 1" selected="selected">Male</option> <option value="Value 2">Female</option> <option value="Value 3">Other</option> </select>  Submit button: <input type="submit" name="submitBtn" value="Apply Now"> 28
  • 29. Other Form Controls (2)  Reset button – clears the form <input type="reset" name="resetBtn" value="Clear the form">  Image button – acts like submit but image is displayed instead of button <input type="image" src="submit.gif" name="submitBtn" alt="Submit">  Ordinary button – used for JavaScript, no default action <input type="button" value="simple button"> 29
  • 30. Other Form Controls (3)  Password input – acts like normal text field but hides the text with * signs <input type="password" name="pass" value="">  Multiple select field – code is like drop down but displays list of items to select <select name="products" multiple="multiple"> <option value="Value 1" selected="selected">keyboard</option> <option value="Value 2">mouse</option> <option value="Value 3">speakers</option> </select> 30
  • 31. HTML Forms – Example form.html <form method="POST" action="apply-now.php"> <input name="subject" type="hidden" value="Class" /> <p>Degree: <select name="degree"> <option value="BA">Bachelor of Art</option> <option value="BS">Bachelor of Science</option> <option value="MBA" selected="true">Master of Business Administration</option> </select> </p> <p> First Name: <input type="text" name="firstname" /> </p> <p> Last Name: <input type="text" name="lastname" /> </p> <p> Student ID: <input type="password" name="studentid" /> </p> 31
  • 32. HTML Forms – Example (2) form.html (continuation) <p> Gender: <input name="gender" type="radio" value="Male" checked="true" /> Male <input name="gender" type="radio" value="Female" /> Female </p> <p> E-mail: <input type="text" name="email" value="" /> </p> <p> <textarea name="terms" cols="30" rows="4" readonly="true">TERMS AND CONDITIONS By clicking the Send Form button you agree to submit this form.</textarea> </p> <p> <input type="submit" name="button" value="Send Form" /> </p> </form> 32
  • 33. HTML Forms – Example (3) form.html (continuation) <p> Gender: <input name="gender" type="radio" value="Male" checked="true" /> Male <input name="gender" type="radio" value="Female" /> Female </p> <p> E-mail: <input type="text" name="email" value="" /> </p> <p> <textarea name="terms" cols="30" rows="4" readonly="true">TERMS AND CONDITIONS By clicking the Send Form button you agree to submit this form.</textarea> </p> <p> <input type="submit" name="button" value="Send Form" /> </p> </form> 33
  • 35. HTML Frames  Frames provide a way to show multiple HTML documents in a single Web page  The page is split into multiple parts horizontally or vertically <html> <head><title>Frames Example</title></head> <frameset cols="25%,*,25%"> <frame src="left.html" /> <frame src="middle.html" /> <frame src="right.html" /> </frameset> </html> frames.html 35
  • 36. Embedded Frames: <iframe>  Embedded frames provide a way to show one Web site inside another Web site: iframe-demo.html <html> <head><title>IFrame Example</title></head> <iframe name="iframeGoogle" width="600" height="400" src="http://www.google.com" frameborder="yes" scrolling="yes"></iframe> </html> 36
  • 37. HTML – Tables and Forms Questions? http://academy.telerik.com