Current location: Hot Scripts Forums » General Web Coding » CSS » Table CSS Noob Question


Table CSS Noob Question

Reply
  #1 (permalink)  
Old 09-10-08, 12:12 PM
outhowz42 outhowz42 is offline
Newbie Coder
 
Join Date: Jun 2008
Location: USA
Posts: 25
Thanks: 0
Thanked 0 Times in 0 Posts
Table CSS Noob Question

I have CSS for a table, and when I create a table in HTML I want to do something like this:

<table class="special">
</table>

I would like for all th, td, tbody, caption, etc use the properties defined in the special class. In order for that to happen, I have to do <tr class="special">, or <td class="special">, for every single element? Why cant I just assign the class to the table and be done with it?

Here is the CSS. I was doing table.special, th.special, td.special, caption.special, etc... is there a way to avoid this, by doing something like table.special, then doing table.special:th, table.special:td, or something like that? I'm confused. Thanks.
css Code:
  1. <style type="text/css">
  2.  
  3. table, th, td {
  4.     border: 1px solid #D4E0EE;
  5.     border-collapse: collapse;
  6.     font-family: "Trebuchet MS", Arial, sans-serif;
  7.     color: #555;
  8. }
  9.  
  10. caption {
  11.     font-size: 16px;
  12.     font-weight: bold;
  13.     margin: 5px;
  14. }
  15.  
  16. td, th {
  17.     padding: 4px;
  18. }
  19.  
  20. thead th {
  21.     text-align: center;
  22.     background: #E6EDF5;
  23.     color: #4F76A3;
  24.     font-size: 100% !important;
  25. }
  26.  
  27. tbody th {
  28.     font-weight: bold;
  29.     font-size: 10px;
  30. }
  31.  
  32. tbody tr { background: #FCFDFE; }
  33.  
  34. tbody tr.odd { background: #F7F9FC; }
  35.  
  36. table a:link {
  37.     color: #718ABE;
  38.     text-decoration: none;
  39. }
  40.  
  41. table a:visited {
  42.     color: #718ABE;
  43.     text-decoration: none;
  44. }
  45.  
  46. table a:hover {
  47.     color: #718ABE;
  48.     text-decoration: underline !important;
  49. }
  50.  
  51. tfoot th, tfoot td {
  52.     background: #E6EDF5;
  53.     font-size: 10px;
  54. }
__________________
www.sportsloon.com

Last edited by Nico; 09-10-08 at 12:21 PM. Reason: Wrappers.
Reply With Quote
  #2 (permalink)  
Old 09-11-08, 04:22 AM
omniman's Avatar
omniman omniman is offline
Coding Addict
 
Join Date: Aug 2006
Location: Baltimore, MD
Posts: 342
Thanks: 0
Thanked 1 Time in 1 Post
You can start with your class name, and then utilize inheritance for the objects. That way, you are saying: look at an element with class 'special' and take any table, th, td, etc. elements within that class.

An example would be:

css Code:
  1. .special table,
  2. .special th,
  3. .special td {
  4.     border: 1px solid #D4E0EE;
  5.     border-collapse: collapse;
  6.     font-family: "Trebuchet MS", Arial, sans-serif;
  7.     color: #555;
  8. }
  9.  
  10. .special caption {
  11.     font-size: 16px;
  12.     font-weight: bold;
  13.     margin: 5px;
  14. }
  15.  
  16. .special td,
  17. .special th {
  18.     padding: 4px;
  19. }
__________________
"Political Correctness is a doctrine, fostered by a delusionary, illogical, liberal minority and rabidly promoted by an unscrupulous mainstream media, which holds forth the proposition that it is entirely possible to pick up a turd by the clean end."

Last edited by omniman; 09-11-08 at 04:23 AM. Reason: Code highlighting error
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I center an ID'd table using CSS? likegluelikecrew CSS 4 04-30-09 04:57 AM
MYSQL database countll Database 2 06-19-07 04:20 PM
What do you think of my database structure? Oskare100 Database 5 12-27-06 07:43 AM
IE and Firefox Table + CSS Help iidavidii HTML/XHTML/XML 5 12-04-06 11:29 AM
Pretty simple ( i think) question any help!?!? 0o0o0 PHP 2 04-07-06 10:47 AM


All times are GMT -5. The time now is 02:12 PM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.