Quantcast
Channel: HTML Renderer
Viewing all articles
Browse latest Browse all 693

New Post: Centering tables

$
0
0
Hello,

first, thanks for this awesome project.

I am having a little problem with centering tables. Here is an example of an HTML document that I'd like to render:
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Centered table</title>
<style type="text/css">
body { font: 12px tahoma,12px helvetica,12px arial,12px verdana; }
table { border-collapse: collapse; }
th { border: 1px solid black; text-align: center; vertical-align: middle; }
td { border: 1px solid black; text-align: left; vertical-align: middle; }
tr { border: 1px solid black; text-align: left; vertical-align: middle; }
</style>
</head>
<body>
<div align="center">
<table border="0" cellpadding="2" cellspacing="0">
<tbody>
<tr><td colspan="2"><b>Field 1</b></td></tr>
<tr><td>&#160;&#160;&#160;&#160;Sub field 1</td><td>Value</td></tr>
<tr><td>&#160;&#160;&#160;&#160;Sub field 2</td><td>Value</td></tr>
<tr><td>&#160;&#160;&#160;&#160;Sub field 3</td><td>Value</td></tr>
<tr><td colspan="2"><b>Field 2</b></td></tr>
<tr><td>&#160;&#160;&#160;&#160;Sub field 1</td><td>Value</td></tr>
<tr><td>&#160;&#160;&#160;&#160;Sub field 2</td><td>Value</td></tr>
<tr><td>&#160;&#160;&#160;&#160;Sub field 3</td><td>Value</td></tr>
</tbody>
</table>
</div>
</body>
</html>
Everything renders just fine except that the table is not centered. I've tried as many centering methods as I could come up with but the table is always left-aligned. Maybe I missed the correct way how to center the table (HTML is just not my level of expertize) and therefore I am wondering, is it possible to center a table?

Viewing all articles
Browse latest Browse all 693

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>