Unit 5 – HTML Tables Instructor: Brent Presley.

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

Chapter 3 – Web Design Tables & Page Layout
Table (TABLE) Contains TABLE ROWS (TR) Contains TABLE DATA (TD) Data can contain anything Text Lists Other tables Pictures …
Internet Basics & Way Beyond!
9-May-15 More CSS. 2 A different emphasis CSS is the same for XML as it is for HTML and XHTML, but-- XML contains no display information If you want your.
Today’s objectives Site performance Padding, Margins, Borders
Week 9 Using the Box Properties. 9-2 The CSS Visual Formatting Model Describes how the element content boxes should be displayed by the browser –Based.
CSS: Class 1 Background Images, Controlling Position of Background Images, Add Padding to Page Elements, Add Borders to Elements on a Page.
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
Tutorial 4: Designing a Web Page with Tables
Text Properties, Line Box, CSS. Text Properties Properties related to the display of text. Text-align : left, right, center I like FSU!
Cos 125 Day 22. Agenda Assignment 6 Not corrected Waiting for tune-ins Assignment 7 is posted Assignment 7 Due April 2PM Left to do 1 Assignments.
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.
Cos 125 Day 24. Agenda All students meeting 7 Pm Monday, April 19 UMS Strategic Plan Assignment #7 Posted Due April 20 Two (one?) more to go Quiz Four.
Creating a Web Page with Tables. Objectives Create a text table with preformatted text Create the basic structure of a graphical table Organize table.
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.
MORE Cascading Style Sheets (The Positioning Model)
14-Jul-15 CSS Applications to XML. 2 A different emphasis CSS is the same for XML as it is for HTML, but-- HTML already does a pretty good job of layout.
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.
Using HTML to Create Tables in Web pages Connie Lindsey November 2005.
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.
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.
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.
Principles of Web Design 6 th Edition Chapter 10 – Data Tables.
CO1552 – Web Application Development Lists, Special Characters, and Tables.
Actual Building the Pages Tables. Using Table Elements  To build effective page templates, you must be familiar with the HTML table elements and attributes.
The Missing Manual MARGINS, PADDING, & BORDERS—CHAPTER 7.
CHAPTER 10 Formatting Tables and Forms. Using Tables the Right Way  HTML and XHTML have a LOT of tags dedicated to building a table  If you have only.
10/4/2015Tables1 Spring, 2008 Modified by Linda Kenney 4/2/08.
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:
INTRODUCTION TO WEB DEVELOPMENT AND HTML Lecture 10: A Deeper Look at CCS- Spring 2011.
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.
INTRODUCTORY Tutorial 4 Exploring Graphic Elements and Images.
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.
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.
Table (TABLE) Contains TABLE ROWS (TR) Contains TABLE DATA (TD) Data can contain anything › Text › Lists › Other tables › Pictures › …
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.
Chapter 5 Creating Page Templates. Principles of Web Design 2nd Ed. Chapter 5 2 Principles of Web Design Chapter 5 Objectives Understand table basics.
HTML Tables The HTML table model allows authors to arrange data - text, preformatted text, images, links, forms, form fields, other tables, etc. - into.
1 CS428 Web Engineering Lecture 08 Border, Margin, Padding … (CSS - III)
CSS Layout Cascading Style Sheets. Lesson Overview  In this lesson, you will learn:  CSS Box Model  CSS properties for border  CSS properties for.
How To Create HTML Tables. Table Structure General HTML code for a Web Table: table cells table cells.
Positioning Objects with CSS and Tables
Coding with HTML {. THE BASICS { What is HTML and how can you use it to make websites?
Session: 9. © Aptech Ltd. 2Creating Tables / Session 9  Describe how to create and format tables  Explain the table size and the width of a column 
CSS Box Model. What is the Box Model? Each XHTML element appearing on our page takes up a "box" or "container" of space. Each box size is affected not.
Tutorial #5 Working with the Box Model. Tutorial #4 Review - CSS Create a homework page Final Project Discussion Exam on Blackboard Styling Lists (List-style-type,
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.
Cascading Style Sheets Boxes
CSS Layouts: Grouping Elements
LAB Work 02 MBA 61062: E-Commerce
Using HTML Tables SWBAT: - create tables using HTML
DREAMWEAVER MX 2004 Chapter 3 Working with Tables
Presentation transcript:

Unit 5 – HTML Tables Instructor: Brent Presley

ASSIGNED READING Chapter 4, Page

PLANNING –Tables are used to create tables/columns of data on a web page. Tables can also be used to align text and images in almost any fashion you want on a web page, but current guidelines recommend you use div tags whenever possible instead. –Creating tables on the fly can be a very difficult process, particularly if the tables are complex and even more so if you need to embed one table within another. –Consider making a drawing that shows how you want your table cells to appear.

DEFINING A TABLE STRUCTURE –A table is composed of many rows each of which has many cells. –You use containers (tags) to define the boundaries of the table, beginning and end of each row, and the beginning and end of each cell. – define the beginning and end of the table – (table row) define the beginning and end of each row within the table – (table data) define the beginning and end of each cell within a row. – (table header) define the column headers for the table. Technically, they can appear anywhere in the table definition, but normally they form the cells in the first row of the table. Headers work just like td ’s except they are automatically boldfaced and centered in the cell.

DEFINING A TABLE STRUCTURE Tables can also include a caption that appears either above or below the table. your caption’s text here NOTE: the align="position" element is deprecated. –Position can be : top (positioned above table) bottom (below table) Text-align is specified just like text: left, center, right –Default is center

GENERAL LAYOUT

DEFINING A TABLE STRUCTURE Each row in the table should have the same number of cells. The cells in the same position of the rows form the table columns. HTML provides no direct control or definition of columns. I recommend laying out the structure of your table first, then adding the contents of each cell. See general layout example above. –Tip: Instead of Row 1, Column 1 using a non-breaking space as the initial contents of the cell. If you don’t put anything between the tags, the entire row is collapsed. Column widths are determined by the data entered in the cells (determined by HTML), but you can modify them using table styles.

TABLE ROW GROUPS –Row groups allow you to apply formatting to more than one row of cells. –Row groups are also used when importing data from other sources. This data may spill over multiple pages and the row groups allow header rows and footer rows to be repeated on those pages. –To create a row group, add any of the following tags around a group of row tags. –If you include more than one of the row group types, you must provide them in the order listed. –Note particularly that the tfoot tag must appear before the tbody tag. –If you include more than one of the row group types, you must provide them in the order listed.

TABLE BORDERS NOTE: the border= bordercolor= bordercolorlight= bordercolordark= attributes are all deprecated. By default, tables appear without borders By adding styles to the table tag, you can control how borders display in the table Tables include two types of the borders: –Outside borders of the table Controlled in the table tag –Inside borders of the table Controlled in the table data (td) tag –Both are defined using a 3-part style

TABLE BORDERS style="border: 1px maroon solid; " –The first value designates how wide the border is. –The second value designates the border’s color you can use names, RGB or hexadecimal values –The final value designates the line style of the border Solid is most common Dashed and dotted are also available (among other odd styles) –You may leave off the size (default is 2 px) or the color (default is gray), but you must designate a line style (default is none) –These can be listed in any order Change the table border to 2px solid red

MANAGING INSIDE TABLE BORDERS Inside border issues –First of all, it’s a pain to have to designate a border style for every cell tag in a table (particularly if the table is large) To simplify designating the borders of all cells (td) we’ll use CSS Define a style that will be applied to all the tags (embedded or external) td {border: blue 1px solid} There is space between the inside border (see Cell Spacing below) The inside borders seem to be twice as thick (if cell spacing is 0). –Actually the borders of neighboring cells are both displaying next to each other. The cell borders and the table borders both display where they are adjacent to each other

BORDER SPACING If you want the extra spacing between borders, you can control how much space is between the borders using the border-spacing style in the table tag style="border-spacing:5px; " –Default value is 2 pixels Controls the width of the space between borders –Minimum=0, but borders still display as long as there’s a table border The borders of both adjacent cells display so borders appear twice as thick as when you use the border-collapse style

BORDER SPACING The easiest way to merge all the borders, removing the extra space between the borders is to use a table style: <table style="border-collapse: collapse; " –This style tells the browser to remove overlapping borders. –Using both border-collapse and border-spacing in the same style doesn’t make sense.

UNIT 5 EXAMPLE Change border-spacing value from 5 to 10, then from 10 to 0 and observe the changes Set table style to collapse borders

CELL PADDING –(Cell style) padding:"value" Controls the spacing between the data within the cell and the cell borders (all four borders). Default is 0, but text often looks crowded in the cell. Be sure to designate the measurement type for value This style needs to be applied to each cell ( td ) in the table. –Include in embedded style used to set cell borders padding: 10px 5px 10px 5px; –Applies a 10px padding to top; 5px padding to the right, 10px padding to the bottom and 5px padding to the left sides of the cell –Note these measurements (top, right, bottom, left) are designated in clockwise order. padding-top: 10px; –Applies a 10px padding to the top sides of the cell –padding-right, padding-bottom and padding-left available

UNIT 5 EXAMPLE Change cell padding from 2 to 5 to 10 (final at 5)

TABLE SIZE Initially, a table’s width is determined by the width of its columns whose width is determined by the width of the cells within the column whose width is determined by the widest item in each column –This is very flexible but may give your table an unbalanced look –You can control this width by setting the table’s width combined with setting the column (cell) width. You can control the total width of the table using a style within the table tag –width : value; –Value is normally designated as a percentage (e.g. 80%) or in pixels (px) If you use pixels, the table will always be the same size regardless of the window size. Percent will scale to window size –NOTE: the width= and height= attributes (not in a style) are deprecated. Table height is rarely specified. Table height is normally, automatically based on the number of rows in the table and height of those rows.

TABLE ALIGNMENT –Tables can be aligned with the surrounding text (text wraps around table) –In the table tag add: style="float:left" Table at left margin, text wraps around right side style="float:left" Table aligns on right margin, text wraps around left side Note, there is no float:center. You can’t wrap text around both sides of a table. –You can however center a table between the margins of the page (window)

UNIT 5 EXAMPLE Size the table to 80% width Center the table

CELL DATA FORMATTING –You format the contents of cells exactly the same way you format any other element—using styles Any non-style cell attribute is deprecated –If you apply a style to the table tag, the style applies to all cells in the table. –If you apply a style to a row tag, the style applies to the all the cells in the row. –If you apply a style to a cell tag, the style only applies to that cell. –Cell styles override row styles override table styles.

UNIT 5 EXAMPLE Change the font of the entire table Change the background color of the title row. add the sand.png to last two rows background image. Header height: 50 Vertical-align header bottom

CELL SIZE –HTML determines the size of a cell (and therefore a column) based on the data within the cell and the total space required for all cells. If you have set a table width, the column width is also dependent on the width of the table. –You can control the width of columns. If the data (text) in the cell doesn’t fit, HTML will wrap the text to a new line, automatically expanding the cell’s height. –NOTE: the width= a nd height= attributes (not in a style) are deprecated. –You can also change the height of a cell (or row), but this is less often used. Generally, the height of the row is left to HTML to determine.

CELL SIZE Adding the width and/or height to the td tag(s) allows you to change the width or height of an individual cell and its corresponding column of cells. –HTML automatically adjusts the width of all cells in a column to the size of the largest cell in the column –Specifying a width for a cell will prevent the cell’s column from resizing as the table (via the window) resizes. –The cell width will never be larger than you specify; however, the cell (column) may become narrower if the user shrinks the table an extreme amount –Cells will never shrink smaller than the width of the longest word in the cell (column) Again width and height can be specified as either pixels or a percentage. –Percentage here refers to percentage of the overall table size. –If you specify a total number of pixels that exceed table size, HTML will either adjust the table size or scroll as appropriate. Tip: Always leave the width of one column (and only one column) unspecified. This column will then stretch to fill the table regardless of the window or table size

CELL SIZE Tip: Always leave the width of one column (and only one column) unspecified. This column will then stretch to fill the table regardless of the window or table size unit 5 examples –Set the width of the header of column 1 to 110. – Note the effects on column 2 when you resize the window. – Set width of header 1 to 20% – Set width of table to 50%

SPANNING ROWS/COLUMNS –Spanning is HTML’s answer to merging cells (in Word). –Spanning is added to th or td tags only. –NOTE: these are not style elements, they are attributes (designated outside a style). There are no corresponding style elements. –colspan=x is used to designate that this cell spans x number of columns (merges that many cells horizontally to the right) –rowspan=x is used to designate that this cell spans x number of rows (merges that many cell vertically (down) –When spanning rows or columns, make sure the remaining td/th definitions match up appropriately Ensure each row in the table has the same number of cells (either individual or spanned). When designating a cell that spans rows, that cell’s definition is only included as part of the first row spanned.

TABLE TIPS Indent each and tag properly. Place comments at the beginning of each row describing what it holds (where possible) Instead of removing td tags to allow for spans, comment them out: Whenever you enter a colspan=x tag, remove x td tags from the row immediately after the td tag with the colspan in it. Whenever you enter a rowspan=x tag, remove 1 td tag from each of the following x rows. Build your table one cell (span) at a time. Work from the top down, left to right.

IN CLASS PROJECT –CREATE THIS TABLE

IN CLASS PROJECT 7 columns, 7 rows –Tip: place a non-breaking space in each cell. Add comments to beginning of each row describing purpose. Merge all the cells in the first row. Add text In row 2: span the first cell for 6 rows. Remove one cell from each of the following rows. Add days. Add times (right-aligned, width=45) Enter Excel Enter Prep And Grading (row span 4) remove a blank cell from following rows. Enter Troubleshooting Enter Donating Platelets Enter Meetings Set each column (Mon-Fri) to 18% of width

IN CLASS PROJECT Merge all cells under platelets Insert a 3 row, 3 column table (no borders) Merge the top & bottom row. Use sad face to fill merged cells the middle left and middle right cells In the middle cell and an unordered list of weekend tasks: Vacuum Scrub toilets Grading More prep Laundry

IN CLASS PROJECT –In addition to using the border: and border-color: styles described above, you can also control the border style and color of individual borders of the table or a cell –Set the three values (width, style, color) of a designated border: border-top: border-bottom: border-left: border-right: –Set the style of a designated border: border-top-style: border-bottom-style: border-left-style: border-right-style: –Set the color of a designated border: border-top-color: border-bottom-color: border-left-color: border-right-color: –Set the width of a designated border: border-top-width: border-bottom-width: border-left-width: border-right-width: This site has a cool try it feature for all table styles: