• Welcome to Overclockers Forums! Join us to reply in threads, receive reduced ads, and to customize your site experience!

manipulating html table borders

Overclockers is supported by our readers. When you click a link to make a purchase, we may earn a commission. Learn More.

rebelwarlock

Member
Joined
Dec 13, 2004
i need to create a table with a border such that there is one horizontal line every two lines of text. the default is every line, and i haven't been able to find any settings that let me do otherwise. any ideas?
 
I don't think you can. If you didn't have the table you could just insert a horizontal rule or your favorite image every two lines. Or you could shade every other rows background a color like white-gray-white or something. I don't know if that would work for you.
 
There is not a simple way. You can do something like this:

Code:
		<table border=0 cellspacing=0 cellpadding=0>
		<tr>
			<td>1A</td><td>1B</td>
		</tr>
		<tr>
			<td>2A</td><td>2B</td>
		</tr>
		<tr style='height:1px;'>
			<td bgcolor='black' colspan=2></td>
		</tr>
		<tr class='topborder'>
			<td>3A</td><td>3A</td>
		</tr>
		<tr>
			<td>4A</td><td>4A</td>
		</tr>
		</table>

Replace colspan=2 with the appropriate # of columns, the bgcolor with your desired border color, and the height of the TR tag with the thickness.
 
<tr><td>Stuff here!<br />Second line!</td><td>More stuff here!<br />Other second line!</td></tr>

the other thing you could do is...

<style>
tr.bordered {
border: 0 0 1px/*or however many you want :p*/ 0 Solid/*or checked, or whatever*/ red/*again, or whatever*/;
}

<table border=0>
<tr><td>Stuff goes here...</td></tr>
<tr class="bordered"><td>Looky! More stufff! WITH a border beneath!</td></tr>
<tr><td>More stuff again</td></tr>
<tr class="bordered"><td>Bordered!</td></tr>
</table>
etc.
 
If you are using PHP, however, and wish to check if something is odd or even...

$count=0;

while($count<15) {
if(ceil($count/2)==$count/2) {
echo '<tr class="bordered">';
} else {
echo '<tr>';
}
<td>Content</td></tr>
}

edit: The CEIL function is used to round up an integer. I.E. ceil(2.5) would yeild 3. However, checking to see if 5/2(rounded up) is equal to 5/2 will tell you if the number is even. You can also use this to check if a number is divisible by another number, say you wanted it to be every three or 4 instead of every two.

if(ceil($count/3)==$count/3) {//IF divisible by three do it!

}

Tada! Majeek!
 
There's an attribute for the table tag that lets you specify what border to display. one of them will do only the horizontal lines on the inside. Then you can just do two lines of text in each cell...
 
that would be ...

tr {
border: 0/*this is the top*/ 0 /*this is the right*/ 1px /*This is the bottom*/ 0 /*This is the left*/
}

Put that in your stylesheet, or in <style></style> Tags and it would do what you said.

However, then you lose the entire purpose of tables, which is providing rows of information.
 
thanks for the help guys, here's what ended up working for me
Code:
<td rowspan="2">
First line
<br>
Second line
</td>
 
Back