Question HTML - tables

Do you have a question? Post it now! No Registration Necessary.  Now with pictures!

Threaded View
Hello everybody,

here's my problem :
I have a table with 3 rows and 2 columns. Is it possible to right-align
the text in the left column without writing thrice "<td align="right">" ?

Here's the code :

             " ">
       <table border="1" width="20%">
              <td colspan="2" align="center">Data</td>

              <td>A</td><td align="right">1</td>

              <td>B</td><td align="right">2</td>

              <td>C</td><td align="right">3</td>


Re: Question HTML - tables

Rom wrote:
Quoted text here. Click to load it

Since your "Data" and "A", "B" & "C" cell appear to be heading not data
cells, style them differently, (look up TH element).

In your stylesheet:

TABLE { width: 20%, border: 1px solid black; }
TH, TD { border: 1px solid black; }
TD { text-align: right; }

Your HTML:

    <tr><th colspan="2">Date</th></tr>

If you want more that one type of styling for your data cell then create
classes like:

.totals, .bucks { text-align: right: padding-right: .5em; }
.totals { font-weight: bold; }

Take care,

Re: Question HTML - tables

Jonathan N. Little a écrit :
Quoted text here. Click to load it
Thanks. that's precisely what I was looking for ;)
See you.

Site Timeline