...

View Full Version : CSS on a table



blade007
08-06-2007, 09:46 PM
Can someone look at this code, and see if theres anything wrong with it(im fairly new to CSS), also what does "table-layout" do?



.table {width: 100%; cellspacing:0; cellpadding:0; align:100%; font-size:medium; }

Rappa
08-06-2007, 09:50 PM
Looks good to me.

I personally like it all not on one line:


.table {
width: 100%;
cellspacing:0;
cellpadding:0;
align:100%;
font-size:medium;
}

but thats up to you.

as for your other question:

http://msdn2.microsoft.com/en-us/library/ms531161.aspx (http://msdn2.microsoft.com/en-us/library/ms531161.aspx)

blade007
08-06-2007, 09:57 PM
Looks good to me.

I personally like it all not on one line:


.table {
width: 100%;
cellspacing:0;
cellpadding:0;
align:100%;
font-size:medium;
}

but thats up to you.

as for your other question:

http://msdn2.microsoft.com/en-us/library/ms531161.aspx (http://msdn2.microsoft.com/en-us/library/ms531161.aspx)


it says "it renders by default with width=100%." if no layout is specified, so do ireally need the "width:100%" in there, also i want to align the table in the center, would i put that in the CSS - "align:center" or do i put the commands "<center></center>" at the beginning and end of the table

blade007
08-06-2007, 10:11 PM
when referencing to the CSS table, i use this <table class="table">, do i have to put the class in the <tr> and <td> fields too

Rappa
08-06-2007, 10:11 PM
you dont need the width="100%", but i dont see the difference if its there or not, except the file size. besides if you want to make it a different width then you dont have far to go.

if you want to center your table, you can do it with css, or:



<table align="center">


works too.

blade007
08-06-2007, 10:38 PM
this CSS is not working, dont know why..


.table1 { cellspacing:0; cellpadding:0; align:center; font-size:medium; width:100%; border:1; bordercolor:#0099cc; }


and to reference that, im using..


<table class="table1"><tr><td>etc..

blade007
08-06-2007, 10:46 PM
ok, i got it to work, my next question is how to show all the lines between the cellls, it only shows the outside border of the table

Jutlander
08-06-2007, 10:57 PM
Well, I'd suggest you validate that code you've got there before continuing. Cellpadding and -spacing are not valid CSS properties. Same thing goes for align and bordercolor. Also, you must specify a unit in the border property.

To make borders show inside the table instead of just around it, assign a border to the td element:


td {
border: values here;
}

blade007
08-06-2007, 11:26 PM
i decided to just put the table properties in the table, instead of using CSS, i will only have three tables on the page, so I don't think the load time between having a CSS or not will make mush of a difference; my next question is how to change the font inside a table? this is my table..

<table cellspacing="1" cellpadding="0" align="center" width="100%" border="1" bordercolor="#0099cc"><tr><td><img alt="Arrow" src=""> <b>Condition:</b> </td><td>Like New (<a onclick="win(600,600,this.href); return false;" href="">Condition Detail</a>)</td></tr><tr><td><img alt="Arrow" src=""> <b>Functionality:</b> </td><td>100%</td></tr><tr><td><img alt="Arrow" src=""> <b>Packaging:</b> </td><td>Original Packaging</td></tr></table>

Jutlander
08-06-2007, 11:35 PM
Assign an ID or a class to it and define the font family:


#table1 {
font-family: Arial, Verdana, sans-serif;
}

blade007
08-06-2007, 11:40 PM
what about font size, would i do the same thing; do i have to use CSS to do this, or is there a way to change a tables font without the use of CSS

i want it to be the same font as the rest of my document, but everytime i make a table, the font inside the table gets bigger

Jutlander
08-06-2007, 11:46 PM
Just define a set font size under the body selector and this will be the standard size for all text, except for headings and such.

Or you could just adjust it in .table1:


.table1 {
font-family: Arial, Verdana, sans-serif;
font-size: 0.9em;
}

blade007
08-06-2007, 11:59 PM
ok great, got the tables to change font, but its not the exact same font size as the rest, what is the default/normal font size, what does "em" mean, ive seen CSS style sheets that have "px" in them

Jutlander
08-07-2007, 12:07 AM
The default is 1em. Em is a unit, but you can also use %. It is recommended not to use px, because IE users won't be able to resize the text then.

blade007
08-07-2007, 12:10 AM
as mentioned earlier cell spacing and padding are not CSS properties, can someone TRANSLATE this to a CSS style property..



<table width="100%" align="center" cellpadding="5" cellspacing="1">



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum