HTML and CSS Reference
In-Depth Information
or height that is a percentage of what is available to the element. Example 2.8
shows a loated table with a width attribute. he tr element deines a table row,
and the th and td elements deine table cells. Tables are discussed in more
detail later in this chapter.
Example 2.8: An HTML table with width and float attributes
<!DOCTYPE html>
<html>
<head>
<title>Example 2.8</title>
<style type="text/css">
body { padding: 30px; line-height: 1.5em; }
td { text-align: right; padding: 5px; }
th { text-align: left; padding: 5px; }
</style>
</head>
<body>
<h2 align="center"> Final Exam Results </h2>
<table width="33%" align="right" hspace="12" border="1">
<tr><th></th><th> Points </th><th> Grade </th></tr>
<tr><th> Larry </th><td> 86 </td><td> B+ </td></tr>
<tr><th> Heidi </th><td> 91 </td><td> A </td></tr>
</table>
<p> The final exam required students to create an HTML page
containing a floating table. Larry lost a number of points
because he used <em> align </em> and <em> hspace </em> attributes in
the table statement instead of using the CSS <em> float </em> and
<em> padding </em> properties in his entry entitled, <cite> Example
2.8 </cite> . </p>
</body>
</html>
Note the use of the cite element to mark up a title. Figure 2.8 shows how
this HTML appears in a browser.
 
 
Search WWH ::




Custom Search