SlideShare a Scribd company logo
1 of 37
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

More Related Content

What's hot

Images and Tables in HTML
Images and Tables in HTMLImages and Tables in HTML
Images and Tables in HTML
Aarti P
 
Html text and formatting
Html text and formattingHtml text and formatting
Html text and formatting
eShikshak
 
Introduction to html
Introduction to htmlIntroduction to html
Introduction to html
vikasgaur31
 

What's hot (20)

CSS Basics
CSS BasicsCSS Basics
CSS Basics
 
Images and Tables in HTML
Images and Tables in HTMLImages and Tables in HTML
Images and Tables in HTML
 
Html text and formatting
Html text and formattingHtml text and formatting
Html text and formatting
 
HTML Forms
HTML FormsHTML Forms
HTML Forms
 
Web Development using HTML & CSS
Web Development using HTML & CSSWeb Development using HTML & CSS
Web Development using HTML & CSS
 
Intro to html 5
Intro to html 5Intro to html 5
Intro to html 5
 
Introduction to Cascading Style Sheets (CSS)
Introduction to Cascading Style Sheets (CSS)Introduction to Cascading Style Sheets (CSS)
Introduction to Cascading Style Sheets (CSS)
 
Document Object Model
Document Object ModelDocument Object Model
Document Object Model
 
Html frames
Html framesHtml frames
Html frames
 
Cascading Style Sheet (CSS)
Cascading Style Sheet (CSS)Cascading Style Sheet (CSS)
Cascading Style Sheet (CSS)
 
Introduction to html
Introduction to htmlIntroduction to html
Introduction to html
 
CSS
CSSCSS
CSS
 
Html forms
Html formsHtml forms
Html forms
 
Html ppt
Html pptHtml ppt
Html ppt
 
Html
HtmlHtml
Html
 
HTML (Web) basics for a beginner
HTML (Web) basics for a beginnerHTML (Web) basics for a beginner
HTML (Web) basics for a beginner
 
Html
HtmlHtml
Html
 
JavaScript - Chapter 12 - Document Object Model
  JavaScript - Chapter 12 - Document Object Model  JavaScript - Chapter 12 - Document Object Model
JavaScript - Chapter 12 - Document Object Model
 
Html-list
Html-listHtml-list
Html-list
 
HTML5: features with examples
HTML5: features with examplesHTML5: features with examples
HTML5: features with examples
 

Viewers also liked (7)

Html tables examples
Html tables   examplesHtml tables   examples
Html tables examples
 
Tables frames
Tables framesTables frames
Tables frames
 
HTML practicals
HTML practicals HTML practicals
HTML practicals
 
HTML Tables
HTML TablesHTML Tables
HTML Tables
 
html5.ppt
html5.ppthtml5.ppt
html5.ppt
 
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...
Take Better Care of Library Data and Spreadsheets with Google Visualization A...
 
Introduction to spreadsheets
Introduction to spreadsheetsIntroduction to spreadsheets
Introduction to spreadsheets
 

Similar to HTML: Tables and Forms

HTML 5 Tables and Forms
HTML 5 Tables and FormsHTML 5 Tables and Forms
HTML 5 Tables and Forms
Doncho Minkov
 
Html - Tables, Forms and Frames by Telerik Academy
Html - Tables, Forms and Frames by Telerik AcademyHtml - Tables, Forms and Frames by Telerik Academy
Html - Tables, Forms and Frames by Telerik Academy
Ognyan Penkov
 
Html 5-tables-forms-frames (1)
Html 5-tables-forms-frames (1)Html 5-tables-forms-frames (1)
Html 5-tables-forms-frames (1)
club23
 
Web topic 12 tables in html
Web topic 12  tables in htmlWeb topic 12  tables in html
Web topic 12 tables in html
CK Yang
 

Similar to HTML: Tables and Forms (20)

HTML 5 Tables and Forms
HTML 5 Tables and FormsHTML 5 Tables and Forms
HTML 5 Tables and Forms
 
01 HTML-Tables-1.pptx
01 HTML-Tables-1.pptx01 HTML-Tables-1.pptx
01 HTML-Tables-1.pptx
 
Handout5 tables
Handout5 tablesHandout5 tables
Handout5 tables
 
HTML Tables
HTML TablesHTML Tables
HTML Tables
 
v4-html-table-210321161424.pptx
v4-html-table-210321161424.pptxv4-html-table-210321161424.pptx
v4-html-table-210321161424.pptx
 
Html - Tables, Forms and Frames by Telerik Academy
Html - Tables, Forms and Frames by Telerik AcademyHtml - Tables, Forms and Frames by Telerik Academy
Html - Tables, Forms and Frames by Telerik Academy
 
Web I - 03 - Tables
Web I - 03 - TablesWeb I - 03 - Tables
Web I - 03 - Tables
 
Tables and their padding in HTML etc.pptx
Tables and their padding in HTML etc.pptxTables and their padding in HTML etc.pptx
Tables and their padding in HTML etc.pptx
 
Table structure introduction
Table structure introductionTable structure introduction
Table structure introduction
 
Html 5-tables-forms-frames (1)
Html 5-tables-forms-frames (1)Html 5-tables-forms-frames (1)
Html 5-tables-forms-frames (1)
 
Web design - Working with tables in HTML
Web design - Working with tables in HTMLWeb design - Working with tables in HTML
Web design - Working with tables in HTML
 
Table and Form HTML&CSS
Table and Form HTML&CSSTable and Form HTML&CSS
Table and Form HTML&CSS
 
