Tutorial 4: Designing a Web Page with Tables

Slides:



Advertisements
Similar presentations
Use Tables for Layout Control Day 7. You will learn to: Understand Tables Create a Simple Table Modify Your Tables Appearance Create Page Layouts with.
Advertisements

XP Tutorial 4New Perspectives on Creating Web Pages with HTML, XHTML, and XML 1 Designing a Web Page with Tables Tutorial 4 Creating a News Page.
Chapter 3 – Web Design Tables & Page Layout
Copyright © 2004 ProsoftTraining, All Rights Reserved. Lesson 6: HTML Tables.
Internet Basics & Way Beyond!
Working with Web Tables
CREATED BY : VIRAL M.KORADIYA. Anchor elements are defined by the element. The element accepts several attributes, but either the Name or HREF attribute.
Creating Tables Text Tables -created by using preformatted tags. Graphical Tables - created using Table Structure with HTML.
New Perspectives on Creating Web Pages with HTML
© 2004, Robert K. Moniot Chapters 4 & 5 Introduction to HTML, More Details.
XHTML1 Tables and Lists. XHTML2 Objectives In this chapter, you will: Create basic tables Structure tables Format tables Create lists.
XP 1 New Perspectives on Creating Web Pages with HTML Tutorial 4: Designing a Web Page with Tables.
XP 1 Designing a Web Page with Tables Tutorial 4 Creating a News Page.
Creating a Web Page with Tables. Objectives Create a text table with preformatted text Create the basic structure of a graphical table Organize table.
Introducing Web Tables
XP Creating Web Pages with HTML Using Tables. XP Objectives Create a text table Create a table using the,, and tags Create table headers and captions.
Using HTML Tables.
1 Tables: Data in Rows and Columns – What is Table? – How Tables are Used? – Designing Tables – Table, Cell, Row Attributes – Using Tables for Alignment.
HTML. Creating a Table Attributes: border: indicates the border type of the table Value: 0 (no border), 1, 2, etc. cols: indicates the number of columns.
INTRODUCTION TO WEB DEVELOPMENT AND HTML Lecture 06: Tables - Spring 2011.
HTML Tables and Forms Creating Web Pages with HTML CIS 133 Web Programming Concepts 1.
HTML Essentials Tables and Table Tags. Overview Use of Tables goes beyond tabulating data Frequently used to format Web pages / control layout Especially.
Chapter 5 Working with Tables. Agenda Add a Table Assign a Table Border Adjust Cell Padding and Spacing Adjust Cell Width and Height Add Column Labels.
XP 1 Tutorial 4 Designing a Web Page with Tables.
XHTML1 Tables N100 Creating a Simple Web Page. XHTML2 Creating Basic Tables Tables are collections of rows and columns that you use to organize and display.
Identifies the Structure Table Row Column 1 Table Heading Column 2.
CIS 1315 – Web Development for Educators CIS 1315 HTML Tutorial 5: Working with Tables.
1 The Structure of a Web Table beginning of the table structure first row of three in the table end of the table structure table cells You do not need.
CHAPTER 11 Tables. How Are Tables Used Data Display  Very tidy and very useful Better Text Alignment  Putting text in tables allows you to format indents.
XHTML Tables. Tables create little boxes in which you can place things to keep them organized. The little boxes are called table cells. Tables are created.
HTML Comprehensive Concepts and Techniques Second Edition Project 3 Creating Tables in a Web Site.
Tutorial 5 Working with Web Tables. XP Objectives Explore the structure of a Web table Create headings and cells in a table Create cells that span multiple.
XP Using Frames in a Web Site Ali Alfayly. XP Tutorial Objectives Create frames for a Web site Control the appearance and placement of frames Control.
Lecture: Tables. Table Tags (all container tags) establishes a table (________) establishes a row (________) says what’s in the row more than one TD within.
1 eVenzia Technologies Learning HTML, XHTML & CSS Chapter 2.
CNIT 132 – Week 7 HTML - Tables. Tables on the World Wide Web A table can be displayed on a Web page either in a text or graphical format. A text table:
Designing a Web Page with Tables. A text table: contains only text, evenly spaced on the Web page in rows and columns uses only standard word processing.
Tutorial 5 Working with Tables and Columns
Tutorial 5 Working with Tables and Columns
XP Creating Web Pages with HTML, 3e Prepared by: C. Hueckstaedt, Tutorial 4 1 New Perspectives on Creating Web Pages with HTML Tutorial 4: Designing a.
Introducing Web Tables. Tables for tabulating items  Better looking  More flexibility  More efficient to explain information than plain text.
TABLES 1. In this chapter you will learn that tables have many uses in HTML. Objectives: Upon completing this section, you should be able to: 1. Insert.
ECA 228 Internet/Intranet Design I Tables. ECA 228 Internet/Intranet Design I Basic HTML Tables Created as a way to present rows and clumns of data.
Tutorial 5 Working with Web Tables. XP Objectives Explore the structure of a Web table Create headings and cells in a table Create cells that span multiple.
CIS234A- Lecture 7 Instructor Greg D’Andrea. Tables A table can be displayed on a Web page either in a text or graphical format. A text table: – contains.
Tables in HTML. Table Tag HTML tables always begin and end with a table tag. Syntax:
Lesson 7. Tables Table Tags and Attributes Tables HTML tables are used in two main ways: 1.To organize tabular data in a familiar spreadsheet-like way.
HTML ( HYPER TEXT MARK UP LANGUAGE ). What is HTML HTML describes the content and format of web pages using tags. Ex. Title Tag: A title It’s the job.
Computer Science 101 Lists and Tables. Lists Unordered lists - use a bullet Ordered lists - use a number, Roman numeral, or letter.
Copyright (c) 2004 Prentice-Hall. All rights reserved. 1 Committed to Shaping the Next Generation of IT Experts. Project 5: Working with Tables Kelly L.
CIS234A Lecture 8 Instructor Greg D’Andrea. Review Text Table contains only text, evenly spaced on the Web page in rows and columns uses only standard.
Unit 4 Create and Use Tables. TITLE CORNELL NOTES TOPIC: NOTES: Name: Date: 09/08/2009 Period : Summary: Reasons for using tables Unit 4 Page 1 Display.
CSE 409 – Advanced Internet Technology 1 DISCUSSION OF BASIC HTML TAGS.
20-753: Fundamentals of Web Programming 1 Lecture 6: Advanced HTML Fundamentals of Web Programming Lecture 6: Advanced HTML.
LINKING WEBPAGES USING HTML HYPERLINKS. Hyperlinks are text strings or images on a webpage which when clicked on, links to another section in the same.
Web Development Basics Lecture 2 – More HTML. Content  More text formatting  Map  Table  Frame  Form.
Tutorial 5 Working with Web Tables. New Perspectives on HTML, XHTML, and XML, Comprehensive, 3rd Edition 2 Objectives Learn and Apply the structure of.
Designing a Web Page with Tables
CNIT 131 HTML5 - Tables.
Yourfriendmanoj.wordpress.com Fb/yourfriendmanoj
Working with Tables: Module A: Table Basics
LAB Work 02 MBA 61062: E-Commerce
Tutorial 5 Working with Tables and Columns
Introduction to HTML.
New Perspectives on Creating Web Pages with HTML
Using HTML Tables SWBAT: - create tables using HTML
TABLES.
For the World Wide Web Styling Tables with CSS
Lesson 5: HTML Tables.
Presentation transcript:

