<th> Tag Syntax
<body> ... flow content expected ... <table> <thead> <tr> <th colspan="n">...</th> ... </tr> <tr> <th>...</th> ... </tr> ... </thead> <tbody> ... </tbody> </table> ... </body>
Rules for coding the HTML th
element
Make sure you understand the difference between a tag and element and are familiar with the definitions of namespace and other HTML terms.
- Inside a tr element code one or more th elements, one for each heading cell in the row.
- Begin the element for each heading cell with a starting <th> tag. The element name uses lower case letters and should be in the HTML namespace, which it will pick up automatically from the
xmlns
attribute on the <html> tag. - Include any attributes of the <th> tag as appropriate.The
colspan
attribute androwspan
attribute allow merging cells from multiple heading columns and/or rows. - End the th element with a matching
</th>
closing tag. (To ensure tags match up properly, it helps to code the starting and ending tags first, then fill in between them.) - Between the
<th>
starting tag and the</th>
ending tag include the inner HTML flow content for the heading. - Code separate th elements for any additional headings in the same table row before the </tr> tag for the end of the row.