250 likes | 378 Views
HTML Overview. Part 4 – Tables. HTML Tables. Tables are defined with the <table> </table> tag pair. A table is divided into rows with < tr > </ tr > tag pairs. tr stands for "table row" E ach row is divided into data cells with <td> </td> tag pairs.
E N D
HTML Overview Part 4 – Tables
HTML Tables • Tables are defined with the <table></table>tag pair. • A table is divided into rows with <tr></tr>tagpairs. • trstands for "table row" • Each row is divided into data cells with <td></td>tag pairs. • tdstands for "table data," and holds the content of a data cell. • A <td>tag can contain text, links, images, lists, forms, other tables, etc.
Parts of a Table • table header: • A cell with bold, centered text in the first row of the table. • <th></th> creates a table header
table row: • <tr></tr> defines the start and end of a table row
table cell: • Each “box” in the table is called a cell. • <td></td> defines the start and end of a table cell
HTML Table Example <table><tr><td>row 1, cell 1</td><td>row 1, cell 2</td></tr><tr><td>row 2, cell 1</td><td>row 2, cell 2</td></tr></table>
Table Attributes • The opening <table> tag may also contain attributes for the table: • <table border=“value”> specifies the thickness of the cell borders in pixels • <table cellpadding=“value”> sets the amount of space between the cells in the table • <table width=“value”> specifies the width of the table either in the number of pixels or as a percentage of the page width.
Table With Borders • If you do not specify a border attribute, the table will be displayed without borders. To display a table with borders, specify the border attribute: <table border="1"><tr><td>Row 1, cell 1</td><td>Row 1, cell 2</td></tr></table>
Tables Without Borders <h4>This table has no borders:</h4> <table> <tr> <td>100</td> <td>200</td> <td>300</td> </tr> <tr> <td>400</td> <td>500</td> <td>600</td> </tr> </table>
Table Headers <h4>Table headers:</h4> <table border="1"> <tr> <th>Name</th> <th>Telephone</th> <th>Telephone</th> </tr> <tr> <td>Bill Gates</td> <td>555 77 854</td> <td>555 77 855</td> </tr> </table>
Table With a Caption <table border="1"> <caption>Monthly savings</caption> <tr> <th>Month</th> <th>Savings</th> </tr> <tr> <td>January</td> <td>$100</td> </tr> <tr> <td>February</td> <td>$50</td> </tr> </table>
Cell Padding Use cellpadding to create more white space between the cell content and its borders. <h4>With cellpadding:</h4> <table border="1“ cellpadding="10"> <tr> <td>First</td> <td>Row</td> </tr> <tr> <td>Second</td> <td>Row</td> </tr> </table>
Cell Spacing Use cellspacing to increase the distance between the cells. <h4>With cellspacing:</h4> <table border="1" cellspacing="10"> <tr> <td>First</td> <td>Row</td> </tr> <tr> <td>Second</td> <td>Row</td> </tr> </table>
Tags Inside a Table <table border="1"> <tr> <td> <p>This is a paragraph</p> <p>This is another paragraph</p> </td> <td>This cell contains a table: <table border="1"> <tr> <td>A</td> <td>B</td> </tr> <tr> <td>C</td> <td>D</td> </tr> </table> </td> </table>
HTML Overview Part 4 – Hyperlinks
A hyperlink is is a word, group of words, or image that you can click on to jump to a new document . • Hyperlinks are displayed in blue underlined text in the browser window. • Visited hyperlinks are displayed in purple underlined text. • The anchor tag <a></a>tells the browser the text inside the tag is a hyperlink and. • The href attribute sets the URL of the destination page. <a href=“url”>Link Text</a> This text will display as the hyperlink on your page.
A hyperlink is is a word, group of words, or image that you can click on to jump to a new document . • Hyperlinks are displayed in blue underlined text in the browser window. • Visited hyperlinks are displayed in purple underlined text. • The anchor tag <a></a> tells the browser the text inside the tag is a hyperlink and. • The hrefattribute sets the URL of the destination page. <a href=“url”>Link Text</a> This is the URL of the destination site.
A hyperlink is is a word, group of words, or image that you can click on to jump to a new document . • Hyperlinks are displayed in blue underlined text in the browser window. • Visited hyperlinks are displayed in purple underlined text. • The anchor tag <a></a> tells the browser the text inside the tag is a hyperlink and. • The hrefattribute sets the URL of the destination page. <a href=“url”>Link Text</a>
HTML Links Example <p> <a href="default.asp">HTML Tutorial</a> This is a link to a page on this website. </p> <p> <a href="http://www.google.com/">Google</a> This is a link to a website on the World Wide Web. </p>
Assignment Work through the W3Schools HTML Tables tutorial http://www.w3schools.com/html/html_tables.asp and the HTML Hyperlinks tutorial http://www.w3schools.com/html/html_links.asp Complete Practice: Computer Viruses – part 3 of 5 Save your file as lastname_computer_viruses2