⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 html_tables.asp@output=print

📁 W3Schools tutorial..web designing
💻 ASP@OUTPUT=PRINT
字号:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html lang="en-US" xml:lang="en-US" xmlns="http://www.w3.org/1999/xhtml">
<head>

<title>HTML Tables</title>
 
<link rel="shortcut icon" href="../favicon.ico" type="image/x-icon" />
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<meta name="Keywords" content="xml,tutorial,html,dhtml,css,xsl,xhtml,javascript,asp,ado,vbscript,dom,sql,colors,soap,php,authoring,programming,training,learning,beginner's guide,primer,lessons,school,howto,reference,examples,samples,source code,tags,demos,tips,links,FAQ,tag list,forms,frames,color table,w3c,cascading style sheets,active server pages,dynamic html,internet,database,development,Web building,Webmaster,html guide" />

<meta name="Description" content="Free HTML XHTML CSS JavaScript DHTML XML DOM XSL XSLT RSS AJAX ASP ADO PHP SQL tutorials, references, examples for web building." />

<meta http-equiv="pragma" content="no-cache" />
<meta http-equiv="cache-control" content="no-cache" />

<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "../../https@ssl./default.htm" : "../../www./default.htm");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-3855518-1");
pageTracker._initData();
pageTracker._trackPageview();
</script>

</head>
<body>

<p>From <b>http://www.w3schools.com</b> (Copyright Refsnes Data)</p>


<h1>HTML Tables</h1>
<a href="html_frames.asp"><img border="0" src="../images/btn_previous.gif" width="100" height="20" alt="Previous" /></a>
<a href="html_lists.asp"><img border="0" src="../images/btn_next.gif" width="100" height="20" alt="Next" /></a>

<hr />
<p class="intro">With HTML you can create tables.</p>
<hr />
<h2>Examples</h2>

<p><a target="_blank" href="tryit.asp@filename=tryhtml_tables">Tables</a><br />
This example demonstrates how to create tables in an HTML document.</p>

<p><a target="_blank" href="tryit.asp@filename=tryhtml_table_borders">Table borders</a><br />
This example demonstrates different table borders.</p>

<p>(You can find more examples at the bottom of this page)</p>

<hr />
<h2>Tables</h2>
<p>Tables are defined with the &lt;table&gt; tag. A table is divided into rows
(with the &lt;tr&gt; tag), and each row is divided into data cells
(with the &lt;td&gt; tag). The letters td stands for "table data," which is the
content of a data cell. A data
cell can contain text, images, lists, paragraphs, forms, horizontal rules,
tables, etc.</p>
<table width="100%" class="ex" cellspacing="0" border="1">
    <tr>
      <td>
        <pre>&lt;table border=&quot;1&quot;&gt;
&lt;tr&gt;
&lt;td&gt;row 1, cell 1&lt;/td&gt;
&lt;td&gt;row 1, cell 2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;row 2, cell 1&lt;/td&gt;
&lt;td&gt;row 2, cell 2&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;</pre>
      </td>
    </tr>
</table>
<p>How it looks in a browser:</p>
<table border="1">
<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>
<br />
<hr />

<h2>Tables and the Border Attribute</h2>
<p>If you do not specify a border attribute the table will be displayed without any
borders. Sometimes this can be useful, but most of the time, you want the
borders to show.
</p>
<p>To display a table with borders, you will have to use the border attribute:</p>
<table width="100%" class="ex" cellspacing="0" border="1">
    <tr>
      <td>
        <pre>&lt;table border=&quot;1&quot;&gt;
&lt;tr&gt;
&lt;td&gt;Row 1, cell 1&lt;/td&gt;
&lt;td&gt;Row 1, cell 2&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;</pre>
      </td>
    </tr>
</table>
<br />
<hr />
<h2>Headings in a Table</h2>
<p>Headings in a table are defined with the &lt;th&gt; tag.</p>
<table width="100%" class="ex" cellspacing="0" border="1">
    <tr>
      <td>
        <pre>&lt;table border=&quot;1&quot;&gt;
