Solved

trouble aligning text in a table

Posted on 2013-05-14
2
146 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Suggested Solutions

CSS is a visual language used to classify objects and define rules about how they should be displayed. CSS skills aren’t restricted to developers anymore, there is a big benefit to having a basic understanding of the language, regardless of your occ…
Today, the web development industry is booming, and many people consider it to be their vocation. The question you may be asking yourself is – how do I become a web developer?
In this tutorial viewers will learn how to style transparent/translucent elements using alpha transparency in CSS Start with a normal styled element, such as a div.: Define its "background-color" property as "rgba (255, 255, 255, .5): The numbers in…
Video by: Mark
This lesson goes over how to construct ordered and unordered lists and how to create hyperlinks.

710 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