Tutorial 4: Designing a Web Page with Tables Create a text table Create a table using the <TABLE>, <TH>, <TR> and <TD> tags Create table headers and captions Control the appearance of a table and table text An Example Table

Defining a Table Structure Column Heading 1 Heading 2 Heading 3 Cell 11 Data Cell 12 Cell 13 Cell 21 Cell 22 Cell 23 Row 2 Row 1 Row 3 General form of a table:

Essential tags used to construct a table… <TH>columnheading1</TH> <TH>columnheading2</TH> <TH>columnheading3</TH> </TR> <TD>cell11data</TD> <TD>cell12data</TD> <TD>cell13data</TD> <TD>cell21data</TD> <TD>cell22data</TD> <TD>cell23data</TD> </TABLE> Row 1 You do not need to indent the <TD> tags or place them on separate lines, but you may find it easier to interpret your code if you do so. After the table structure is in place, you’re ready to add the text for each cell. Row 2 Row 3

Viewing the example table set up in the browser Table Properties: CELLPADDING - spacing between the cell border and its contents in pixels CELLSPACING - space between table cells in pixels (default is 2) BORDERCOLOR – the border color BORDER – the width of the border in pixels <TABLE BORDER=20 BORDERCOLOR=NAVY CELLPADDING=1 CELLSPACING=10>

