CSS Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsWeb DesignCSS Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
  #1  
Old March 13th, 2004, 08:52 AM
annihilate's Avatar
annihilate annihilate is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: Surrey, UK
Posts: 216 annihilate User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 3 h 21 m 19 sec
Reputation Power: 5
CSS and bordering only certain table cells

Hi, I have the following code which is for a table.
Code:
<table width="100%" border="0" cellspacing="0" cellpadding="0">
			      <tr>
			        <td>&nbsp;</td>
		          </tr>
			      <tr>
			        <td><a name="A"></a>A</td>
		          </tr>
			      <tr>
			        <td>&nbsp;</td>
		          </tr>
			      <tr>
			        <td><a name="B"></a>B</td>
		          </tr>
			      <tr>
			        <td>&nbsp;</td>
		          </tr>
			      <tr>
			        <td><a name="C"></a>C</td>
		          </tr>
			      <tr>
			        <td>&nbsp;</td>
		          </tr>
			      <tr>
			        <td><a name="D"></a>D</td>
		          </tr>
			      <tr>
			        <td>&nbsp;</td>
		          </tr>
			      <tr>
			        <td><a name="E"></a>E</td>
		          </tr>
			      <tr>
			        <td>&nbsp;</td>
		          </tr>
			      <tr>
			        <td><a name="F"></a>F</td>
		          </tr>
			      <tr>
			        <td>&nbsp;</td>
		          </tr>
			      <tr>
			        <td><a name="G"></a>G</td>
		          </tr>
			      <tr>
			        <td>&nbsp;</td>
		          </tr>
			      <tr>
			        <td><a name="H"></a>H</td>
		          </tr>
			      <tr>
			        <td>&nbsp;</td>
		          </tr>
			      <tr>
			        <td><a name="I"></a>I</td>
		          </tr>
			      <tr>
			        <td>&nbsp;</td>
		          </tr>
			      <tr>
			        <td><a name="J"></a>J</td>
		          </tr>
			      <tr>
			        <td>&nbsp;</td>
		          </tr>
			      <tr>
			        <td><a name="K"></a>K</td>
		          </tr>
			      <tr>
			        <td>&nbsp;</td>
		          </tr>
			      <tr>
			        <td><a name="L"></a>L</td>
		          </tr>
			      <tr>
			        <td>&nbsp;</td>
		          </tr>
			      <tr>
			        <td><a name="M"></a>M</td>
		          </tr>
			      <tr>
			        <td>&nbsp;</td>
		          </tr>
			      <tr>
			        <td><a name="N"></a>N</td>
		          </tr>
			      <tr>
			        <td>&nbsp;</td>
		          </tr>
			      <tr>
			        <td><a name="O"></a>O</td>
		          </tr>
			      <tr>
			        <td>&nbsp;</td>
		          </tr>
			      <tr>
			        <td><a name="P"></a>P</td>
		          </tr>
			      <tr>
			        <td>&nbsp;</td>
		          </tr>
			      <tr>
			        <td><a name="Q"></a>Q</td>
		          </tr>
			      <tr>
			        <td>&nbsp;</td>
		          </tr>

		        </table>

What I want to do is to have a black 1px border around the cells with the letters in, in A, B, C , D etc etc.

I am hoping it is a CSS thing, but I only want it to apply to this table, not all the other tables on the page.

Anyone know the easiest way to do this?

Thanks

Reply With Quote
  #2  
Old March 13th, 2004, 09:13 AM
CrappoMan CrappoMan is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 15 CrappoMan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Hi,

Just setup a style:

Code:
<style type="text/css">
.bbox { border: 1px solid black; };
</style>


and apply it to the cells you want:

Code:
<table width="100%" border="0" cellspacing="0" cellpadding="0">
  <tr><td>&nbsp;</td></tr>
  <tr><td class="bbox"><a name="A"></a>A</td></tr>
  <tr><td>&nbsp;</td></tr>
  <tr><td class="bbox"><a name="B"></a>B</td></tr>

etc...


Simon

Reply With Quote
  #3  
Old March 13th, 2004, 10:06 AM
annihilate's Avatar
annihilate annihilate is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: Surrey, UK
Posts: 216 annihilate User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 3 h 21 m 19 sec
Reputation Power: 5
Ok. I've got that working now. However, I'm trying to do something else. I want to use CSS for all my existing tables as I just tried my site in Mozilla and the borders don't come out how they should, so I used some CSS and it works properly. This is what I have at the moment.

TABLE.border {
border-style: solid;
border-width: 2px;
border-color: 000000;
padding: 0px;
}

And I use it like <table class="border" etc etc. This puts a 2px border around the table, but how do I get the cells inside to have borders as well. A 1px line between each row is what I'm after, so that the border is thinner than the outer border of the table.

Thanks

Reply With Quote
  #4  
Old March 13th, 2004, 10:19 AM
CrappoMan CrappoMan is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 15 CrappoMan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
You don't need to declare the style as "TABLE.name", just use ".name", and use <table class="name">. That way the style can be applied to other elements as well.

For the cell borders, declare a style and do <td class="name">

You can use { border-bottom: 1px solid gray } to put a line between each row.