HTML Tables.ppt
HTML Tables.pptHTML Tables.ppt
HTML Tables.ppt
 
Lecture-4.pptx
Lecture-4.pptxLecture-4.pptx
Lecture-4.pptx
 
Html
HtmlHtml
Html
 
Tables and Forms in HTML
Tables and Forms in HTMLTables and Forms in HTML
Tables and Forms in HTML
 
Lect# 1 html part ii
Lect# 1 html part iiLect# 1 html part ii
Lect# 1 html part ii
 
Html tables
Html tablesHtml tables
Html tables
 
HTML Lecture Part 2 of 2
HTML Lecture Part 2 of 2HTML Lecture Part 2 of 2
HTML Lecture Part 2 of 2
 
Web topic 12 tables in html
Web topic 12  tables in htmlWeb topic 12  tables in html
Web topic 12 tables in html
 

More from BG Java EE Course

Java Server Faces (JSF) - advanced
Java Server Faces (JSF) - advancedJava Server Faces (JSF) - advanced
Java Server Faces (JSF) - advanced
BG Java EE Course
 
JavaScript and jQuery Fundamentals
JavaScript and jQuery FundamentalsJavaScript and jQuery Fundamentals
JavaScript and jQuery Fundamentals
BG Java EE Course
 
Creating Web Sites with HTML and CSS
Creating Web Sites with HTML and CSSCreating Web Sites with HTML and CSS
Creating Web Sites with HTML and CSS
BG Java EE Course
 

More from BG Java EE Course (20)

Rich faces
Rich facesRich faces
Rich faces
 
JSP Custom Tags
JSP Custom TagsJSP Custom Tags
JSP Custom Tags
 
Java Server Faces (JSF) - advanced
Java Server Faces (JSF) - advancedJava Server Faces (JSF) - advanced
Java Server Faces (JSF) - advanced
 
Java Server Faces (JSF) - Basics
Java Server Faces (JSF) - BasicsJava Server Faces (JSF) - Basics
Java Server Faces (JSF) - Basics
 
JSTL
JSTLJSTL
JSTL
 
Unified Expression Language
Unified Expression LanguageUnified Expression Language
Unified Expression Language
 
Java Server Pages
Java Server PagesJava Server Pages
Java Server Pages
 
Web Applications and Deployment
Web Applications and DeploymentWeb Applications and Deployment
Web Applications and Deployment
 
Java Servlets
Java ServletsJava Servlets
Java Servlets
 
CSS
CSSCSS
CSS
 
HTML Fundamentals
HTML FundamentalsHTML Fundamentals
HTML Fundamentals
 
WWW and HTTP
WWW and HTTPWWW and HTTP
WWW and HTTP
 
JavaScript and jQuery Fundamentals
JavaScript and jQuery FundamentalsJavaScript and jQuery Fundamentals
JavaScript and jQuery Fundamentals
 
Creating Web Sites with HTML and CSS
Creating Web Sites with HTML and CSSCreating Web Sites with HTML and CSS
Creating Web Sites with HTML and CSS
 
Processing XML with Java
Processing XML with JavaProcessing XML with Java
Processing XML with Java
 
Introduction to XML
Introduction to XMLIntroduction to XML
Introduction to XML
 
Data Access with JDBC
Data Access with JDBCData Access with JDBC
Data Access with JDBC
 
Introduction to-sql
Introduction to-sqlIntroduction to-sql
Introduction to-sql
 
Introduction to-RDBMS-systems
Introduction to-RDBMS-systemsIntroduction to-RDBMS-systems
Introduction to-RDBMS-systems
 
Basic data-structures-v.1.1
Basic data-structures-v.1.1Basic data-structures-v.1.1
Basic data-structures-v.1.1
 

Recently uploaded

Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
AnaAcapella
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 

Recently uploaded (20)

How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...Kodo Millet  PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
Kodo Millet PPT made by Ghanshyam bairwa college of Agriculture kumher bhara...
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
Spellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please PractiseSpellings Wk 3 English CAPS CARES Please Practise
Spellings Wk 3 English CAPS CARES Please Practise
 
Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024Mehran University Newsletter Vol-X, Issue-I, 2024
Mehran University Newsletter Vol-X, Issue-I, 2024
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Unit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptxUnit-V; Pricing (Pharma Marketing Management).pptx
Unit-V; Pricing (Pharma Marketing Management).pptx
 
SOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning PresentationSOC 101 Demonstration of Learning Presentation
SOC 101 Demonstration of Learning Presentation
 
Introduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The BasicsIntroduction to Nonprofit Accounting: The Basics
Introduction to Nonprofit Accounting: The Basics
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
Application orientated numerical on hev.ppt
Application orientated numerical on hev.pptApplication orientated numerical on hev.ppt
Application orientated numerical on hev.ppt
 
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdfUGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
UGC NET Paper 1 Mathematical Reasoning & Aptitude.pdf
 
Asian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptxAsian American Pacific Islander Month DDSD 2024.pptx
Asian American Pacific Islander Month DDSD 2024.pptx
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
TỔNG ÔN TẬP THI VÀO LỚP 10 MÔN TIẾNG ANH NĂM HỌC 2023 - 2024 CÓ ĐÁP ÁN (NGỮ Â...
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
PROCESS RECORDING FORMAT.docx
PROCESS      RECORDING        FORMAT.docxPROCESS      RECORDING        FORMAT.docx
PROCESS RECORDING FORMAT.docx
 

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