Need some help to get these Tables Right (PLS)

Hey guys, its been too long since of worked on tables freehand and need to get the exact colors and layout for the tables below I have taken screenshots on. It will be super great if I can get the same fonts - these match my template and css will be swell, but beggers can’t be choosers…

Here are the screenshots (yeah, simple tables I know, but I just can’t get them right, as I said I’ve relied on apps for my html for so long) - yes I can free-hand a table up with multi cells etc, but i need it to look just like these, i’ve spent half a day messing around trying to fix up spacings, etc etc… Arrrgh.

(Table 1 - One I really Need Most, & would really appreciate a kick start, i may be able to figure out table 2 from this - I am pretty good at reading and putting down HTML and tables once I get the style down, whoch i’m stuck on, on these)

thanks so much if someone can help me out, if css is involved they can sit in div tags or whatever you prefer

NOTE-:

  • In table 1 the top row background color is:
    #f5f5f5

  • Border Is:
    #cecece

  • Font Face:
    ? arial or verdana or sans-serif (bit of a random call - but not too important I can figure it later)

  • In Table 2 (Same as Above)

Thanks to anyone who can help me out with this quick table job, It will help me a great deal to get back into the form of hand writing tables, as I can read html fine, just rusty atm and need to add a few variations of these 2 tables to about 8 templates which I can do by myself once I get a boost up.

I’ve been a member at Sitepoint.com since about end of 2005, I just forgot my login ID, I was active in the PHP and HTML/CSS and Web Design Areas, and my brother is an active member here for many years also.

Anyhow, I hope to become an active member again as I work on my websites and hope to help others in return when I can.

Much Appreciated.

J.C
QLD, AU

This should get you started. Might need some corrections, as I just wrote it from what I saw.

<table>
 <thead>
  <tr>
   <th scope="col">Shipping Method</th>
   <th scope="col">Shipping Timeframe</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <th scope="row">Local Pick-Up</th>
   <td>
    <ul>
     <li>$5 handling fee per pick-up from our warehouse in Port Melbourne, Victoria
     <li>Please contact us before making a purchase
    </ul>
   </td>
  </tr>
 </tbody>
</table>
table {
 border-collapse: collapse;
}

td, th {
 border: 1px solid #ccc;
 font-family: arial, sans-serif;
 font-size: 0.8em;
 padding: 2px;
 text-align: left;
}

th {
 font-weight: bold;
}

thead th {
 background-color: #eee;
}

td ul {
 margin: 0;
 padding: 0;
}

td li {
 margin: 0 0 0 25px;
 padding: 0;
}

You are a legend, thank you so much for taking the time to help me out! I love being part of communities like these.
I hope I can one day repay the favour.

I will give the code a go and let you know how it turned out, well I’ll show you :slight_smile:

thanks again!

OK, There is a couple of things I don’t know how to do, and what this really needs, as you can see here is what that code produced, though I added a width=500 in the table tag and a valign=top in the Local Pick-Up td tag as it was sitting in the middle.

The difference I can notice and I think it needs but have no idea, like I said is to add some sort of padding around the inner sides of the table cells. It looks like the source table has some padding on the left of the left hand cells only and a little on the right. Both the left and right columns have a little padding on the inside top to keep the text from being too close to the edges. And it looks like both right and left columns have a little padding on the inner bottoms, which keeps the text the furthest away from the bottom edge, which I think actually looks quiet good.

Now I’ve muddled with cellspacing and padding but have a feeling the padding is in the css - which I am in over my head, I can read what most css does, but am hopeless trying to create something like this.

Once the CSS is done with the spacing, I can replicate the rows pretty easy I think we will have a pretty much identical table.

After that I think I can figure out table #2 based on using most of whats in this table, though to me it looks a whole lot easier - everything is centered and replicated. So table to will use alot let css too which i can work out what i need/dont need as i start from the top.

So C. Ankerstjerne are you up for some CSS modification to get that padding right?, as it needs to be pretty much the exact same as the one shown, well the padding is important, the rest I can figure out like cell sizing etc, but I’m lost with the padding. Basically “Copy” of the image what the padding would be (approx) and I can adjust if its out once i figure what controls what :slight_smile:

Also, is adding valign=top to the TD tags the best way to get the text to the top now that there will be a little inside padding? CSS is next on my list for learning how to use for page layouts instead of the old HTML tags like font, etc…basically any visual effect which is the future. PhotoShop PSD -> HTML needs to catch up.

THANKS ONCE AGAIN ANYONE WHO CAN HELP OUT, YOU DON’T KNOW HOW MUCH IT MEANS TO ME TO BE ABLE TO GET THIS LOOK AGAIN WITH THESE TABLES! I APPRECIATE IT, & HOPE SOME KARMA COMES YOUR WAY!

Cheers,
J.C :slight_smile:

You shouldn’t use the width or valign attributes, as they have been deprecated. The same goes for the center and font tags, which should never be used. Rather, you should use CSS for all styling. This modified HTML and CSS should give you what you want. Notice that I added an id for the table. For the other table, I’ve set up the CSS using the id airmail.

<table id="shipping">
 <thead>
  <tr>
   <th scope="col">Shipping Method</th>
   <th scope="col">Shipping Timeframe</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <th scope="row">Local Pick-Up</th>
   <td>
    <ul>
     <li>$5 handling fee per pick-up from our warehouse in Port Melbourne, Victoria
     <li>Please contact us before making a purchase
    </ul>
   </td>
  </tr>
 </tbody>
</table>
table {
 border-collapse: collapse;
}

#shipping {
 width: 500px;
}

td, th {
 border: 1px solid #ccc;
 font-family: arial, sans-serif;
 font-size: 0.8em;
 padding: 5px 2px;
 text-align: left;
 vertical-align: top;
}

th {
 font-weight: bold;
}

thead th, #airmail th {
 background-color: #eee;
}

td ul {
 margin: 0;
 padding: 0 0 5px;
}

td li {
 margin: 0 0 0 25px;
 padding: 0;
}

#airmail td {
 text-align: center;
 vertical-align: middle;
}

I’m happy to be of assistance. Don’t hesitate to ask questions in the CSS forum too. You seem eager to learn how to design webpages ‘the right way’, which is great! :slight_smile:

In addition to the forum, check out the SitePoint CSS Reference. I would also recommend the SitePoint books [url=http://www.sitepoint.com/books/html2/]Build Your Own
Web Site The Right Way Using HTML & CSS (great for getting started) and The CSS Anthology: 101 Essential Tips, Tricks & Hacks (for more advanced stuff).

I actually learned my first semantic tables from HTML Utopia: Designing Without Tables (it ended up happening to have a data table in it which is the only book I had with such a table in it).

The main focus of the book is styling and setting up positioning with CSS, and then also styling a table, so if you happen to see if in a library or bookstore, pick it up.

I just noticed that the second table’s first cell isn’t bold. This can be done with CSS too:

#airmail th:first-child {
 font-weight: normal;
}

thanks again, I am testing the new code for ‘shipping’ table now and will let you know how it turns out.

Also, what does th:first-child represent in the #airmail tag, will this only change the first cell to normal font, but all others to bold? (for learning purposes)
Or should I give the first cell the id=first-child … yes? (I hope I’m learning fast.)
… I will not get carried away yet, I will finish the first table, then do some reading you ointed out to me (thank you), then begin with the 2nd table and if I run into any problems there I will gratefully ask for your assistance if I can not find in my reading… I’m a quick learner and practice makes perfect in my experience (aswell as reading to fill in blanks, of course)
\

THANKS KINDLY ONCE AGAIN C. Ankerstjerne you have been a patient and gracious helper and teacher.

Jay.

OK, thanks for your help so far C. Ankerstjerne and others who have contributed reading material.

OK, here is my Table 1 now (with a few changes to your code C. Ankerstjerne due to not enough padding or space between cell inside borders and the text inside (as you can see with older tables to the Original I am trying to replicate.)
This looks like I’ve added enough padding between left hand site and the List ‘dots’ and bottom of the list ending and space (approx 8px to bottom of cell)

Here is the Almost finished Image screenshot, and if you look over from the start - We are getting alot closer to the original table 1

I have added some of my own adjustements to the code:

1) I measured the original Table 1 and it is approx 570px wide, so I need to change to 570px for the table width.

2) the right hand column is slighlty wider than the left (as it hold more test I gather), It looks like the left is 260px wide & right TD is 310px (approx, but thats close enough). The one thing is I have no idea how to change the widths of each individual Table TD (what is the name for a TD? row or column? Its been so long I write all this stuff down in my categorized notes so you know :slight_smile: )

3) I changed the main font colour from black to the #3a3a3a which is the exact colour used in table 1 and 2 in the code.

So once we get the TD’s their widths, then I think with my little adjustments to padding (as you can see from last screenshot) it is looking more like a splitting image, well that was the plan all along, as I need this basically exactly as is for to fit into my layout.

Here is the code I adjusted from yours, if you compare it you will see minor changes, I still have no idea what margins are and padding and why the four digits (eg: 0 0 0 25px) is there an order for future reference. I mean I was changing things until it looked right. is there an order such as (eg: padding: first 0 is left, 2nd 0 is top, 3rd 0 is bottom & 4th 0/25px is left of the cell?)
Or a link you can guide me to that specializes in this area (padding and margins and the 4 digits (or less) what they change exactly, as I have yet to find any good info describing this on google - a short answer will do, just so I know what changes what, as there are 4 digits most of the time which I consider left, right, top, bottom from my experiementing with the padding in that code… Anyhow… here is my code, if you see something that does not need to be there, or is not correct with standards could you please fix it up for me quickly (so i compare what i did wrong).

This is your recent code with my changes:


table {
 border-collapse: collapse;
}
 
#shipping {
 width: 570px;
 color: #3a3a3a;
}
 
td, th {
 border: 1px solid #ccc;
 font-family: arial, sans-serif;
 font-size: 0.8em;
 color: #3a3a3a;
 padding: 5px 2px;
 text-align: left;
 vertical-align: top;
}
 
th {
 font-weight: bold;
}
 
thead th, #airmail th {
 background-color: #eee;
}
 
td ul {
 margin: 0;
 padding: 0 0 8px;
}
 
td li {
 margin: 0 0 0 40px;
 padding: 2px;
}
 
#airmail td {
 text-align: center;
 vertical-align: middle;
}

#airmail th:first-child {
 font-weight: normal;
}

And the HTML changes are not the frequent, other than adding a &nbsp: sign before ‘Local Pick-Up’ as I did not know how to do it using padding, or even if that code is still used. I removed ‘Methods’ from “shipping methods” as I wanted to make sure I was not exanding those cells when playing with the padding and margin 0’s and 10px etc, so I have added back in the code below, however is missing from screenshot.


<table id="shipping">
 <thead>
  <tr>
   <th scope="col">Shipping Methods</th>
   <th scope="col">Shipping Timeframe</th>
  </tr>
 </thead>
 <tbody>
  <tr>
   <th scope="row">&nbsp;Local Pick-Up</th>
   <td>
    <ul>
     <li>$5 handling fee per pick-up from our warehouse in Port Melbourne, Victoria
     <li>Please contact us before making a order
    </ul>
   </td>
  </tr>
 </tbody>
</table>

Thanks again in advance for your help on this last bit, hopefully if you can compare any alternated code to the original Table 1 we can see if it looks identical, and if you can answer my questions regarding the order of padding and margin numbers that will mean I have learned alot about padding and CSS today, as tables is the most common form of CSS I will start with - it makes sense now, and I use them very frequently. I know I have some learning ahead of me, but I picked up the old HTML 8yrs ago when I was just starting out, and could hand write code and websites no problems - as I said I’m a fast and keen learner so CSS will be no different I expect as always with the help of mentors and helpers that answer questions and help make it so much easier - like hands on learning!

I’m sure I will have some questions for you with the 2nd table, mostly about how to get all the cells the same size (or certain size), except the main front ones are different. I know it relies on text size also, but these are too cemetrical and measured for that. Also how to do that with CSS if I cannot use what you do to make the left and right cells in table 1 a certain width, though I will try before bothering you with questions.

It looks as if Table 2 will be alot easier than table 2, atleast in the old way we wrote tables from scratch it seems all text is centered and cells the same width and height, so the CSS should be a test for me :slight_smile:

[b]thanks so much, and I appreciate you giving me instructions to get these tables right, once these are done I will have time to read, and will be hovering the CSS forums and other books and reading you suggested so I may help others in return once I learn more, or in something I know like PhotoShop Design (which is behind the times for DESIGN -> HTML) but a great application for web page elements (buttons, icons, logos etc) which I have many years experience in and hope I can give back.

Again - Your assistance I appreciate more than words. I have been on this for along time, then you came along, and from your spark I too shall be joining the CSS design group of designers (from old school to new).Looking forward to hearing from you soon, and see if we can get this table 1 looking the same with the cell widths, and once I add the other rows it will (hopefully) match.
P.S I know how to use CSS to make the font red on row 3 (from what i’ve been reading, I’m sure I have that down pat… learn something everyday… I knew that, just forgot it as it had been a while working with altering html/basic css templates yrs ago)

TTYS-
Jay


#airmail th:first-child {
 font-weight: normal;
}

:first-child selects… the first child : ) of an element (in this case, the th who is the first child of its parent, the thead). So it says, “bold the th who is the first child of his parent”.

I look those things up here: http://www.w3.org/TR/css3-selectors/ (I happen to have it bookmarked though)


padding: 0 0 0 25px;

goes
top right bottom left

if it’s
padding: 0 0 25px;
then it’s
top sides bottom

if it’s
padding: 0 25px;
then it’s
top-bottom, sides

if it’s
padding: 25px;
then it’s
all four sides.

A google search for “CSS shorthands” should be able to bring up all the shorthands and shorthand rules (you can use a shorthand for background, border, fonts as well, and some of them have special requirements).

You can set the width of the th and td using CSS too:

#shipping td {
 width: 310px;
}

#shipping th {
 width: 260px;
}

You should be careful about replicating the original table too much, as different browsers will always display the page slightly different (for example, the font will not look the same in Internet Explorer and Firefox). Furthermore, the user can always override the styles you set. Setting the width of the table and table data will be annoying to those who wish to use a larger font size and those using devices with small viewports (such as cellphones and PDAs). It is better to let the browser determine the size, based on the contents.

I’m happy to see that you’re learning quickly. I’ve been using CSS for almost a decade now (boy, I’m getting old ;)), and I’m still learning new techniques all the time. It’s a great tool, and while it may be a bit frustrating in the beginning, I can promise you that it’ll definitely pay off in the end.

C. Ankerstjerne ,
Thank you so very very much for all your help, the end result with some minor tweaks to the padding (thanks to the guy above - Stomme poes) looks exactly what I wanted & am over the moon about it - lets just hope I can get the same result with Table #2- in some ways it should be easier, but I will struggle with the CSS, but I guess that’s all a part of the learning process and it’s great to have guys like you & our new helper to better understand - if it was’nt for asking questions and getting help here and there we would all be lossed!.

Once again your time and patience is greatly appreciated, and I suppose I will be needing to take you up on the offer to ask questions when I run into a jam really soon - once I start getting into the CSS of Table 2 I can see myself getting lossed, but will try to use the reading I’ve found on the web and the lessons learned from table 1 to keep me going as long as possible.

Thanks again guys (C. Ankerstjerne and Stomme poes) & you will be hearing from me shortly :wink:

Yours Sincerely,
JC

JC, one more thing you might want to add to the XHTML is a “table summary.” The table summary is used mainly for the visually impaired. You can read about it here at Sitepoint.

Thanks for the advise eLePHANT, but I’m still a bit stuck on Table #2 at the moment - mixed things up quiet a bit trying to getting looking the same, so after some neatening a think it might be time to give a Help Me Out! shout out call to the guys OR anyone else keen to help me get table #2 looking the same. My CSS is just mixing things up, but atleast I’ve had some good reading this past week and have learned alot about CSS and how to use it across your whole website taking over ALL ‘old’ style tags, while adding a whole new range of effects ans style Inever knew were possible until my research. (thanks for the reading tips too whoever pointed me onto that css reading, once I learn a little more I may take the option ofgrabbing myself a copy of the CSS book discussed earlier (hopefully there is a 2nd hand copy floating around online - i only buy new books if i really have to.)

cheers guys and I will keep you updated!

JC

Honestly, lots is online.

I still look up my table specs here: http://www.w3.org/TR/2004/WD-xhtml2-20040722/mod-tables.html (fairly similar to the HTML4 ones, which, I write in HTML4 most of the time)

Accessibility and tables: http://www.webaim.org/techniques/tables/

I learned what axis really is/means/does and when it’s useless here: http://www.ferg.org/section508/accessible_tables.html
It’s old enough to say no user agents understand axis however 2002 is a long time ago and JAWS understands it, I believe Window-Eyes does too…

I used to state what the table was about in the table summary but Tommy Olsson says it should be used to describe how to read the table, or how it’s set up. Sometimes I simply cannot describe that, if the table is complicated enough. Or I’ll describe it in outside text instead (before the table and before the table caption).

This page sometimes has something I need about styling tables: http://www.w3.org/TR/CSS21/visuren.html

Thanks so much for your input Stomme poes and great links, I have added the to my bookmarks - I love getting links that help me learn more about html and css from you guys (the guys that KNOW it!) so again thank you kindly.
I’m still working on the 2nd table, but have been busy so haven’t got much done lately, but will post a screenshot when I get something workable going and see if one of you guys can help me out with the css (or getting it to look more like the examples in the first post) or fixing my code a little (thanks again all you guys for the help with the first table, it is now a fully working table just as shown in the screen shots in the 1st post).

I will keep this thread updated so someone else may also learn as I have, and hopefully this will help someone else too!

cheers guys, and I should have a working table #2 in the next couple of days and will post the code and screenshot, as no doubt I will need help with something - table#2 is more complex than I first thought to replicate.

Thanks Guys!
Jay.