?
Solved

trouble aligning text in a table

Posted on 2013-05-14
2
Medium Priority
?
154 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 2000 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

Unordered lists (HTML ul tags) are very handy to create menus of all types, shapes and sizes.  All it takes is a little knowledge of CSS and the possibilities are endless. First off, you should know the general format for menus created using the …
This article discusses four methods for overlaying images in a container on a web page
In this Micro Tutorial viewers will learn how to create a CSS image sprite (In a later tutorial, viewers will learn how to use CSS and HTML to create a navigation menu using this sprite) Open a new Photoshop document with a width of (Icon width)x(N…
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…
Suggested Courses

718 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