Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

CSS how to create a border around part of a table 1

Status
Not open for further replies.

gus121

Technical User
May 9, 2002
298
GB
Hi am struggling with the challenge with css where i wish to create a blue border around part of a table. I tried creating a span element giving it a class from the style sheet and using CSS border-right, border-left border-bottom attributes to create a border around part of the table but this did not work. I then tried creating a boarder on the left and the right of the table. Then setting the border as 0 for left and right this did not work as the border still shows. please cut and paste this code into HTML editor and give it a go. Thanks.

<head>
<title></title>
<meta http-equiv=&quot;Content-Type&quot; content=&quot;text/html; charset=iso-8859-1&quot;>
<style type=&quot;text/css&quot;>
body {color: black; background: #cbe5fe;}
table { width: 280px; border-right: solid #5387B8 1px ; border-left: solid #5387B8 1px; }
tr td{font-size: 75%; font-family: Arial, Helvetica, Verdana, sans-serif; padding: 0.1em 0.2em 0;}
tr.heading td{background: #5387B8; font-weight: bold; font-size: 85%; font-family: Arial, Helvetica, Verdana, sans-serif; color: white; border: solid #5387B8; border-top: 1px;}
span.table-body td{background: #f2f2f2; font-weight: bold;}
tr.footer td{border-right: 0 ; border-left: 0; border-top: solid #5387B8 1px;}
</style>
</head>

<body>

<form name=&quot;register&quot; method=&quot;post&quot; action=&quot;register_site.asp?action=Submit_Validate&quot;>
<div align=&quot;center&quot;> <table cellspacing=&quot;0&quot;>
<tr class=&quot;heading&quot;>
<td colspan=&quot;2&quot; >
Your Details:
</td>
</tr>
<span class=&quot;table-body&quot;>
<tr>
<td width=&quot;35%&quot;>&nbsp;</td>
<td width=&quot;65%&quot;>
<input type=&quot;hidden&quot; name=&quot;existing_email&quot; value=&quot;angus.grant@tdci.eu.com&quot;>
<input type=&quot;hidden&quot; name=&quot;Mask&quot; value=&quot;1&quot;>
</td>
</tr>
<tr>
<td width=&quot;35%&quot;>
<div align=&quot;left&quot;>Title:&nbsp;&nbsp;
</div>
</td>
<td width=&quot;65%&quot;>
<select name=&quot;Title&quot;>
<option value=&quot;Mr&quot; >Mr</option>
<option value=&quot;Mrs&quot; >Mrs</option>
<option value=&quot;Miss&quot; >Miss</option>
<option value=&quot;Dr&quot;>Dr</option>
</select>
</td>
</tr>
<tr>
<td width=&quot;35%&quot;>
<div align=&quot;left&quot;><span class=&quot;basketoverview&quot;>Forename:</span>&nbsp;&nbsp;
</div>
</td>
<td width=&quot;65%&quot;>
<input type=&quot;text&quot; name=&quot;Forename&quot; size=&quot;28&quot; value=&quot;Angus &quot; maxlength=&quot;50&quot;>
</td>
</tr>
<tr>
<td width=&quot;35%&quot; height=&quot;32&quot;>
<div align=&quot;left&quot;><span class=&quot;basketoverview&quot;>Surname:</span>&nbsp;&nbsp;
</div>
</td>
<td width=&quot;65%&quot; height=&quot;32&quot;>
<input type=&quot;text&quot; name=&quot;Sirname&quot; size=&quot;28&quot; value=&quot;Grant &quot; maxlength=&quot;50&quot;>
</td>
</tr>
<tr>
<td width=&quot;35%&quot;>
<div align=&quot;left&quot;><span class=&quot;basketoverview&quot;>E-mail: </span>&nbsp;&nbsp;
</div>
</td>
<td width=&quot;65%&quot;>
<input type=&quot;text&quot; name=&quot;Email_Address&quot; value=&quot;angus.grant@tdci.eu.com&quot; size=&quot;28&quot; maxlength=&quot;50&quot;>
</td>
</tr>
<tr>
<td width=&quot;35%&quot; height=&quot;19&quot;>&nbsp;</td>
<td width=&quot;65%&quot; height=&quot;19&quot;>&nbsp;</td>
</tr>
</span>
<tr class=&quot;footer&quot;>
<td colspan=&quot;2&quot;>
<div align=&quot;right&quot;>
<input type=&quot;submit&quot; name=&quot;Submit&quot; onclick=&quot;return checkEmail(this)&quot; value=&quot;Send&quot;>
</div>
</td>
</tr>
</table></div>
</form>


Angus

http\\http\\
 
Why not just add a border to the cells that you want to have a border around. Add a new td class and use that to display cells with a border.

td.bordered{font-size: 75%; font-family: Arial, Helvetica, Verdana, sans-serif; padding: 0.1em 0.2em 0; border: 1px solid black;}

Then forget your span and use the new td class to display a border.

<tr>
<td class=&quot;bordered&quot; width=&quot;35%&quot;> </td>
<td class=&quot;bordered&quot; width=&quot;65%&quot;>
<input type=&quot;hidden&quot; name=&quot;existing_email&quot; value=&quot;angus.grant@tdci.eu.com&quot;>
<input type=&quot;hidden&quot; name=&quot;Mask&quot; value=&quot;1&quot;>
</td>
</tr>


Mighty
 
Try to declare all sides of the border:

td.bordered{
border-color: #0000ff;
border-style: solid;
border-width: 2px 1px 1px 1px;
}

Play arround on border-width's value.

regards
 
Hi mansii I tried that approach still with the same result.
Here is the source code:

<style type=&quot;text/css&quot;>
body {color: black; background: #cbe5fe;}
table { width: 280px;}
form input {border: 1px solid #000000;}
form select {border: 1px solid #000000;}
tr td{font-size: 75%; font-family: Arial, Helvetica, Verdana, sans-serif; padding: 0.1em 0.2em 0;}
tr.heading td{background: #5387B8; font-weight: bold; font-size: 85%; font-family: Arial, Helvetica, Verdana, sans-serif; color: white; border-color: #5387B8; border-style: solid; border-width: 1px 1px 0 1px;}
td.leftborder {border-color: #5387B8; border-style: solid; border-width: 0 0 0 1px; background: #f2f2f2; font-weight: bold;}
td.rightborder { border-color: #5387B8; border-style: solid; border-width: 0 1px 0 0; background: #f2f2f2; font-weight: bold;}
tr.footer td{border-top: solid #5387B8 1px;}
tr.footer input.button {width: 60px; background-color : #757575; color: #ffffff;}
</style>
</head>

<body>

<form name=&quot;register&quot; method=&quot;post&quot; action=&quot;register_site.asp?action=Submit_Validate&quot;>

<div align=&quot;center&quot;> <table cellspacing=&quot;0&quot;>
<tr class=&quot;heading&quot;>
<td colspan=&quot;2&quot; >
Your Details:
</td>
</tr>
<tr>
<td class=&quot;leftborder&quot; width=&quot;35%&quot;>&nbsp;</td>
<td class=&quot;rightborder&quot; width=&quot;65%&quot;>
<input type=&quot;hidden&quot; name=&quot;existing_email&quot; value=&quot;angus.grant@tdci.eu.com&quot;>
<input type=&quot;hidden&quot; name=&quot;Mask&quot; value=&quot;1&quot;>

</td>
</tr>
<tr>
<td class=&quot;leftborder&quot; width=&quot;35%&quot;>
<div align=&quot;left&quot;>Title:
</div>
</td>
<td class=&quot;rightborder&quot; width=&quot;65%&quot;>
<select name=&quot;Title&quot;>
<option value=&quot;Mr&quot; >Mr</option>

<option value=&quot;Mrs&quot; >Mrs</option>
<option value=&quot;Miss&quot; >Miss</option>
<option value=&quot;Dr&quot;>Dr</option>
</select>
</td>
</tr>
<tr>
<td class=&quot;leftborder&quot; width=&quot;35%&quot;>
<div align=&quot;left&quot;><span class=&quot;basketoverview&quot;>Forename:</span>&nbsp;&nbsp;
</div>

</td>
<td class=&quot;rightborder&quot; width=&quot;65%&quot;>
<input type=&quot;text&quot; name=&quot;Forename&quot; size=&quot;28&quot; value=&quot;Angus &quot; maxlength=&quot;50&quot;>
</td>
</tr>
<tr>
<td class=&quot;leftborder&quot; width=&quot;35%&quot;>
<div align=&quot;left&quot;><span class=&quot;basketoverview&quot;>Surname:</span>&nbsp;&nbsp;
</div>
</td>

<td class=&quot;rightborder&quot; width=&quot;65%&quot;>
<input type=&quot;text&quot; name=&quot;Sirname&quot; size=&quot;28&quot; value=&quot;Grant &quot; maxlength=&quot;50&quot;>
</td>
</tr>
<tr>
<td class=&quot;leftborder&quot; width=&quot;35%&quot;>
<div align=&quot;left&quot;><span class=&quot;basketoverview&quot;>E-mail: </span>&nbsp;&nbsp;
</div>
</td>
<td class=&quot;rightborder&quot; width=&quot;65%&quot;>
<input type=&quot;text&quot; name=&quot;Email_Address&quot; value=&quot;angus.grant@tdci.eu.com&quot; size=&quot;28&quot; maxlength=&quot;50&quot;>

</td>
</tr>
<tr>
<td class=&quot;leftborder&quot; width=&quot;35%&quot; height=&quot;19&quot;>&nbsp;</td>
<td class=&quot;rightborder&quot; width=&quot;65%&quot; height=&quot;19&quot;>&nbsp;</td>
</tr>
<tr class=&quot;footer&quot;>
<td colspan=&quot;2&quot;>
<div align=&quot;right&quot;>
<input class=&quot;button&quot; type=&quot;submit&quot; name=&quot;Submit&quot; onclick=&quot;return checkEmail(this)&quot; value=&quot;Send&quot;>
</div>

</td>
</tr>
</table></div>
</form>

Angus

http\\http\\
 
heres a little work around, but it works best in fixed dimension cells

say you have a cell and you want a 1px black border on left and bottom, make that cell background black then change the alignemnt to left and top.

draw a table in the cell 1px smaler in widht and height. and you are done.

[Hammer]
Nike Failed Slogans -- &quot;Just Don't Do It!&quot;
 
Try to put a non-breaking-space (see the blue colored text. I have difficulty in writing in a & format here hee.. hee..):

<style type=&quot;text/css&quot;>
body {color: black; background: #cbe5fe;}
table { width: 280px;}
form input {border: 1px solid #000000;}
form select {border: 1px solid #000000;}
tr td{font-size: 75%; font-family: Arial, Helvetica, Verdana, sans-serif; padding: 0.1em 0.2em 0;}
tr.heading td{background: #5387B8; font-weight: bold; font-size: 85%; font-family: Arial, Helvetica, Verdana, sans-serif; color: white; border-color: #5387B8; border-style: solid; border-width: 1px 1px 0 1px;}
td.leftborder {border-color: #5387B8; border-style: solid; border-width: 0 0 0 1px; background: #f2f2f2; font-weight: bold;}
td.rightborder { border-color: #5387B8; border-style: solid; border-width: 0 1px 0 0; background: #f2f2f2; font-weight: bold;}
tr.footer td{border-top: solid #5387B8 1px;}
tr.footer input.button {width: 60px; background-color : #757575; color: #ffffff;}
</style>
</head>

<body>

<form name=&quot;register&quot; method=&quot;post&quot; action=&quot;register_site.asp?action=Submit_Validate&quot;>

<div align=&quot;center&quot;> <table cellspacing=&quot;0&quot;>
<tr class=&quot;heading&quot;>
<td colspan=&quot;2&quot; >
Your Details:
</td>
</tr>
<tr>
<td class=&quot;leftborder&quot; width=&quot;35%&quot;> </td>
<td class=&quot;rightborder&quot; width=&quot;65%&quot;>
<input type=&quot;hidden&quot; name=&quot;existing_email&quot; value=&quot;angus.grant@tdci.eu.com&quot;>
<input type=&quot;hidden&quot; name=&quot;Mask&quot; value=&quot;1&quot;>

</td>
</tr>
<tr>
<td class=&quot;leftborder&quot; width=&quot;35%&quot;>
<div align=&quot;left&quot;>Title:
</div>
</td>
<td class=&quot;rightborder&quot; width=&quot;65%&quot;>
<select name=&quot;Title&quot;>
<option value=&quot;Mr&quot; >Mr</option>

<option value=&quot;Mrs&quot; >Mrs</option>
<option value=&quot;Miss&quot; >Miss</option>
<option value=&quot;Dr&quot;>Dr</option>
</select>
</td>
</tr>
<tr>
<td class=&quot;leftborder&quot; width=&quot;35%&quot;>
<div align=&quot;left&quot;><span class=&quot;basketoverview&quot;>Forename:</span>
</div>

</td>
<td class=&quot;rightborder&quot; width=&quot;65%&quot;>
<input type=&quot;text&quot; name=&quot;Forename&quot; size=&quot;28&quot; value=&quot;Angus &quot; maxlength=&quot;50&quot;>
</td>
</tr>
<tr>
<td class=&quot;leftborder&quot; width=&quot;35%&quot;>
<div align=&quot;left&quot;><span class=&quot;basketoverview&quot;>Surname:</span>
</div>
</td>

<td class=&quot;rightborder&quot; width=&quot;65%&quot;>
<input type=&quot;text&quot; name=&quot;Sirname&quot; size=&quot;28&quot; value=&quot;Grant &quot; maxlength=&quot;50&quot;>
</td>
</tr>
<tr>
<td class=&quot;leftborder&quot; width=&quot;35%&quot;>
<div align=&quot;left&quot;><span class=&quot;basketoverview&quot;>E-mail: </span>
</div>
</td>
<td class=&quot;rightborder&quot; width=&quot;65%&quot;>
<input type=&quot;text&quot; name=&quot;Email_Address&quot; value=&quot;angus.grant@tdci.eu.com&quot; size=&quot;28&quot; maxlength=&quot;50&quot;>

</td>
</tr>
<tr>
<td class=&quot;leftborder&quot; width=&quot;35%&quot; height=&quot;19&quot;>non-breaking-space</td>
<td class=&quot;rightborder&quot; width=&quot;65%&quot; height=&quot;19&quot;>non-breaking-space</td>
</tr>
<tr class=&quot;footer&quot;>
<td colspan=&quot;2&quot;>
<div align=&quot;right&quot;>
<input class=&quot;button&quot; type=&quot;submit&quot; name=&quot;Submit&quot; onclick=&quot;return checkEmail(this)&quot; value=&quot;Send&quot;>
</div>

</td>
</tr>
</table></div>
</form>

Regards,
mansii
 
mansii has hit the nail on the head. If you have a completely empty cell, a border won't be displayed. You need to user either &nbsp; or <BR> as the content of the cell.

Instead of:

<td class=&quot;leftborder&quot; width=&quot;35%&quot;> </td>

try:

<td class=&quot;leftborder&quot; width=&quot;35%&quot;><BR></td>

Mighty
 
Uh, one more thing, see the broken border on the upper-left side? Try to move these lines:

<tr>
<td class=&quot;leftborder&quot; width=&quot;35%&quot;> </td>
<td class=&quot;rightborder&quot; width=&quot;65%&quot;>
<input type=&quot;hidden&quot; name=&quot;existing_email&quot; value=&quot;angus.grant@tdci.eu.com&quot;>
<input type=&quot;hidden&quot; name=&quot;Mask&quot; value=&quot;1&quot;>

</td>
</tr>

just before the </form> tag, and remove the tr and td tags. Like this, I guess:

<input type=&quot;hidden&quot; name=&quot;existing_email&quot; value=&quot;angus.grant@tdci.eu.com&quot;>
<input type=&quot;hidden&quot; name=&quot;Mask&quot; value=&quot;1&quot;>
</form>

Try and try
 
Thanks mansii I moved the hidden form elements just after the opening form tag and used the &nbsp; instead. Hay presto the border appeared fine in both browsers. I just need to work out how to pad out all form elements and get rid of the default border around the select box use the input element style because: form select {border: 1px solid #000000;} does not work.

Any Ideas.

Thanks Again

Angus
 
Gus,
I don't quite understand your problem. If I'm right, you want to remove the input border, right?

Line 4 of your code:
form input {border: 1px solid #000000;}
Try to change to:
form input {border: 0px none;}
 
no my style sheet which creates a border fine around the input form elements. however appeares to ignore the dropdown select element. My question is how do I apply a style to dropdown select element. thanks

Angus
 
Unfortunately, I can't find a way to acomplish that. We really need a real guru here.
Gimme a sign when this is solved, okay?
 
Still think its possible however this is all i could find on the subject:

thread215-521474

Angus
 
I agree with him. I myself have been searching for this solution too, but it seems that we can only play with what is listed in the select box, not the select box itself. But keep on looking.

mansii
 
<style type=&quot;text/css&quot;>
<!--
.tableborder {
border-top: thin dotted #66CCFF;
border-right: thin dotted #66CCFF;
border-bottom: thin dotted #66CCFF;
border-left: 1px dotted #000000;
-->
</style>

Give this a go
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top