specify a style for the table outside the <TABLE> block

R

Rahul

Is there a way to specify a style that applies to all tables on a page?
Currently my tables are styled using

<link rel="stylesheet" href="table_style.css" type="text/css"
media="screen" />

<TABLE id="box-table-a" >
blah blah blah
</TABLE>


But now I am generating the <TABLE> </TABLE> block automatically via the
mysql command-line-interface (and a cron job) so I want to avoid having to
insert the id="box-table-a" directive.

Is there some way I can specify this above the actual auto-generated html
code for the <TABLE> blocks?

The table_style.css contains some other styles as well but I wanted just
the "box-table-a".
 
D

dorayme

Rahul said:
Is there a way to specify a style that applies to all tables on a page?
Currently my tables are styled using

<link rel="stylesheet" href="table_style.css" type="text/css"
media="screen" />

<TABLE id="box-table-a" >
blah blah blah
</TABLE>


But now I am generating the <TABLE> </TABLE> block automatically via the
mysql command-line-interface (and a cron job) so I want to avoid having to
insert the id="box-table-a" directive.

Would you want to avoid class="" too?

If so, I can only think that you might wrap the table in a div (what a
complication) and class or id the div and the css would go

..class table {...}
 
J

John Hosking

Is there a way to specify a style that applies to all tables on a page?

Based on dorayme's response, I fear that I am misunderstanding your
question, for which the answer to me seems obvious. Add to your CSS:

table { color:white; background-color:navy; }

while moving the rules from your current .box-table-a to the table selector
above to replace the color rules I've used as examples.
 
R

Rahul

Based on dorayme's response, I fear that I am misunderstanding your
question, for which the answer to me seems obvious. Add to your CSS:

table { color:white; background-color:navy; }

while moving the rules from your current .box-table-a to the table
selector above to replace the color rules I've used as examples.

Thanks John! I think I did something very similar to what you suggest and
it worked:

table
{
font-family: "Lucida Sans Unicode", "Lucida Grande", Sans-Serif;
font-size: 12px;
margin: 45px;
width: 480px;
text-align: left;
border-collapse: collapse;
}
table th
{
font-size: 13px;
font-weight: normal;
padding: 8px;
background: #b9c9fe;
border-top: 4px solid #aabcfe;
border-bottom: 1px solid #fff;
color: #039;
}
table td
{
padding: 8px;
background: #e8edff;
border-bottom: 1px solid #fff;
color: #669;
border-top: 1px solid transparent;
}
 
J

John Hosking

Thanks John! I think I did something very similar to what you suggest and
it worked:

You're welcome, and I'm glad. Here's a link which may help you learn how to
style standard HTML elements in general as well as particular elements
which you give a class or id: said:
table
{
font-family: "Lucida Sans Unicode", "Lucida Grande", Sans-Serif;
font-size: 12px;
margin: 45px;
width: 480px;
text-align: left;
border-collapse: collapse;
}
table th
{
font-size: 13px;
font-weight: normal;
padding: 8px;
background: #b9c9fe;
border-top: 4px solid #aabcfe;
border-bottom: 1px solid #fff;
color: #039;
}
table td
{
padding: 8px;
background: #e8edff;
border-bottom: 1px solid #fff;
color: #669;
border-top: 1px solid transparent;
}

From the link I provided above, you will see (although you may know this
already) that the last two rulesets above don't need the "table" in the
selectors; you could use just "th" for the first rule and just "td" for the
second. There's nothing wrong with what you have, though.

I would advise you to reconsider the use of px in specifying font sizes,
however. Try using font-size:100% for table and font-size:108% for th.

See <http://tekrider.net/html/fontsize.php> for a bit about some of the
drawbacks (esp. with IE) when using px units.

GL.
 
R

Rahul

From the link I provided above, you will see (although you may know
this already) that the last two rulesets above don't need the "table"
in the selectors; you could use just "th" for the first rule and just
"td" for the second. There's nothing wrong with what you have, though.

Thanks for your help John! Actually, I did *not* know this. So good that
you commented.

I am nowhere near an html coder. I am more into scientifc computing and
need to do some php / html just because it is a neat way of finally getting
my data across.

Thanks again for your help!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,997
Messages
2,570,239
Members
46,827
Latest member
DMUK_Beginner

Latest Threads

Top