Special Note: Using the <PRE> Tag Creating Headings with the <TH> Tag HTML provides the <TH> tag for table headings. Text formatted with the <TH> tag is centered within the cell and displayed in a boldface font. The <TH> tag is most often used for column headings, but you can use it for any cell that you want to contain centered boldfaced text. Special Note: Using the <PRE> Tag The <PRE> tag creates preformatted text and retains any spaces or line breaks indicated in the HTML file. preformatted text is text formatted in ways that HTML would otherwise not recognize. The <PRE> tag displays text using a fixed-width font. By using the <PRE> tag, a text table can be displayed by all browsers, and the columns will retain their alignment no matter what font the browser is using.

Sample code for a table: <TABLE border=20 BORDERCOLOR=NAVY CELLPADDING=1 CELLSPACING=10> <CAPTION><FONT FACE="Comic Sans MS" SIZE=3>Golf Courses around Dallas</CAPTION> <TR BGCOLOR=PALEGREEN> <TH WIDTH=180><FONT FACE="Comic Sans MS" SIZE=3>Public</TH> <TH WIDTH=180 valign=center align=center> <FONT FACE="Comic Sans MS" SIZE=3>Private</TH></TR> <TR BGCOLOR=YELLOW> <TD WIDTH=180 valign=center align=center> <FONT FACE="Comic Sans MS" SIZE=3>Tenison</TD> <TD WIDTH=180 valign=center align=center> <FONT FACE="Comic Sans MS" SIZE=3>Oak Cliff</TD> </TR> <TR BGCOLOR=YELLOW> <TD WIDTH=180 valign=center align=center> <FONT FACE="Comic Sans MS" SIZE=3>Buffalo Creek</TD> <TD WIDTH=180 valign=center align=center> <FONT FACE="Comic Sans MS" SIZE=3>Royal Oaks</TD> </TR> </TABLE>

The same table when viewed in the browser

Tables with Different Borders Values <TABLE BORDER="5"> Only the outside border is affected by the border attribute; the internal gridlines are not affected. The size attribute is optional; if you don’t specify a size, the browser creates a table border 1 pixel wide. By default, browsers display tables without table borders. To vary the color of the border, use: <TABLE BORDERCOLOR="red"> for example

Tables with Different Cell Spacing Values <TABLE CELLSPACING=5> Setting the cellspacing to 0 reduces the width of the borders between individual table cells. This will not remove the border between the cells. The cellspacing attribute controls the amount of space inserted between table cells. The syntax for specifying the cell space is: <table cellspacing="value"> value is the width of the interior borders in pixels the default cell spacing is 2 pixels Cell spacing refers to the space between the cells.

Tables with Different Cell Padding Values <TABLE CELLPADDING=5> To control the space between the table text and the cell borders, add the cellpadding attribute to the table tag. The syntax for this attribute is: <table cellpadding="value"> value is the distance from the table text to the cell border, as measured in pixels the default cell padding value is 1 pixel Cell padding refers to the space within the cells.