&lt;tr&gt;
&lt;th&gt;Heading&lt;/th&gt;
&lt;th&gt;Another Heading&lt;/th&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;row 1, cell 1&lt;/td&gt;
&lt;td&gt;row 1, cell 2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;row 2, cell 1&lt;/td&gt;
&lt;td&gt;row 2, cell 2&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;</pre>
      </td>
    </tr>
</table>
<p>How it looks in a browser:</p>
<table border="1">
<tr>
<th>Heading</th>
<th>Another Heading</th>
</tr>
<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>
<br />
<hr />
<h2>Empty Cells in a Table</h2>
<p>Table cells with no content are not displayed very well in most browsers.</p>
<table width="100%" class="ex" cellspacing="0" border="1">
    <tr>
      <td>
        <pre>&lt;table border=&quot;1&quot;&gt;
&lt;tr&gt;
&lt;td&gt;row 1, cell 1&lt;/td&gt;
&lt;td&gt;row 1, cell 2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;row 2, cell 1&lt;/td&gt;
&lt;td&gt;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;</pre>
      </td>
    </tr>
</table>
<p>How it looks in a browser:</p>
<table border="1">
<tr>
<td>row 1, cell 1</td>
<td>row 1, cell 2</td>
</tr>
<tr>
<td>row 2, cell 1</td>
<td></td>
</tr>
</table>
<p>Note that the borders around the empty table cell are missing (NB! Mozilla 
Firefox displays the border).</p>

<p>To avoid this, add a non-breaking space (&amp;nbsp;) to
empty data cells, to make the borders visible:&nbsp;</p>
<table width="100%" class="ex" cellspacing="0" border="1">
    <tr>
      <td>
        <pre>&lt;table border=&quot;1&quot;&gt;
&lt;tr&gt;
&lt;td&gt;row 1, cell 1&lt;/td&gt;
&lt;td&gt;row 1, cell 2&lt;/td&gt;
&lt;/tr&gt;
&lt;tr&gt;
&lt;td&gt;row 2, cell 1&lt;/td&gt;
&lt;td&gt;&amp;nbsp;&lt;/td&gt;
&lt;/tr&gt;
&lt;/table&gt;</pre>
      </td>
    </tr>
</table>
<p>How it looks in a browser:</p>
<table border="1">
<tr>
<td>row 1, cell 1</td>
<td>row 1, cell 2</td>
</tr>
<tr>
<td>row 2, cell 1</td>
<td>&nbsp;</td>
</tr>
</table>
<br />

<hr />
<h2>Basic Notes - Useful Tips</h2>
<p>The &lt;thead&gt;,&lt;tbody&gt; and &lt;tfoot&gt; elements are seldom used,
because of bad browser support. Expect this to change in future versions of XHTML.
If you have Internet Explorer 5.0 or newer, you can view a <a href="../xml/tryit.asp@filename=cd_catalog_island_thead" target="_blank">working
example</a> in our XML tutorial.</p>

<hr />

<h2>More Examples</h2>

<p><a target="_blank" href="tryit.asp@filename=tryhtml_tables3">Table with no border</a><br />
This example demonstrates a table with no borders.</p>

<p><a target="_blank" href="tryit.asp@filename=tryhtml_table_headers">Headings in a table</a><br />
This example demonstrates how to display table headers.</p>

<p><a target="_blank" href="tryit.asp@filename=tryhtml_table_nbsp">Empty cells</a><br />
This example demonstrates how to use &quot;&amp;nbsp;&quot; to handle
cells that have no content.</p>

<p><a target="_blank" href="tryit.asp@filename=tryhtml_tables2">Table with a caption</a><br />
This example demonstrates a table with a caption.</p>

