Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

custom formating of <table>

Posted on 2005-02-27
6
Medium Priority
?
166 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
  • 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
Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

 

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

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

Question has a verified solution.

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

Not sure what the best email signature size is? Are you worried about email signature image size? Follow this best practice guide.
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
In this tutorial viewers will learn how to embed an audio file in a webpage using HTML5. Ensure your DOCTYPE declaration is set to HTML5: : The declaration should display (CODE) HTML5 is supported by the most recent versions of all major browsers…
The viewer will the learn the benefit of plain text editors and code an HTML5 based template for use in further tutorials.
Suggested Courses

572 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