Solved

trouble aligning text in a table

Posted on 2013-05-14
2
139 Views
Last Modified: 2013-05-14
http://roofgenius.com/tablepractise.asp

I have been trying to center align all the text in the right side of this table to no avail
also the bottom left 4 rows I have been unable to put a 40px padding on the left side of the left aligned text
What am i doing wrong?
0
Comment
Question by:isnoend2001
2 Comments
 
LVL 40

Accepted Solution

by:
Kyle Abrahams earned 500 total points
ID: 39164745
the <!-- isn't a valid comment for CSS.

use the /* syntax for that.
http://www.w3schools.com/css/css_syntax.asp

I've posted 2 sections of code, the first where everything is working, but the comments are incorrect (actually causing some of your styles not to apply)

The second is the correct syntax, but then other stuff changes.

A useful tool is firefox's inspection tool where you can just right click on a cell to see what styles are being applied.

To indent the text, use a span inside of the cell.


Working:
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="dcterms.created" content="Mon, 13 May 2013 15:47:28 GMT">
    <meta name="description" content="">
    <meta name="keywords" content="">
    <title>Table practise</title>
    
    <!--[if IE]>
    <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
	<style type= "text/css">
	    
	     .nailsizetable .rightcolumn{
	 width: 45px;
	 text-align: center !important;
	  }  
	  
	  	 .nailsizetable .leftcolumn td{
	 width: 345px;
	 text-align:center;
	 margin-left:40px;
	  } 
	  
	
	
	.nailsizetable {
	width:480px; 
    margin:auto;
    font-size:12px;
    border:1px solid #0066ff; <!-- ~dark blue -->
     border-collapse:collapse;	
	}	

	.nailsizetable tr{
	background: #F2F2F2;<!-- light gray -->
	 }	
	
	.nailsizetable td{
	height: 20px;
	border-right: 1px solid #CCC;<!-- darker gray -->
    	border-left: 1px solid #CCC;
      	border-bottom: 1px solid #CCC;
	width:auto;
	 }

	.nailsizetable .headingrow td{
	border: 1px solid #0066ff;<!-- ~dark blue -->
	background: #0066ff;
	width:260px;
	font-size: 12px;
	 font-family: verdana, arial, helvetica, sans-serif; 
	 color: #FFFFFF;<!-- ~font color white -->
	 font-weight: bold;
	 text-align:center;
	 padding-left:2px; 
	 }

	.nailsizetable .firstrow td {
	 border-right: 1px solid #CCC;<!-- darker gray -->
      border-left: 1px solid #CCC;
      border-bottom: 1px solid #CCC;
	  }


	  
	 </style>
  </head>
  <body>
 
<table class="nailsizetable">
<tr>
<td class="headingrow" rowspan="2"  style="margin-top:30px; text-align:center">
Composition Shingles
</td>
<td class="rightcolumn" colspan="4">
Sheathing Thickness
</td>
</tr>
<tr>
<td class="rightcolumn">3/8"</td>
<td class="rightcolumn">1/2"</td>
<td class="rightcolumn">5/8"</td>
<td class="rightcolumn">3/4"</td>
</tr>
<tr>
<td class="leftcolumn">
3-Tab comp shingles (Bare sheathing)</td>
<td class="rightcolumn">1"</td>
<td class="rightcolumn">1"</td>
<td class="rightcolumn">1"</td>
<td class="rightcolumn">1"</td>
</tr>
<tr>
<td class="leftcolumn">
<span style="padding-left:40px">
Dimensional comp shingles (Bare sheathing)
</span>
</td>

<td class="rightcolumn">1"</td>
<td class="rightcolumn">1-1/4"</td>
<td class="rightcolumn">1-1/4"</td>
<td class="rightcolumn">1-1/4"</td>
</tr>
<tr>
<td class="leftcolumn">
3-Tab comp shingles over 3 Tab comp shingles</td>
<td class="rightcolumn">1"</td>
<td class="rightcolumn">1-1/4"</td>
<td class="rightcolumn">1-1/4"</td>
<td class="rightcolumn">1-1/4"</td>
</tr>
<tr>
<td class="leftcolumn">
Dimensional comp shingles over 3 Tab</td>
<td class="rightcolumn">1-1/4"</td>
<td class="rightcolumn">1-1/2"</td>
<td class="rightcolumn">1-1/2"</td>
<td class="rightcolumn">1-1/2"</td>
 
</tr>
</table>
  </body>
</html>

Open in new window



Not working, but correct syntax:
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="utf-8">
    <meta name="dcterms.created" content="Mon, 13 May 2013 15:47:28 GMT">
    <meta name="description" content="">
    <meta name="keywords" content="">
    <title>Table practise</title>
    
    <!--[if IE]>
    <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
	<style type= "text/css">
	    
	     .nailsizetable .rightcolumn{
	 width: 45px;
	 text-align: center !important;
	  }  
	  
	  	 .nailsizetable .leftcolumn td{
	 width: 345px;
	 text-align:center;
	 margin-left:40px;
	  } 
	  
	
	
	.nailsizetable {
	width:480px; 
    margin:auto;
    font-size:12px;
    border:1px solid #0066ff; /* ~dark blue */
     border-collapse:collapse;	
	}	

	.nailsizetable tr{
	background: #F2F2F2; /* light gray*/
	 }	
	
	.nailsizetable td{
	height: 20px;
	border-right: 1px solid #CCC; /*darker gray */
    	border-left: 1px solid #CCC;
      	border-bottom: 1px solid #CCC;
	width:auto;
	 }

	.nailsizetable .headingrow td{
	border: 1px solid #0066ff; /* ~dark blue */
	background: #0066ff;
	width:260px;
	font-size: 12px;
	 font-family: verdana, arial, helvetica, sans-serif; 
	 color: #FFFFFF; /* ~font color white */
	 font-weight: bold;
	 text-align:center;
	 padding-left:2px; 
	 }

	.nailsizetable .firstrow td {
	 border-right: 1px solid #CCC;/*darker gray */
      border-left: 1px solid #CCC;
      border-bottom: 1px solid #CCC;
	  }


	  
	 </style>
  </head>
  <body>
 
<table class="nailsizetable">
<tr>
<td class="headingrow" rowspan="2"  style="margin-top:30px; text-align:center">
Composition Shingles
</td>
<td class="rightcolumn" colspan="4">
Sheathing Thickness
</td>
</tr>
<tr>
<td class="rightcolumn">3/8"</td>
<td class="rightcolumn">1/2"</td>
<td class="rightcolumn">5/8"</td>
<td class="rightcolumn">3/4"</td>
</tr>
<tr>
<td class="leftcolumn">
3-Tab comp shingles (Bare sheathing)</td>
<td class="rightcolumn">1"</td>
<td class="rightcolumn">1"</td>
<td class="rightcolumn">1"</td>
<td class="rightcolumn">1"</td>
</tr>
<tr>
<td class="leftcolumn">
<span style="padding-left:40px">
Dimensional comp shingles (Bare sheathing)
</span>
</td>

<td class="rightcolumn">1"</td>
<td class="rightcolumn">1-1/4"</td>
<td class="rightcolumn">1-1/4"</td>
<td class="rightcolumn">1-1/4"</td>
</tr>
<tr>
<td class="leftcolumn">
3-Tab comp shingles over 3 Tab comp shingles</td>
<td class="rightcolumn">1"</td>
<td class="rightcolumn">1-1/4"</td>
<td class="rightcolumn">1-1/4"</td>
<td class="rightcolumn">1-1/4"</td>
</tr>
<tr>
<td class="leftcolumn">
Dimensional comp shingles over 3 Tab</td>
<td class="rightcolumn">1-1/4"</td>
<td class="rightcolumn">1-1/2"</td>
<td class="rightcolumn">1-1/2"</td>
<td class="rightcolumn">1-1/2"</td>
 
</tr>
</table>
  </body>
</html>

Open in new window

0
 

Author Closing Comment

by:isnoend2001
ID: 39164822
Thanks for adding that did not even think about the comment syntax
I was thinking the /* ..*/only applied to external style sheets. never really thought about it.
But now i know. Back to the drawing board
0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When applying CSS to your HTML, there are many different ways to select which element(s) the CSS applies to.  Some of these selectors are more commonly known and used than others - Here are the more common ones: #X - Matches an ID of X .X - Matche…
Why do we like using grid based layouts in website design? Let's look at the live examples of websites and compare them to grid based WordPress themes.
In this tutorial viewers will learn how to position items using CSS's three positioning types Create a new HTML document with an internal stylesheet.: Create another div in CSS and name it Absolute : Type "position:absolute;" and "top:10px; left:50p…
In this tutorial viewers will learn how to embed custom externally-hosted Google Fonts using the Google Font API in CSS Go to the Google Fonts website at google.com/fonts: Browse or search based on font properties or name to find a suitable font for…

856 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question