?
Solved

custom formating of <table>

Posted on 2005-02-27
6
Medium Priority
?
164 Views
Last Modified: 2010-04-09
In excel there is a way to automatically put a $ at the very left of each cell, and then have whatever number you put in go right aligned in the cell.  Is there any way to do that in an html table?  Thanks!

0
Comment
Question by:ARACK04
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
6 Comments
 
LVL 32

Expert Comment

by:Batalf
ID: 13415804
You could assign styles to a col tag.

<table border="1" width="500">
      <col style="text-align:right">
      <col>
      <tr>
            <td><p>Data</td>
            <td><p>Data</td>
      </TR>
      <tr>
            <td><p>Data</td>
            <td><p>Data</td>
      </TR>
</table>
0
 
LVL 32

Expert Comment

by:Batalf
ID: 13415812
or you could just add style to a single cell

<style type="text/css">
.right{text-align:right;}
</style>
<table border="1" width="500">
     <tr>
          <td class="right"><p>Data</td>
          <td><p>Data</td>
     </TR>
     <tr>
          <td><p>Data</td>
          <td><p>Data</td>
     </TR>
</table>

or

<td style="text-align:right">Right aligned</td>

0
 
LVL 32

Expert Comment

by:Batalf
ID: 13415818
or yet another way

<td align="right"><p>Data</td>
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 

Author Comment

by:ARACK04
ID: 13415950
I'm trying to get a $  at the left end of my table cell and my data at the right end of it.

I created a css class for <p> setting text-align to left, and a css class for <td> setting it to right and said:

<tr><td colspan='1' class="right"><p class='left'>$</p>100.00</td></tr>

As expected though, it put a <br> after the <p> tag.  I tried setting colspan='1' on the <td> but it ignored it and put the newline anyway.  I'm really close.  I've got the $ on the left and the data on the right, I just need to get it on the same line.
0
 
LVL 32

Expert Comment

by:Batalf
ID: 13415976
The easiest way is to add a own column for the $

<table border="0">
<tr>
      <td width="10"><p>$</TD>
      <td class="right"><p>100.00</td>
</tr>
</table>
0
 
LVL 32

Accepted Solution

by:
Batalf earned 2000 total points
ID: 13416025
Another option:

<table border="1" width="500">
            <tr><td><div style="float:left">$</div><div style="float:right">100</div></td></tr>

</table>
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Finding original email is quite difficult due to their duplicates. From this article, you will come to know why multiple duplicates of same emails appear and how to delete duplicate emails from Outlook securely and instantly while vital emails remai…
Originally, this post was published on Monitis Blog, you can check it here . Websites are getting bigger and more complicated by the day. Video, images and custom fonts are all great for showcasing your product or service. But the price to pay in…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

765 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question