columns and text formatting

  • Thread starter Thread starter Chi
  • Start date Start date
C

Chi

Hi,
My table has two columns. NAME and INFORMATION
I would like to have all data entered in NAME column has a “left “alignment
and all data entered in INFORMATION column has “center†alignment.
Instead of using the left or center function, I would like to have a style
sheet ,CSS , to control the table formatting.
Please show me the codes.
Thank you
Chi
 
See http://www.w3schools.com for a CSS tutorial.

For your specific case:

<style type="text/css">
td {vertical-aline: top;} /* sets content of all cells to the top of
the cell */
..tdc {text-align: center;} /* all html elements with class tdc will be
center aligned */
..tdl {text-align: left;}
</style>

Your table will be:

<table>
<tr>
<th class="tdl">Name</th><th class="tdc">INFORMATION</th>
</tr>
<tr>
<td class="tdl">Ron</td><td class="tdc">MVP Expression</td>
</tr>
</table>

Table cells will naturally left align text unless told to do otherwise,
so the tdl class and style definition may not be required.
 
Ron,

I sometimes have problems with using CSS to align the contents of table
cells, but I usually get there.

Anyway, I wondered what this CSS code was:
td {vertical-aline: top;}

I was thinking in terms of "What is 'aline' ?" Is it a line at the top of
the cell or what?

Then the penny dropped - you meant
td {vertical-align: top;}

BTW,
I was not trying to be "clever". I genuinely didn't understand it (a senior
moment perhaps) and the OP might need to have this corrected.
 
The OP will need to correct that. Definitely a senior moment - at 5am
after little sleep (not that that is an excuse...).

The CSS should be:

<style type="text/css">
td {vertical-align: top;} /* sets content of all cells to the top of
the cell */
..tdc {text-align: center;} /* all html elements with class tdc will be
center aligned */
..tdl {text-align: left;}
</style>

--
Ron Symonds - Microsoft MVP (Expression)
Reply only to group - emails will be deleted unread.

http://www.rxs-enterprises.org/fp
 
Ronx said:
The OP will need to correct that. Definitely a senior moment - at 5am
after little sleep (not that that is an excuse...).

Thanks, Ron

But I meant that it was MY senior moment.

If I am familiar with CSS as I should be, then it would have been clear to
me.
 
Thank you Ronx!!

It works perfectly!

Chi

Ronx said:
See http://www.w3schools.com for a CSS tutorial.

For your specific case:

<style type="text/css">
td {vertical-aline: top;} /* sets content of all cells to the top of
the cell */
..tdc {text-align: center;} /* all html elements with class tdc will be
center aligned */
..tdl {text-align: left;}
</style>

Your table will be:

<table>
<tr>
<th class="tdl">Name</th><th class="tdc">INFORMATION</th>
</tr>
<tr>
<td class="tdl">Ron</td><td class="tdc">MVP Expression</td>
</tr>
</table>

Table cells will naturally left align text unless told to do otherwise,
so the tdl class and style definition may not be required.

--
Ron Symonds - Microsoft MVP (Expression)
Reply only to group - emails will be deleted unread.

http://www.rxs-enterprises.org/fp
 
Back
Top