SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Hybrid View

  1. #1
    SitePoint Member
    Join Date
    Jan 2002
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    text alignment within tables with css

    Hi, I am pretty new to css and I am having a problem or two with aligning text within tables that I was hoping someone might be able to help me with. Firstly, can you set the margins for tables so there is a gap around all the text within the tables? I have been playing around with some css but the margin attributes within my table section dosent seem to work. Here is the code I have so far :

    Code:
    body {
    	  font-size: 8pt;
    	  font-family: "Verdana, Helvetica, sans-serif";
    	  color: white;
    	  background: "#000033";
    	  line-height: 4pt;
    	  text-align: center;
    	  margin-left: 10pt;
    	  margin-right: 10pt;
    	  margin-top: 10pt;
    	  scrollbar-3dlight-color: "#000033"; 
    	  scrollbar-arrow-color: "#000033";
    	  scrollbar-base-color: "#006699";
    	  }
    
    td  {  
        font-size: 8pt;
        font-family: "Verdana, Helvetica, sans-serif";
        color: white;
        line-height: 4pt;
        text-align: left;
        margin-left: 10pt;
        margin-right: 10pt;
        margin-top: 10pt;
        }
    
    a:link, a:active {
    		 text-decoration: none;
    		 color: "#FF9900";
    		 }
    a:visited {color: "FFCC00";}
    a:hover {color: blue;}
    some of the code within the td part works but the margins dont. Also one other thing, is it possible to vertically align the text within a table using css?

  2. #2
    .net install meltdown
    Join Date
    May 2001
    Location
    View Ridge
    Posts
    692
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    To create some whitespace between the text & the cell border try using the padding property instead of margin.
    To position the text to the top w/ CSS you would have to absolutly position the text within the cell using position:top, left etc. Probably easier just to use the HTML valign="top" method in this case.

    HTH

  3. #3
    SitePoint Wizard
    Join Date
    Oct 2001
    Location
    Tucson, Arizona
    Posts
    1,858
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In CSS, padding is equivalent to cellpadding (when applied to table data elements), but there's nothing I know of yet to replace cellspacing. As for the vertical alignment, of course there is! Use this:
    Code:
    td {
      vertical-align: top;
    }

  4. #4
    SitePoint Member
    Join Date
    Jan 2002
    Posts
    6
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the help guys, much appreciated

  5. #5
    .net install meltdown
    Join Date
    May 2001
    Location
    View Ridge
    Posts
    692
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Huh,

    Vertical-align. How did I miss that one?

    Thanks for the tip colon.

    The CSS equivalent of cellspacing is the border-spacing prop.
    Last edited by isotope235; Jan 4, 2002 at 15:18.

  6. #6
    SitePoint Wizard
    Join Date
    Oct 2001
    Location
    Tucson, Arizona
    Posts
    1,858
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ah, of course! You just taught me something new, as well.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •