thibo1025 Posted February 6, 2006 Share Posted February 6, 2006 I have a table in my page with a table header(th) and cells(td).I would like to know how to set the border size and color of each as the cellspacing, the margin and the align feature.only I do not know what syntax to use in the case of tables in css. Link to comment Share on other sites More sharing options...
aspnetguy Posted February 6, 2006 Share Posted February 6, 2006 sample table <table><tr><th>header 1</th><th>header 2</th></tr><tr><td>column 1</td><td column 2</td></tr></table> CSS table{ border: 1px solid black;}th{ border:1px solid red;}td{ border:1px solid blue;} Link to comment Share on other sites More sharing options...
thibo1025 Posted February 6, 2006 Author Share Posted February 6, 2006 what about cellspacing and cellpadding? Link to comment Share on other sites More sharing options...
aspnetguy Posted February 6, 2006 Share Posted February 6, 2006 the equivalent to <table cellspacing="5" cellpadding="5"> for the above example would beCSS table{ border: 1px solid black;}th{ border:1px solid red; margin:5px; /*spacing*/ padding:5px;}td{ border:1px solid blue; margin:5px; /*spacing*/ padding:5px;} Link to comment Share on other sites More sharing options...
thibo1025 Posted February 6, 2006 Author Share Posted February 6, 2006 thank you now I see how it works! Link to comment Share on other sites More sharing options...
brad_mn1988 Posted February 7, 2006 Share Posted February 7, 2006 Hi,I was about to post a queston about table attributes myself, but this thread answered most of them -- thanks!But I will append my unanswered questions here. But first a little background.I am building a PHP function that will return a table, I want the users to be able to determine many attributes of how it will render -- fonts, background colors etc. In the old days, each attribute would need a parameter. Now, with CSS, I have one parameter, $table_style, that gets passed in by the user (with a default setting). Because this dnynamically renders I need to use the 'inline' method for applying CSS (or course). CSS is much cleaner and extensible. thus the table gets rendered as so: <?phpecho "<table{$table_style}>"."(rest of table)"."</table>";?> My question is:I can't seem to get "child" attributes to work here in this 'inline' CSS method. Specifically, if I wanted to have my table where each row has a background color of red, I want to use the "child" status of the rows and embed the background color of the rows within the $table_style string.I tried (after PHP has parsed it): <table style="background-color:yellow; tr background-color:red">(rest of table)</table> and I expect the rows to have a background color of red, but they don't.(overall background color of yellow worked)Can someone explain what I am doing wrong?Thanks in advance!Brad Link to comment Share on other sites More sharing options...
Mimika Posted February 8, 2006 Share Posted February 8, 2006 I dont know how php works so there i cant help but css i can helpput this code before </head> <style type="text/css"><!--tr {background-color:red}--></style> and edit the table <table style="background-color:yellow;">(rest of table)</table> hope this helps :)and you should not higjack others topic's,just an advice *I did once, before i reread the rules* Link to comment Share on other sites More sharing options...
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now