<p><a target="_blank" href="tryit.asp@filename=tryhtml_table_span">Table cells that span more
than one row/column</a><br />
This example demonstrates how to define table cells that span more than
one row or one column.</p>

<p><a target="_blank" href="tryit.asp@filename=tryhtml_table_elements">Tags inside a table</a><br />
This example demonstrates how to display elements inside other elements.</p>

<p><a target="_blank" href="tryit.asp@filename=tryhtml_table_cellpadding">Cell padding</a><br />
This example demonstrates how to use cellpadding to create more white space
between the cell content and its borders.</p>

<p><a target="_blank" href="tryit.asp@filename=tryhtml_table_cellspacing">Cell spacing</a><br />
This example demonstrates how to use cellspacing to increase the distance
between the cells.</p>

<p><a target="_blank" href="tryit.asp@filename=tryhtml_table_background">Add a background color
or a background image to a table</a><br />
This example demonstrates how to add a background to a table.</p>

<p><a target="_blank" href="tryit.asp@filename=tryhtml_table_cellbackground">Add a background
color or a background image to a table cell</a><br />
This example demonstrates how to add a background to one or more table cells.</p>

<p><a target="_blank" href="tryit.asp@filename=tryhtml_table_align">Align the content in a table
cell</a><br />
This example demonstrates how to use the &quot;align&quot; attribute to align
the content of cells, to create a &quot;nice-looking&quot; table.</p>

<p><a target="_blank" href="tryit.asp@filename=tryhtml_table_frame">The frame attribute</a><br />
This example demonstrates how to use the &quot;frame&quot; attribute to control
the borders around the table.</p>

<p>
<a target="_blank" href="../tags/tryit.asp@filename=tryhtml_table_frame2">The frame and border attributes</a><br />
How to use the &quot;frame&quot; and &quot;border&quot; attributes to control the borders around the table.</p>

<hr />

<h2>Table Tags</h2>

<table class="ex" cellspacing="0" border="1" width="100%">
<tr>
<th align="left">Tag</th>
<th align="left">Description</th>
</tr>
<tr>
<td><a href="../tags/tag_table.asp">&lt;table&gt;</a></td>
<td>Defines a table</td>
</tr>
<tr>
<td><a href="../tags/tag_th.asp">&lt;th&gt;</a></td>
<td>Defines a table header</td>
</tr>
<tr>
<td><a href="../tags/tag_tr.asp">&lt;tr&gt;</a></td>
<td>Defines a table row</td>
</tr>
<tr>
<td><a href="../tags/tag_td.asp">&lt;td&gt;</a></td>
<td>Defines a table cell</td>
</tr>
<tr>
<td><a href="../tags/tag_caption.asp">&lt;caption&gt;</a></td>
<td>Defines a table caption</td>
</tr>
<tr>
<td><a href="../tags/tag_colgroup.asp">&lt;colgroup&gt;</a></td>
<td>Defines groups of table columns</td>
</tr>
<tr>
<td><a href="../tags/tag_col.asp">&lt;col&gt;</a></td>
<td>Defines the attribute values for one or more columns in a table</td>
</tr>
<tr>
<td><a href="../tags/tag_thead.asp">&lt;thead&gt;</a></td>
<td>Defines a table head</td>
</tr>
<tr>
<td><a href="../tags/tag_tbody.asp">&lt;tbody&gt;</a></td>
<td>Defines a table body
</td>
</tr>
<tr>
<td><a href="../tags/tag_tfoot.asp">&lt;tfoot&gt;</a></td>
<td>Defines a table footer
</td>
</tr>
</table>
<br />
<hr />
<a href="html_frames.asp"><img border="0" src="../images/btn_previous.gif" width="100" height="20" alt="Previous" /></a>
<a href="html_lists.asp"><img border="0" src="../images/btn_next.gif" width="100" height="20" alt="Next" /></a>

<p>From <b>http://www.w3schools.com</b> (Copyright Refsnes Data)</p>

</body>
</html>

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -