Solved

trouble aligning text in a table

Posted on 2013-05-14
2
135 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 39

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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

CSS3 Custom checkboxes This article shows how to style the checkbox form element using only CSS. Works in: Chrome, FF, Safari, Opera, IE9+ Uses modernizr.js to check for :checked pseudo class, falling back to plain old checkboxes (IE8 and bel…
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 customize the background color and font color of highlighted text using the ::selection element in CSS Begin by defining the selected text as an element in CSS by typing "::selection": Style the ::selection…
In this tutorial viewers will learn how to style rounded corners for elements in CSS using the border-radius property Begin with a normal styled element such as a div: To style all four corners of the div to be the same degree of roundness, use the …

708 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

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now