CSS - Centering A Table With Borders In Css
Okay, I have a table and I can center it using css, and I can turn on the outside border, but I cannot seem to turn on the row borders. How do I do this.
I tried.style="border:5px outset #a0a0a0; margin-left:auto;margin-right:auto; margin-top:15%;" which works for the outside border and centering, but to turn on the inside cell row borders I had to use border="3" and then I am unable to center the table on the page no matter what I do. How do I center this table properly using css with both outside border and the row border turned on. Similar TutorialsHi all, what i want is to customise the borders of a table... i know that <div>'s can have custom borders but, for the way that the page works i used table tags <table>. (very little experience of using <div>) is there a way that css can manipulate the borders of a table? i tried using this css: .nmhead { border-color:#cccccc; border-top:border-top-style:none; border-left:border-left-style:none; border-right:border-right-style:double; border-bottom:border-bottom-width:5px; } and then in the table doing this: <td class='nmhead'> but it didnt work (attached is what i want it to look like) any ideas? I am trying to make a nice thin border around a table and all the table cells. It need to work on both windows and macs... If I add this to my table tag [ style="border-collapse: collapse" bordercolor="#808080" ] it give me a nice border in IE, but not so great on a mac (big and thick). I also want to be able to add it into a style sheet and just add the style tag to the table, but I can't seem to get any of it to work. Anyone have any examples or advice? Thanks! While styling table I would like to have black row border all the way, but currently cell borders (grey) overlay them (1px, but still) - like in the image: Bellow is my css. What do I change? Thanks. Code: .list_f { padding: 0px; margin: 0px; border-width: 1px; border-style: solid; border-color: #F1EFE2; border-collapse: collapse; empty-cells: show; border-top: 0px; border-bottom: 0px; border-left: 0px; border-right: 0px; } .list_f th { text-decoration:none; font-weight:normal; background-color:#F3F3F3; margin: 0px; padding: 2px; /* text-align: left;*/ vertical-align:middle; height:22px; border-collapse: collapse; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #000000; border-right-color: #CCCCCC; border-bottom-color: #000000; border-left-color: #CCCCCC; } .list_f td { margin: 0px; padding: 2px; border-collapse: collapse; vertical-align:middle; height:22px; border-top-width: 1px; border-right-width: 1px; border-bottom-width: 1px; border-left-width: 1px; border-top-style: solid; border-right-style: solid; border-bottom-style: solid; border-left-style: solid; border-top-color: #000000; border-right-color: #EBEBEB; border-bottom-color: #000000; border-left-color: #EBEBEB; } .list_f tr { border-top-width: 1px; border-bottom-width: 1px; border-top-style: solid; border-bottom-style: solid; border-top-color: #000000; border-bottom-color: #000000; } I am learning CSS and wish to put a border around selected tables using the following code: table.sidebar { border: 2px black; padding: 50px } Something similar to this code was working OK earlier today, but now it won't. The cell padding command works, but other tags like border, width, etc., are not. I have tried disabling all other table styles in the CSS. Any ideas? I am using MS FrontPage 2002. Also, whys is it that when I apply a style to a table, like the one above, FrontPage puts in the following HTML code: <table class="sidebar" style="border-collapse: collapse" bordercolor="#111111" cellpadding="0" cellspacing="0"> If I go to remove it to <table class="sidebar"> all of the formatting is lost. Seems like this is defeating the whole purpose of CSS Thanks, Keith I'd like to have a class in my style sheet that gives a table a 1 px border, something like this: Quote: <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#111111" width="100%"> <tr> <td width="100%">test</td> </tr> </table> But I'm unsure how to do it. I have a page that is generated with php and contains several page breaks with multiple tables in between. The borders of the tables are generated with Quote: TABLE { BORDER-RIGHT: #000000 1px solid; BORDER-TOP: #000000 1px solid; BORDER-LEFT: #000000 1px solid; BORDER-BOTTOM: #000000 1px solid; } and are needed in odd pages. The even pages tables don't need borders at all. How do I handle this? I tried generating another css file with the BORDER values to be 0px but it didn't work. Any ideas? Evan Hey guys. At the moment i have made a 100% colored table. What i am trying to do is add a 1px colored border to the top of the table and a 2px colored border to the bottom of the table. Ive tried several different approaches but i never get the result i am looking for. Can anyone help me out with this? Here is my code: Quote: <table width="100%" border="0" cellspacing="0" cellpadding="0" align="center"> <tr bgcolor="#000033"> <td align="left"><font face="Arial, Helvetica, sans-serif" size="6"><b><font color="#FFFFFF"> <a name="top">Tiffany and Co Neckless and Braclet Set</a></font></b></font></td> </tr> James Hi all, http://www.zitrote.com/forum/index.php?act=viewforum&f=4 if you see there in IE the two borders on the right dont appear in the topic listing but in FF they do?? Hi, I have a HTML page linking to a CSS file in the header. My main table is defined using class="formBody". This includes: Code: table.formBody td { border-width: 1px 1px 1px 1px; padding: 5px 5px 5px 5px; border-style: solid solid solid solid; border-color: black black black black; background-color: white; -moz-border-radius: 0px 0px 0px 0px; } I need to override this on certain cells, so that a SINGLE certain cell will not have any borders (these will be cells on the bottom row, so the table will have the appearance of having half of its' actual width on the bottom row). Any ideas? I tried explicitly setting border="0" in the <td> tag and also defining a new class called "noborder" with border set to none, and then using <td class="noborder"> but neither of these work. essentially, what I want, is a table that looks like: Code: ________________________ | | | | ------------------------ |________| Any suggestions on how to do this? I'd like to do something like this: Quote: <table border="1" cellpadding="0" cellspacing="0" style="border-collapse: collapse" bordercolor="#666666" width="100%"> <tr> <td>Test</td> </tr> </table> But I don't want to use an inline style tag. I tried this: Quote: <html> <head> <style> .border { border-color: #666666; border-collapse: collapse; border: 1px; } </style> </head> <body> <table class="border" cellpadding="0" cellspacing="0" width="100%"> <tr> <td>Test</td> </tr> </table> </body> </html> But it does not work. What am I doing wrong? Hello, I am working on a site and want to put a thin black line border on individual cells in a table with out putting a border on the whole table. Im not very experienced with css and would perfer to keep it simple. any info will help thanks Nick Carlevaris Hi there, Everyone: Firstly, I am a CSS noob... My site is: wwwDOTincenseforpeaceDOTcom (change the word DOT to a . please, new users are not allowed to post URLs on this forum. Thanks) I have a red background gif on my site. In firefox, it looks great. It DOESN'T show through the cell borders of the main table. However, it is showing through the cell borders of a table in Internet Explorer (at least IE 8, haven't checked with earlier versions of IE). Any idea on how to get it to stop showing through on IE? This is what I THINK is the main table CSS (I told you I am a noob when it comes to CSS). #content-container{ clear:both; width:100%; border-style:solid; border-color:#666666; border-spacing:0; border-width:0 0; /* was border-width:1px 0; before */ padding:0 0 0 0; margin:0; /* ie6 min-height hack */ height:270px; max-height:270px !important; Thanks in advance. I'm trying to center a table with CSS, because apparently putting align="center" in the table tag doesn't validate as HTML Strict. I've tried table.center { position: fixed; left: 50%; } but that makes the table go off of the page. I've tried all the options given on w3schools.com with their positioning lessons, but none of them work. Any suggestions? Can anyone please tell me why cant i see a table centered by using this style sheet? All other elements are centered except form the tables tmemselves. Code: /* style.css */ body { background-image: url(/data/images/night.gif); position: relative; margin: 0; padding: 0; width: 100%; } #page { position: relative; width: 100%; height: auto; } #select_form { margin-top:1 5px; font-size: 3ex; color: lime; text-align: center; } #DivText { overflow: auto; background-image: url(/data/images/kenzo.jpg); border: 4px Ridge Magenta; width: 850px; height: 500px; margin-left: auto; margin-right: auto; margin-top: 25px; color: LightSkyBlue; text-align: left; font-family: Times; font-size: 18px; } #user_form { position: relative; margin-top: 60px; } #info { position: relative; margin-top: 20px; margin-bottom: 20px; } #links { text-align: center; color: lime; } #links a { color: lime; } #links p { font: 12px bold; text-align: right; margin-bottom: 10px; } table.user_form { background-image: url(/data/images/swirl.jpg); width: 55%; color: lime; font: 18px times; text-align: center; border: 5px inset blue; border-collapse: collapse; } table.info { background-image : url(/data/images/blue.jpg); width: 90%; color: lime; font: 18px comic; text-align: center; border: 3px inset red; border-collapse: collapse; } table.tip { background-image : url(/data/images/brick.jpg); width: 20%; color: lime; font: 18px comic; text-align: center; border: 3px inset magenta; border-collapse: collapse; } table.games { background-image : url(/data/images/swirl.jpg); width: 80%; color: yellow; font: 18px comic; text-align: center; border: 3px inset magenta; border-collapse: collapse; } table { margin-top: auto; margin-bottom: auto; text-align: center; } Tr { text-align: center; border: 2px inset blue; } td { padding-top: 3px; padding-bottom: 3px; padding-right: 5px; padding-left: 5px; border: 1px inset yellow; } span { text-align: center; } h3 { margin-top: auto; margin-bottom: auto; margin-right: auto; margin-left: auto; text-align: center; } span.yellow { font: 18px comic; color: yellow; } td.pink { font: 18px comic; color: pink; } td.lime { font: 18px comic; color: lime; } td.yellow { font: 18px comic; color: yellow; } td.cyan { font: 18px comic; color: cyan; } td.white { font: 18px comic; color: white; } td.aquamarine { font: 18px comic; color: aquamarine; } h3.pink { font: 18px comic; color: pink; } h3.lime { font: 18px comic; color: lime; } h3.yellow { font: 18px comic; color: yellow; } h3.cyan { font: 18px comic; color: cyan; } h3.white { font: 18px comic; color: white; } h3.aquamarine { font: 18px comic; color: aquamarine; } Hi, Im having a problem centering a DIV table exactly how i want it too. I want to be use the DIV table so that it will be only a few pixel away from the top.. so lets say 80px from the top and being centered horizontaly, so that it will display the samething for both 1024x768 & 800x600. ps: the DIV table needs to be aligned to the right so that the image will appear on the right in both 1024x768 & 800x600 I have included/attached a image to kinda give a better idea. Seems like I'm always trying to get something to render correctly in IE but this time it's firefox that is acting ornery. There's not much to the page I'm working on. The table (#schoolstable) should be centered in the #mainbody div. Works in ie, fails in firefox. Here's my css: Code: /* = Default Layout -----------------------------------------------------------------------------*/ /* Remove padding and margin */ * { margin: 0; padding: 0; } /* Remove border around linked images */ img { border: 0; } body { text-align: center; min-width: 800px; font-family: Verdana, Arial, Helvetica, sans-serif; } /* = Basic Layout and Typography -----------------------------------------------------------------------------*/ h1 { margin: 8px 0; } h2 { margin: 8px 0; } p { margin: 4px 0; } ul { margin: 8px 0; } li { font-size:14px; } form { margin: 8px 0; } /* =Advanced Layout and Typography by Area -----------------------------------------------------------------------------*/ #wrapper { width:760px; margin: 0 auto; text-align: center; } #masthead { width:760px; margin: 0; background: url(../images/indexheader.jpg) no-repeat center; height: 270px; } #mainbody{ width:760px; margin: 0; text-align: center; } /* = Basic Links -----------------------------------------------------------------------------*/ a, a:visited { color: #000000; background-color: #EEEEEE; width: 150px; line-height: 18px; text-decoration: none; font-size: 14px; font-weight: bold; display: block; } a:hover, a:visited:hover { color: #FFFFFF; width: 150px; text-decoration: none; background-color:#00FF33; } /* = Advanced Links -----------------------------------------------------------------------------*/ .c0000FF a, .c0000FF a:visited { width: 150px; text-decoration: none; font-weight: bold; } .c0000FF a:hover, .c0000FF a:visited:hover { color: #FF6600; width: 150px; text-decoration: none; background-color: #0000FF; } .c990000 a, .c990000 a:visited { width: 150px; text-decoration: none; font-weight: bold; } .c990000 a:hover, .c990000 a:visited:hover { color: #FFCC00; width: 150px; text-decoration: none; background-color: #990000; } .cCC6600 a, .cCC6600 a:visited { width: 150px; text-decoration: none; font-weight: bold; } .cCC6600 a:hover, .cCC6600 a:visited:hover { color: #FFFFFF; width: 150px; text-decoration: none; background-color: #CC6600; } .c3366CC a, .c3366CC a:visited { width: 150px; text-decoration: none; font-weight: bold; } .c3366CC a:hover, .c3366CC a:visited:hover { color: #FFCC33; width: 150px; text-decoration: none; background-color: #3366CC; } .c333366 a, .c333366 a:visited { width: 150px; text-decoration: none; font-weight: bold; } .c333366 a:hover, .c333366 a:visited:hover { color: #CCCC99; width: 150px; text-decoration: none; background-color: #333366; } /* = Basic Lists -----------------------------------------------------------------------------*/ ul { list-style-position: inside; list-style-type: none; } ul li { } /* = Advanced Lists -----------------------------------------------------------------------------*/ .schoollist { text-align: center; } .schoollist li { line-height: 16px; padding: 1px 1px; width: 150px; } /* = Tables -----------------------------------------------------------------------------*/ table { border-spacing: 0; border-collapse: collapse; padding: 0; margin: 8px 0; } tr { padding: 0; margin: 0; } td { padding: 0; margin: 0; } /* = Advanced Tables -----------------------------------------------------------------------------*/ #schoolstable { } #schoolstable tr { } #schoolstable td { } /* = Forms -----------------------------------------------------------------------------*/ fieldset { } /* = Advanced Forms -----------------------------------------------------------------------------*/ I seem to have had success creating a cross-platform method for centering tables. #centeredTable { display:table; width: auto; margin-top: 5px; margin-left: auto; margin-right: auto; text-align: center; } You can view an example he http://jim.centerfuse.net/css/table...ed-example.html IE ignores display:table and doesn't successfully interpret margin: auto, but text-align: center seems to take care of centering the table in IE. Tested in Opera 7, IE 6, IE 5.5, Mozilla 1.5. (I have the top margin in there just to move it away from my header a bit.) It does require that you set a width on your table, or it will simply fill the entire page, though you could get around that with a container DIV (like this: http://jim.centerfuse.net/css/table...able_width.html ). I thought others might be interested in seeing this, since it seems to be a common problem. I had originally developed a slightly more complicated way of doing what I need to do, but this seems to work just as well. My main concerns are that future versions of IE will break this code because of added support for display:table and margin:auto, or that the specs for display:table; will change in the future, since it seems to be entirely unsupported in some browsers (namely IE). Comments/Flames welcome -Jim Keller I know this is probably soooo not kosher, but this is where I'm at ... I have a star rating graphic that I got off the web that uses an HTML list, turned horizontally, to get the stars to light up when you hover over them. It took me ages to get it working, to customize it to my website's colors, and now it all works great. The only problem is I need it to appear centered in a table column, and no matter what I do with the css code I can't make it happen. I know I should probably be using divs and all, but I tried that, and ultimately decided tables is easier for this purpose. Anyway, if someone can forgive my sloppy, amateur ways and tell me how I can get this f-ing thing to center in my table column I would much appreciate it. Here's the css code: Code: /* star rating */ .star * { float: right; padding:0px; margin:0px; list-style:none; } ul.rating{ background:url(images/star8.jpg) bottom; height:21px; width:115px; overflow:hidden; position:relative; } ul.rating li{ display:inline } .rating a { display:block; width:23px; height:21px; float:right; text-indent:-9999px; position:relative; } .rating a:hover { background:url(images/star8.jpg) center; width:115px; margin-left:-92px; position:static; } .rating a:active { background-position:top; } and here's the HTML code (in php format): Oops - won't let me send code because it contains URLs. Either way, it's a straight up table with three columns. Cheers. Julian i use external stylesheet which is shown below. i have tried using <h1> which is set to center, ive tried using <p class="center"> and it still does not center. it only centers when i use the <center> tag...what gives? its fine in netscape, opera, and ie..... Code: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN"> <html> <head> <title>Ranid Photo Gallery</title> <link rel="stylesheet" type="text/css" href="stylesheet1.css" /> </head> <body bgcolor="#ffffff" text="#000000" link="#0000ff" alink="#0000ff" vlink="#0000ff"> <div style="position: absolute; left: 10px; top: 200px; width: 740px; background-color: transperant; padding: 0px;"> <h1>Ranid Frog Photos</h1> <p class="center"><table width=70% border=1 cellspacing=0 cellpadding=0> <tr><td width=30%><h4><a href="images/raurora1.jpg"><img src="images/raurora1.jpg" width=100 height=100></a></h4><h4>Rana aurora aurora; Vancouver Island, Canada</td> <td width=30%><h4><a href="images/raurora2.jpg"><img src="images/raurora2.jpg" width=100 height=100></a></h4><h4>Rana aurora aurora; Vancouver Island, Canada</td> <td width=30%><h4><a href="images/.jpg"></a></h4><h4></td></tr> </table></p> <h5>:<a href="gallery.html">Back to the Gallery</a>:</h5> </body> </html> My style sheet Code: body { color: #000000; background-color: #ffffff; font-family: Georgia, "Times New Roman", Times, serif; } } h1 { FONT-WEIGHT: bold; text-align: center; font-size: 30px } h2 { FONT-WEIGHT: bold; text-align: center; font-size: 25px } h3 { FONT-WEIGHT: bold; text-align: center; font-size: 20px } h4 { FONT-WEIGHT: bold; text-align: center; font-size: 15px } h5 { padding: 0px; FONT-WEIGHT: normal; text-align: center; font-size: 12px } h6 { line-height: 1pt ; FONT-WEIGHT: normal; text-align: center; font-size: 9px } p { FONT-WEIGHT: normal; text-align: left; FONT-WEIGHT: normal; color: #000000; font-size: 12px } hr {color: #7d7c7c } .right {text-align: right } .center {text-align: center } .left {text-align: left } .uppercase {text-transform: uppercase} .lowercase {text-transform: lowercase} .capitalize {text-transform: capitalize} A:visited { COLOR: #802CFF; TEXT-DECORATION: underline } A:link { COLOR: #2C31FF; TEXT-DECORATION: none } A:hover { COLOR: #719FFE; TEXT-DECORATION: underline } A:active { COLOR: #2C31FF; TEXT-DECORATION: underline } any ideas? I have a table that is populated using Spry. For some of the users, the table is showing its' borders in white when there is no data in the cell and for other users (like me) it's showing its' borders in black like expected. This is occurring in IE8 for the user. I have IE8 as well. Here is a setup of my table Code: <div id="Content"> <p class='instructions'>Click a column header to sort the table.</p> <div spry:region="jdmba"> <div spry:state="loading" class="loading">Please wait while alumni data loads…</div> <table class="spry" cellspacing="0" cellpadding="0"> <tr> <th scope="col" width="108px" class="sortable" spry:sort="last" id="last">Last Name</th> <th scope="col" width="106px" class="sortable" spry:sort="first" id="first">First Name</th> <th scope="col" width="269px" class="sortable" spry:sort="account" id="account">Company</th> <th scope="col" width="66px" class="sortable" spry:sort="state" id="state">State</th> <th scope="col" width="82px" class="sortable" spry:sort="hls_year" id="hls_year">JD</th> <th scope="col" width="82px" class="sortable" spry:sort="hbs_year" id="hbs_year">MBA</th> </tr> </table> <div class="Overload"> <table class="spry" cellspacing="0" cellpadding="0"> <tr spry:repeat="jdmba" spry:setrow="jdmba" spry:odd="odd" spry:even="even" spry:hover="hover" > <td width="108px">{last}</td> <td width="106px">{first}</td> <td width="269px">{account}</td> <td width="66px">{state}</td> <td width="82px">{hls_year}</td> <td width="82px">{hbs_year}</td> </tr> </table> </div> </div> Here is my CSS file Code: a:link { text-decoration: none; } a:visited { text-decoration: none; } a:hover { text-decoration: none; } a:active { text-decoration: none; } #News a:link { color: #00F; } #News a:hover { color: #00F; text-decoration: underline; } body { background: #000 repeat; } #wrap { background: #000; width: 900px; border: thick solid #9C0029; float: left; height: auto; padding: 0px 0px 1em; margin-top: 2%; margin-left: 10%; } #footer { font: bold small/50px Arial, Helvetica, sans-serif; color: #FFF; background: #9C0029; text-align: center; height: 50px; width: 850px; margin-left: 25px; } #Header { background: #8F001C url(../images/banner.jpg) no-repeat center center; width: 850px; height: 150px; margin-top: 20px; margin-right: 20px; margin-left: 25px; } h1 { font: normal 18px Arial, Helvetica, sans-serif; color: #000; text-align: left; } h2 { font: small Georgia, "Times New Roman", Times, serif; color: #333; text-align: justify; } h3 { font: normal medium "Times New Roman", Times, serif; color: #FFF; } h4 { font-size: small; color: #333; text-align: left; } .banners { background: #FFF0B2; width: auto; height: auto; font: 18px Arial, Helvetica, sans-serif; padding-top: .5em; padding-bottom: .5em; text-indent: 10px; } .Content { font: 14px/normal Georgia, "Times New Roman", Times, serif; text-align: justify; display: block; padding: 2em 3em 3em; } .Content a:link { color: #00F; } .Content a:hover { color: #00F; text-decoration: underline; } .Content a:visited { color: #00F; } #inner_body { background: #FFF; height: auto; width: 800px; margin-top: 0px; margin-left: 50px; padding-top: 0.5em; padding-bottom: .5em; } #inner_border { margin: 0em auto auto; border: thin solid #8E887C; width: 775px; padding: 1em 0em 0em; } #nav_bar { height: 3em; width: 100%; margin-left: 0%; text-align: center; } #Content { height: auto; width: 95%; padding: 0em 0% 5em; margin: 2.5% 2.55% 2%; text-align: left; font-family: Verdana; } #nav { height: auto; width: 20em; } #News { margin-left: 2px; height: 30%; background: #FFF0B2; padding: 3%; } #News a:visited { color: #00F; } .Overload { height: 208px; overflow: auto; } .odd { background-color: #E8E8E8; } .even { background-color: #E8E8E8;} .hover { background-color: #FFC;} table.spry { font-family: Verdana; font-size: 12px; line-height:20px; cursor: pointer; } .instructions { font-family: Verdana; font-weight:bold; font-size: 12px; line-height:20px; cursor: pointer; margin-bottom:8px; } .loading { font-family: Verdana; font-weight:bold; font-size: 12px; line-height:20px; cursor: pointer; margin-top:0px; margin-bottom:8px; color:#900; } table.spry th { border-left: 1px solid #000000; border-bottom: 1px solid #000000; border-top: 1px solid #000000; font-family:Verdana; padding: 0px; margin: 0px; } table.spry td { border-left: 1px solid #000000; border-bottom: 1px solid #000000; font-family:Verdana; padding: 0px; margin: 0px; } table.spry th.sortable:hover { cursor: pointer; } table.spry th.sortable { text-align:left; color:#FFFFFF; background: #8F001C url(../SpryAssets/bg.gif) no-repeat 95% 6px; } table.spry th.ascending { background: #8F001C url(../SpryAssets/SpryMenuBarUpHover.gif) no-repeat 95% 8px; } table.spry th.descending { background: #8F001C url(../SpryAssets/SpryMenuBarDownHover.gif) no-repeat 95% 8px; } I'm only placing borders on the left and bottom so that in my detail cells the borders aren't doubled up. So for example when I have no data for the cell State, the left and bottom border of that cell is white rather than black. Any ideas? Thanks! |