Table Frames and Rules Two additional table attributes introduced in HTML 4.0 are the frames and rules attributes. With the frame and rule attributes you can control how borders and gridlines are applied to the table. The frames attribute allows you to determine which sides of the table will have borders. The frame attribute syntax is: <table frame="type"> type is either "box" (the default), "above", "below", "hsides", "vsides", "lhs", "rhs", or "void" The following slide illustrates these frame types

Effect of Different Frame Values The frames attribute is: supported by Internet Explorer version 4.0 and above supported by Netscape version 6.2, but not by earlier versions of Netscape CHECK THIS OUT for FIREFOX and SAFARI

Effect of Different Rules Values Creating Frames and Rules Continued The rules attribute lets you control how the table gridlines are drawn. The syntax of the rules attribute is: <table rules="type"> type is either "all", "rows", "cols", or "none" Effect of Different Rules Values The Rules Attribute The rules attribute is: supported by Internet Explorer version 4.0 and above it is not supported by any versions of Netscape CHECK THIS OUT

A Word about Creating a Table Caption HTML allows you to specify a caption for a table. The syntax for creating a caption is: <caption align="alignment">caption text</caption> alignment indicates the caption placement a value of "bottom" centers the caption below the table a value of "top" or "center" centers the caption above the table a value of "left" or "right" place the caption above the table to the left or right A Note about Creating a Table Captions: Only Internet Explorer supports all caption values. The <caption> tag works only with tables, the tag must be placed within the table structure. Captions are shown as normal text without special formatting. Captions can be formatted by embedding the caption text within other HTML tags. for example, place the caption text within a pair of <b> and <i> tags causes the caption to display as bold and italic

Inserting a Table Caption The following <CAPTION> code: <TR> Yields this view when loaded into the browser:

Aligning a Table and its Contents By default, a browser places a table on the left margin of a Web page, with surrounding text placed above and below the table. Aligning a Table on the Web Page To align a table with the surrounding text, use the align attribute as follows: align="alignment" alignment equals "left", "right", or "center" left or right alignment places the table on the margin of the Web page and wraps surrounding text to the side center alignment places the table in the horizontal center of the page, but does not allow text to wrap around it The align attribute is similar to the align attribute used with the <img> tag. The align attribute is available only with browsers that support HTML 3.2 or later.

Results of a Right-Aligned Table The following <TABLE> code: <TR> Yields this view when loaded into the browser: Notice that the table code is placed before the text in the <P> tag.

Working with Table Size The size of a table is determined by the text it contains in its cells. By default, HTML places text on a single line. As you add text in a cell, the width of the column and table expands to the edge of the page. once the page edge is reached, the browser reduces the size of the remaining columns to keep the text to a single line You can insert a line break, paragraph or heading tag within a cell. The syntax for specifying the table size is: <table width="size" height="size"> size is the width and height of the table as measured in pixels or as a percentage of the display area To create a table whose height is equal to the entire height of the display area, enter the attribute height="100%". If you specify an absolute size for a table in pixels, its size remains constant, regardless of the browser or monitor settings used. Remember that some monitors display Web pages at a resolution of 640 by 480 pixels. Limit table sizes to about 600 pixels to prevent the table from expanding beyond the viewing area of the browser.

Defining Cell and Column Sizes To set the width of an individual cell, add the width attribute to either the <TD> or <TH> tags. The syntax is: width="value" value can be expressed either in pixels or as a percentage of the table width a width value of 30% displays a cell that is 30% of the total width of the table A pixel value or a percentage entered depends on whether a table will be a specific size or fill a relative space. Specifying a width for an individual cell does not guarantee that the cell will be that width when displayed in the browser. the reason for this is that the cell is part of a column containing other cells. Set the width of all the cells in the column to the same value to ensure that the cells do not change in size.

Defining Cell and Column Sizes Continued The height attribute can be used in the <TD> or <TH> tags to set the height of individual cells. The height attribute is expressed either in pixels or as a percentage of the height of the table. If you include more text than can be displayed within that height value you specify, the cell expands to display the additional text. Don’t forget that the <TH> tag automatically formats the cell as aligned in the center of the cell and in bold-face type. Aligning the Contents of a Table By default, cell text is placed in the middle of the cell, aligned with the cell’s left edge. By using the align and valign attributes, you can specify the text’s horizontal and vertical placement. To align the text for a single column, you must apply the align attribute to every cell in that column.

Values of the Align and Valign Attributes

This column is WIDTH="150"; also, cell11 and cell12 are ALIGN=CENTER The following code: Table Row HEIGHT=50 Yields this view when loaded into the browser: This column is WIDTH="150"; also, cell11 and cell12 are ALIGN=CENTER

Spanning Rows and Columns To merge several cells into one, you need to create a spanning cell. A spanning cell is a cell that occupies more than one row or column in a table. Spanning cells are created by inserting the rowspan and colspan attribute in a <TD> or <TH> tag. The syntax for these attributes is: rowspan="value" colspan="value" value is the number of rows or columns that the cell spans in the table When a cell spans several rows or columns, it is important to adjust the number of cell tags used in the table row. When a cell spans several rows, the rows below the spanning cell must also be adjusted.

Example of Spanning Cells using COLSPAN The following code: Yields this view when loaded into the browser: Notice that the first row has only one <TH> tag. This is because there is only one cell in the first row.

A Table Structure with a Row-Spanning Cell HTML code resulting table four table cells in the first row only three table cells are required for the second and third rows

An Example of Spanning Cells 5 <TD>’s Only 4 <TD>’s in this row. Notice there are five <TD>’s in the first <TR> and only four in the second <TR>

Applying a Background Color Table elements support the BGCOLOR attribute. To specify a background color for all of the cells in a table, all of the cells in a row, or for individual cells, by adding the bgcolor attribute to either the <TABLE>, <TR>, <TD>, or <TH> tags as follows: <TABLE BGCOLOR="color"> <TR BGCOLOR="color"> <TD BGCOLOR="color"> <TH BGCOLOR="color"> Where color is either a color name or hexadecimal color value You cannot set a background color for a column with a single attribute; to set the background color for an entire column, you must define the background color for each cell in that column. The color defined for a cell overrides the color defined for a row, and the color defined for a row overrides the color defined for a table.

Specifying Table, Row, and Cell Colors The following code: Yields this view when loaded into the browser:

Using the BORDERCOLOR Attribute This figure shows that Internet Explorer applies the same color to all parts of the border, thus removing the 3-D effect; Netscape does not. <TABLE BORDER=10 BORDERCOLOR="blue"> Internet Explorer FireFox

Using the BORDERCOLORLIGHT Attribute The BORDERCOLORLIGHT and BORDERCOLORDARK Attributes Using the BORDERCOLORLIGHT Attribute This figure shows an example of the use of the bordercolor and bordercolorlight attributes to create a 3-D colored border in Internet Explorer. Netscape does not support these attributes. <TABLE BORDER=10 BORDERCOLOR=blue BORDERCOLORLIGHT="#b2b2ff"> Internet Explorer

Applying a Background Image to a Table, Row, and Cell This figure shows examples of the background attribute applied to three sample tables. (Not recommended.) parch.jpg <table background="parch.jpg"> <tr background="parch.jpg"> <td background="parch.jpg">

A Special Note: Comment Tags Comment tags can aid in viewing your HTML file by describing the different sections of the code. The syntax for creating a comment tag is: <! Comment text> comment text is the text that you want to insert into the comment Any text appearing within the comment tag is ignored by the browser and not displayed in the page.