Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

CSS Forum


You are currently viewing our CSS Forum as a guest. Please register to participate.
Login



Reply
Old 07-18-2005, 03:51 PM CSS for tables?
Experienced Talker

Posts: 32
Trades: 0
Hello all

I have found that i use a layout for a table for example.

Code:
<td>
  <table border=1 bordercolor=#000000 cellpadding=0 cellspacing=0 style="border-collapse: collapse;" width=186 height="150">
    <tr> 
  <td style="background-image: url(images/tbg.gif); font-family: verdana; font-size: 10px; color: #ffffff; vertical-align: middle; height: 21px; width: 186px; padding-left: 3px;">
  Header text here
 </td>
 </tr>
<tr>
<td align="center" id="box" style="background-image: url(images/bg1.gif); padding-left: 3px; font-family: verdana; font-size: 10px; color: #000000;">
Information text
</td>
</tr>
</table>
I use this quite allot on a site im creating, is there a way i could use CSS or somthing to store the table infomation and just enter the text info into the html instead of having to have lots of that above code on the page.

Thanks
zerox3k is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 07-19-2005, 03:51 AM
Enigmatic's Avatar
Registered User

Posts: 86
Location: No Fixed Abode
Trades: 0
Create an external CSS file, something along the lines of whats below would work for you.

Code:
#id1 { 
background-image: url(images/tbg.gif); 
font-family: Verdana, Arial 10px #FFFFFF; 
vertical-align: middle; 
height: 21px; 
width: 186px;
padding-left: 3px
}

#id2 {
border-width:1px;
border-color:#000000;
border-collapse: collapse
}

etc ...
Save that to a .css file called styles.css then in your HTML call the CSS file using:

<link rel="stylesheet" type="text/css" rel="styles.css">
Enigmatic is offline
Reply With Quote
View Public Profile
 
Old 07-19-2005, 04:57 AM
Experienced Talker

Posts: 32
Trades: 0
Thanks for the reply, i will try what you have suggested.

How do i use this in the main html file tho?

Thanks again for your help
zerox3k is offline
Reply With Quote
View Public Profile
 
Old 07-19-2005, 11:39 AM
Experienced Talker

Posts: 47
Trades: 0
Between the <head> and </head> tags in your HTML file you need to add a new section

<style>
..put your css here..
</style>

Make sure you don't put it in between other tags like the <title> It has to be on its own inside the <head>
__________________

Please login or register to view this content. Registration is FREE


Please login or register to view this content. Registration is FREE
Synchronize is offline
Reply With Quote
View Public Profile
 
Old 07-19-2005, 12:07 PM
Hudson's Avatar
Experienced Talker

Posts: 38
Location: Derby, UK
Trades: 0
Quote:
Originally Posted by Enigmatic
Save that to a .css file called styles.css then in your HTML call the CSS file using:

<link rel="stylesheet" type="text/css" rel="styles.css">
Sorry to be pedantic, but that should be

<link rel="stylesheet" type="text/css" href="styles.css">
__________________

Please login or register to view this content. Registration is FREE
Hudson is offline
Reply With Quote
View Public Profile Visit Hudson's homepage!
 
Old 07-19-2005, 04:13 PM
Experienced Talker

Posts: 32
Trades: 0
but how do i use it in the main html file? like in a table where i enter data etc?
zerox3k is offline
Reply With Quote
View Public Profile
 
Old 07-19-2005, 05:36 PM
Enigmatic's Avatar
Registered User

Posts: 86
Location: No Fixed Abode
Trades: 0
Quote:
Originally Posted by Hudson
Sorry to be pedantic, but that should be

<link rel="stylesheet" type="text/css" href="styles.css">

Naa man, thats cool, should have noticed I had an error in it. No idea why I put rel there rather than href.


To call the CSS in your table, if you are using CSS id's [ CSS id's use # in the CSS file ], you call them using id="" in your tags. If you just calling a class [ CSS classes use . in the CSS file ], you call them using class="".

You can do as has also been suggested and just use <style></style> tags in the head of you HTML but using a CSS file is less hassle becase it can be linked to any page using the <link rel ... > tag rather than having to re-write code over and over multiple pages.

Hope that helps.
Enigmatic is offline
Reply With Quote
View Public Profile
 
Old 07-19-2005, 06:22 PM
Experienced Talker

Posts: 32
Trades: 0
ok i see what you mean i will have to recall the #id1 and #id2 in the above example

but in a html

example

<html>

i want to use this text as the header

and this as the main text in the cell below

</html>

normally i would do all the table properties and enther the text where needed.

example

<td>
<table border=1 bordercolor=#000000 cellpadding=0 cellspacing=0 style="border-collapse: collapse;" width=186 height="150">
<tr>
<td style="background-image: url(images/tbg.gif); font-family: verdana; font-size: 10px; color: #ffffff; vertical-align: middle; height: 21px; width: 186px; padding-left: 3px;">
<center>.:: Members Login ::. </center>
</td>
</tr>
<tr>
<td align="center" id="box" style="background-image: url(images/bg1.gif); padding-left: 3px; font-family: verdana; font-size: 10px; color: #000000;">
Welcome to the members login area etc....
</td>
</tr>
</table>
zerox3k is offline
Reply With Quote
View Public Profile
 
Old 07-19-2005, 06:28 PM
Experienced Talker

Posts: 32
Trades: 0
sorry for my n00bness by the way, im still learning.
zerox3k is offline
Reply With Quote
View Public Profile
 
Old 07-20-2005, 03:21 AM
Enigmatic's Avatar
Registered User

Posts: 86
Location: No Fixed Abode
Trades: 0
You call the different CSS types using the class and id attributes.

So, either in your page, or a seperate CSS file, you have something like :

#id1 { border-width: 1px; border-color: #000000; border-collapse: collapse; }
.tdBorder { border-width: 1px; border-color: #006699; border-style: dashed; }
.text { font-family: Verdana, Arial, Helvetica, sans-serif; font-color: #000000; font-size: 9px;


Your HTML would look similar to :

<html>
<head>
<title>##----[ YOUR PAGE TITLE ]----##</title>
<!--
either
<style type="text/css">
styles here
</style>
or
<link rel="stylesheet" type="text/css" href="styles.css">
-->
</head>
<body>
<table id="id1">
<tr>
<td class="tdBorder">Something Goes Here</td>
</tr>
<tr>
<td>The text contained within the span tags <span class="text">is formatted like this</span></td>
</tr>
</table>
</body>
</html>

Last edited by Enigmatic; 07-20-2005 at 03:21 AM.. Reason: forgot to close a tag
Enigmatic is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to CSS for tables?
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 1.03235 seconds with 12 queries