views:

188

answers:

6

How to achieve it with CSS or HTML?

 <table class="banner"><tr><td>If you need many results, then post your task as piecework here. You only need to pay qualified results.
  </td>
 <td>Make money by doing piecework</td></tr>
 <tr><td><a href="publish.php">POST PIECEWORK FOR FREE</a><br/></td><td></td></tr></table>
+2  A: 

Use CSS:

td{overflow:hidden;width:200px;}
and add td cssclass to all tds..an other thing don't put to banner class any width..!
jjj
You don't need classes. His question was only how to make the columns the same width.
@ austin cheney .... there is many ways to do that.. and this is a way to do it..!!
jjj
This is ineffective when the contents are larger than 200px. For instance, a string that is longer than 200px will expand the table column.
Josh Stodola
On the other hand, using `table-layout` will work regardless of cell content (see my answer).
Josh Stodola
@Josh, no a long string will not expand the visible width of the table cell. Notice how I included the overflow:hidden property.
@austin Sorry `<table border="1"><tr><td>ThisIsMeProvingYouWrongButDontBeOffendedItHappensSometimes</td></tr></table>`
Josh Stodola
@Josh You are still ignoring the overflow:hidden property, and the border attribute has been deprecated for nearly a decade. If you are going to try to prove somebody wrong please get your facts straight, listen, and do not use an example that is itself faulty and outdated.
@Austin The `border` attribute is not deprecated. Try my markup with your CSS and you will see that it extends way beyond 200px, which means you are **wrong**. My facts are straight, wise guy. Have a nice day.
Josh Stodola
+1  A: 

In CSS, you can use the width property. This can be done inline or as part of a stylesheet. For some more CSS for tables, check out CSS Styling Tables from w3schools.

td {
    width:200px;
}

<td style="width:200px;">

Or, in HTML, check out the colgroup tag, like this:

<colgroup>
    <col width="200px" />
</colgroup>

I personally use the colgroup the most.

Ascalonian
A: 

What about:

table { width:100% }
td { width:20% }

(assuming you have 5 td's per row. If you have three, put width 33%, if you have 2 put 50% and so on.

Ionut Staicu
A: 

Set the width (CSS or inline if you wish) to be the same percent value for each column (ideally with a total of 100%). This will allow progressive scaling.

ck
A: 

You can use the width property for the td selector. However, possibly you want to discriminate one table over the other. In that case, you can classify your 'equal-width' table like this:

<table class="equal_width_columns">
    <tr><td>one</td><td>onetwothree</td></tr>
</table>

<table> <!-- just a regular table -->
    <tr><td>one</td><td>onetwothree</td></tr>
</table>

with css like this:

table.equal_width_colums * td { width: 300px; }
xtofl
A: 

You should use the table-layout property here...

table { table-layout: fixed; }
table td { overflow: hidden; }
Josh Stodola
hmmmmmmmmmm.. i don't know maybe this is better..!
jjj
I updated answer to use overflow hidden on the `td` so that long strings don't break outside the table.
Josh Stodola