|
Nicole -> Cellpadding & Cellspacing in CSS (5/21/2005 20:24:43)
|
Sometimes I’m able to solve or work around the most difficult problems, yet at other times it’s the simplest thing that will stump me as in this case. I’ve had serious problems for a long time now trying to understand the cellspacing and cellpadding attributes and how to apply them to a style sheet. I know what these attributes mean and do, but it seems they aren’t doing what I’d like them to do when I apply them to a style sheet and remove them from the code of a page. I’m going through some old templates and removing all code that I know can be styled using CSS, cellspacing and cellpadding being two such pieces of code that up until now I’ve left in the page code because moving them to the style sheet never seemed to work. Most of these old templates were coded using HTML 4.01 transitional, yet the same problem exists in some pages I have coded to XHTML 1.0 transitional. Elizabeth Castro mentions in her book that the CSS values for these two attributes are “padding” and “border-spacing”, in my templates I have tables with no padding or cellspacing so when I place these into the CSS I have the following: . . . vertical-align: top; background-color: #333333; padding: 0; border-spacing: 0; } Firstly, do I have the code correct in this example, or in cases where I do want padding should I have 5, 5px or 1%? Secondly, am I correct that the padding and border-spacing should be applies to the <table> element, or should/can they be applied to <tr> or <td>? Thirdly, I know the default values for cellpadding and cellspacing are 1 and 2, and this is seemingly what it’s defaulting to when I remove these attributes from the code of a page and place them in the CSS. A working example of my problem is my website where I have a banner image followed underneath by a navigation menu. You’ll notice I’ve left cellspacing and cellpadding in this code but if I take it out the following occurs: A slight gap appears under the image (I’m assuming this is the default cellspacing taking over) The padding at the top, right and bottom is almost non-existent around the navigation menu (I’m assuming this is the default cellpadding taking over). Can anyone please help? Thanks Nicole
|
|
|
|