Tables

Forms Images Mark-ups Lists Links & Anchors
Midterm Final

What are tables and why isn't my plate on it?

Tables in HTML speak is short for tabular data. Tables have been around for a while and serve as the foundation for complicated layouts, with multiple columns, sidebars and many other features that were simply impossible before the advent of CSS.

  






This is a table

Table of Contents
Examples of Tables
Creating a Simple Table
Adding a Border
Setting the width
Centering a Table







© X2 Steve Taylor
  1. Default. Decimal numbers (1,2,3,4)
  2. Alphabetically ordered list Uppercase(A,B,C,D)
  3. Alphabetically ordered list Lowercase(a,b,c,d)
  4. Roman Numerals Uppercase(I,II,III,IV)
  5. Roman Numerals Lowercase (i,ii,iii,iv)
because colspan equaled 2
  1. height
  2. width
  3. vspace
  4. hspace
  5. align
vspace=20
  1. Ç
  2. Ý
  3. å
  4. û
blah http They maintain a directory of domain names and translate them to Internet Protocol (IP) addresses
24 years open() cookie dont know dpnt know
(img src="dog.gif") Hello
CLEAR=ALL
Goodbye
middle refers to the y axis (up and down center refers to the x axis (left and right)


One Two Three
Four Five Six
Seven Eight Nine
One Two Three
Four Five Six
Seven Eight Nine






















How to create a simple table



  1. Type (<)table(>)
  2. If destination,press Return and Tab to distinguish the row elements.These won't affect display in the browser
  3. Type (<)tr(>) to define the beginning of the first row.
  4. Type (<)td(>) to define the beginning of the first cell.
  5. Type the contents of the first cell
  6. Type (<)/td(>) to complete the cell.
  7. Repeat the steps 4-6 for each cell in the row.
  8. Type (<)/tr(>) to complete the row.
  9. Repeat the steps 2-7 for each row.
  10. To finish the table, type (<)/table(>)








Adding a Border



To create a border with (X)HTML:

  1. Inside the initial table tag type border.
  2. If desired,type ="n",where n is the thickness in pixels of the border.

To create a border with styles:

  1. In your style sheet,type table or td,or whichever selector denotes the part of the table you want to apply the border to.
  2. Type {border:value}, were border is the border property that you wish to apply and value is the type of border you want.







Setting a Width



To set the width of a cell or table:


To set the width with styles:








Centering a Table



To center a table with (X)HTML:


To center a table with CSS:

  1. Make sure you've specified the width of the table.
  2. Add margin-right:auto and margin left:auto to the style rule for the table