You can apply any style to any html element, so you can put borders around most things this way, div's, forms, tables, cells, <a>'s, anything.

Simon

Reply With Quote
  #5  
Old March 13th, 2004, 02:09 PM
Akh's Avatar
Akh Akh is offline
|<.+#f@#+.&.|
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2002
Location: norway
Posts: 2,685 Akh User rank is Colonel (50000 - 60000 Reputation Level)Akh User rank is Colonel (50000 - 60000 Reputation Level)Akh User rank is Colonel (50000 - 60000 Reputation Level)Akh User rank is Colonel (50000 - 60000 Reputation Level)Akh User rank is Colonel (50000 - 60000 Reputation Level)Akh User rank is Colonel (50000 - 60000 Reputation Level)Akh User rank is Colonel (50000 - 60000 Reputation Level)Akh User rank is Colonel (50000 - 60000 Reputation Level)Akh User rank is Colonel (50000 - 60000 Reputation Level)Akh User rank is Colonel (50000 - 60000 Reputation Level)Akh User rank is Colonel (50000 - 60000 Reputation Level)Akh User rank is Colonel (50000 - 60000 Reputation Level) 
Time spent in forums: 4 Weeks 6 h 17 m 10 sec
Reputation Power: 594
just use the cascading in css

table.border td {
border:1px solid #000;
}

affects every td with in the table with class border.

you can also add,

border-collapse:collapse;

to the table.border element.

Reply With Quote
  #6  
Old March 13th, 2004, 02:20 PM
CrappoMan CrappoMan is offline
Registered User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Mar 2004
Posts: 15 CrappoMan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
The cascade is fine if you wan't to affect every cell in a table, otherwise you have to use individual class attributes.

Simon

Reply With Quote
  #7  
Old March 13th, 2004, 03:11 PM
annihilate's Avatar
annihilate annihilate is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Oct 2003
Location: Surrey, UK
Posts: 216 annihilate User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 1 Day 3 h 21 m 19 sec
Reputation Power: 5
Quote:
Originally Posted by Akh
you can also add,
border-collapse:collapse;
to the table.border element.


Thanks.

What does the border-collapse:collapse do?

Reply With Quote
  #8  
Old March 13th, 2004, 03:12 PM
Akh's Avatar
Akh Akh is offline
|<.+#f@#+.&.|
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2002
Location: norway
Posts: 2,685 Akh User rank is Colonel (50000 - 60000 Reputation Level)Akh User rank is Colonel (50000 - 60000 Reputation Level)Akh User rank is Colonel (50000 - 60000 Reputation Level)Akh User rank is Colonel (50000 - 60000 Reputation Level)Akh User rank is Colonel (50000 - 60000 Reputation Level)Akh User rank is Colonel (50000 - 60000 Reputation Level)Akh User rank is Colonel (50000 - 60000 Reputation Level)Akh User rank is Colonel (50000 - 60000 Reputation Level)Akh User rank is Colonel (50000 - 60000 Reputation Level)Akh User rank is Colonel (50000 - 60000 Reputation Level)Akh User rank is Colonel (50000 - 60000 Reputation Level)Akh User rank is Colonel (50000 - 60000 Reputation Level) 
Time spent in forums: 4 Weeks 6 h 17 m 10 sec
Reputation Power: 594
you don't have to use classes,
you can use Adjacent sibling selectors +
http://www.w3.org/TR/2004/CR-CSS21-...acent-selectors

then you could set diffrent style to
table.border td
and to
table.border td + td

of course this wouldn't work in msie,
but it work in every other modern browsers (moz, opera, konq)

just for an example with this in practice
http://www.9ls.org/test/css-examples/chess.html

Reply With Quote
  #9  
Old March 13th, 2004, 03:16 PM
Akh's Avatar
Akh Akh is offline
|<.+#f@#+.&.|
Dev Shed Frequenter (2500 - 2999 posts)
 
Join Date: Mar 2002
Location: norway
Posts: 2,685 Akh User rank is Colonel (50000 - 60000 Reputation Level)Akh User rank is Colonel (50000 - 60000 Reputation Level)Akh User rank is Colonel (50000 - 60000 Reputation Level)Akh User rank is Colonel (50000 - 60000 Reputation Level)Akh User rank is Colonel (50000 - 60000 Reputation Level)Akh User rank is Colonel (50000 - 60000 Reputation Level)Akh User rank is Colonel (50000 - 60000 Reputation Level)Akh User rank is Colonel (50000 - 60000 Reputation Level)Akh User rank is Colonel (50000 - 60000 Reputation Level)Akh User rank is Colonel (50000 - 60000 Reputation Level)Akh User rank is Colonel (50000 - 60000 Reputation Level)Akh User rank is Colonel (50000 - 60000 Reputation Level) 
Time spent in forums: 4 Weeks 6 h 17 m 10 sec
Reputation Power: 594
border-collapse:collapse;
makes the space between the "table border" and the "td borders" to collapse,

http://www.w3.org/TR/CSS2/tables.ht...lapsing-borders

Reply With Quote
Reply

Viewing: Dev Shed ForumsWeb DesignCSS Help > CSS and bordering only certain table cells


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 2 hosted by Hostway
Stay green...Green IT